Skip to content

Commit

Permalink
Merge pull request #2 from arendst/development
Browse files Browse the repository at this point in the history
6.4.1.16
  • Loading branch information
Jason2866 authored Feb 13, 2019
2 parents 34692ee + e779c7b commit 6e240c7
Show file tree
Hide file tree
Showing 73 changed files with 3,969 additions and 2,630 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ build
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
*.bak
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ A Sonoff device is not a toy. It uses Mains AC so there is a danger of electrocu
We don't take any responsibility nor liability for using this software nor for the installation or any tips, advice, videos, etc. given by any member of this site or any related site.

### Note
Please dont ask too add devices where you cant provide a basic working configuration (other than sonoff). Since there are thousands of them..
Please do not ask to add devices where you can't provide a basic working configuration (other than sonoff). Since there are thousands of them..

### Quick Install
Download one of the released binaries from https://github.com/arendst/Sonoff-Tasmota/releases and flash it to your hardware as documented in the wiki.
Expand Down
86 changes: 86 additions & 0 deletions TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
## Sonoff-Tasmota template information
Sonoff-Tasmota uses Device or Module information to control peripherals connected to GPIOs. This information is stored in the ``sonoff_template.h`` file as a device specific template. The template contains information about what GPIO should be connected to what peripheral and what GPIO may be configured online using the ``GPIO`` command or GUI Configure Module menu. In addition a device may need specific coding to process the data from these peripherals. The module number as provided by the ``Modules`` command is used to select this coding.

Starting with version 6.4.1.16 Sonoff-Tasmota Modules can be extended by users online using a template. To provide easy processing by Sonoff-Tasmota a user template is written as JSON text and could look like this:

{"NAME":"UserModule1","GPIO":[17,243,29,244,7,201,255,255,138,255,139,255,255],"FLAG":0,"BASE":18}

The four properties with UPPERCASE property names have the following functionality:

Property name | Property value description
--------------|-------------------------------------------------------------------------------------------------------------------
NAME | Up to 14 characters for the Module name
GPIO | Up to 13 decimal numbers from 0 to 255 representing GPIO0 to GPIO5, GPIO09, GPIO10 and GPIO12 to GPIO16
FLAG | 8 bit mask flag register
BASE | Module number of a hard-coded device to be used when device specific functionality is needed

The above example, based on the Generic Module does not allow ADC0 input.

## GPIO functionality
The GPIO functionality numbers are the same is shown by command ``GPIOs``. In addition code 255 is added to select a GPIO as user configurable via the GUI Configure Module menu.

## FLAG functionality
The FLAG value is an 8-bit mask where each bit controls a features. Add FLAG values to set multiple bits.

FLAG | Mask | Feature description
-----|----------|------------------------------
1 | xxxxxxx1 | Allowing to use Analog0 (ADC0) as input if define USE_ADC_VCC in ``my_user_config.h`` is disabled
2 | xxxxxx1x | Enable GUI pull-up control message
4 | xxxxx1xx | Not used
8 | xxxx1xxx | Not used
16 | xxx1xxxx | Not used
32 | xx1xxxxx | Not used
64 | x1xxxxxx | Not used
128 | 1xxxxxxx | Not used

## BASE functionality
The following table lists hard-coded device specific functionality. Notice that not all device modules need special handling.

BASE | Module | Description
-----|----------------|----------------------------------------------
4 | Sonoff Dual | Process relay and button via hardware serial interface using GPIO01 and GPIO03. Change baudrate to 19200 bps. Process buttons as single press only
9 | Sonoff Touch | Invert ledstate 1 functionality
10 | Sonoff LED | Set light type to 2 PWM channels disregarding SetOption15. Fix device specific LED instabilities by disabling GPIO04, GPIO5 and GPIO14
12 | 4 Channel | See 4
13 | Motor C/AC | Force all relays ON at Power On and disable command ``PowerOnState``
15 | EXS Relay(s) | Enable pulse latching using even/odd numbered relay pairs
18 | Generic | Show Wemos specific pin information in GUI
19 | H801 | Change hardware UART Tx from GPIO01 to GPIO02
20 | Sonoff SC | Enable and Process data via hardware serial interface using GPIO01 and GPIO03. Change baudrate to 19200 bps
21 | Sonoff BN-SZ | Set light type to 1 PWM channel disregarding SetOption15
22 | Sonoff 4CH Pro | Button handling disregarding SetOption13 only allowing single press to enable RF learning while holding the button
24 | Sonoff Bridge | Enable and Process data via hardware serial interface using GPIO01 and GPIO03. Change baudrate to 19200 bps. Process 16 buttons in web GUI. Enable EFM8BB1 firmware upload
25 | Sonoff B1 | Set light type to RGBWC using MY92x1
26 | AiLight | Set light type to RGBW using MY92x1
27 | Sonoff T1 1CH | See 9
28 | Sonoff T1 2CH | See 9
29 | Sonoff T1 3CH | See 9
38 | Sonoff Dual R2 | Process buttons as single press only
43 | Sonoff iFan02 | Enable command ``Fanspeed``. Disable Interlock and PulseTime. Tune status information, MQTT data and GUI. Sync with microcontroller. Process Domoticz Fan state
47 | Xiaomi Philips | Process Color Temperature using PWM2 and Intensity using PWM1
53 | Tuya Dimmer | Enable and Process data via software or hardware serial interface using GPIO 148 and 149 or forced GPIO01 and GPIO03. Change baudrate to 9600 bps. Process all Buttons
55 | ARMTR Dimmer | Enable and Process data via software or hardware serial interface using GPIO 148 and 149. Change baudrate to 115200 bps.
57 | PS-16-DZ | Enable and Process data via software or hardware serial interface using GPIO 148 and 149. Change baudrate to 19200 bps.
61 | YTF IR Bridge | Disable serial interface to stop loopback
65 | Mi Desk Lamp | Process rotary and Button1 data specific to this device

## Usage
A user provided template can be stored in Sonoff-Tasmota using the ``Template`` command. It has the following options.

Command | Payload | Description
---------|----------|---------------------------------------
Template | | Show current user template
Template | 0 | Copy active module template to user template
Template | 1 .. 69 | Copy hard-coded module template to user template

The following command will store a complete template based on the Generic module
``Template {"NAME":"UserModule1","GPIO":[17,243,29,244,7,201,255,255,138,255,139,255,255],"FLAG":0,"BASE":18}``

The following command will update the name of a stored template
``Template {"NAME":"UserModule2"}``

The following command will update the flag of a stored template
``Template {"FLAG":1}``

The following command will update the base of a stored template to Generic
``Template {"BASE":0}``
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ TasmotaSerial KEYWORD1
#######################################

begin KEYWORD2
hardwareSerial KEYWORD2
read KEYWORD2
write KEYWORD2
available KEYWORD2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "TasmotaSerial",
"version": "2.2.0",
"version": "2.3.0",
"keywords": [
"serial", "io", "TasmotaSerial"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TasmotaSerial
version=2.2.0
version=2.3.0
author=Theo Arends
maintainer=Theo Arends <[email protected]>
sentence=Implementation of software serial with hardware serial fallback for ESP8266.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
TasmotaSerial.cpp - Minimal implementation of software serial for Tasmota
Copyright (C) 2018 Theo Arends
Copyright (C) 2019 Theo Arends
This library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -100,7 +100,7 @@ TasmotaSerial::TasmotaSerial(int receive_pin, int transmit_pin, int hardware_fal
m_buffer = (uint8_t*)malloc(TM_SERIAL_BUFFER_SIZE);
if (m_buffer == NULL) return;
// Use getCycleCount() loop to get as exact timing as possible
m_bit_time = ESP.getCpuFreqMHz() *1000000 /TM_SERIAL_BAUDRATE;
m_bit_time = F_CPU / TM_SERIAL_BAUDRATE;
pinMode(m_rx_pin, INPUT);
tms_obj_list[m_rx_pin] = this;
attachInterrupt(m_rx_pin, ISRList[m_rx_pin], FALLING);
Expand Down Expand Up @@ -145,7 +145,7 @@ bool TasmotaSerial::begin(long speed, int stop_bits) {
}
} else {
// Use getCycleCount() loop to get as exact timing as possible
m_bit_time = ESP.getCpuFreqMHz() *1000000 /speed;
m_bit_time = F_CPU / speed;
m_high_speed = (speed > 9600);
}
return m_valid;
Expand Down Expand Up @@ -257,7 +257,7 @@ void TasmotaSerial::rxRead()
TM_SERIAL_WAIT;
}
// Store the received value in the buffer unless we have an overflow
int next = (m_in_pos+1) % TM_SERIAL_BUFFER_SIZE;
unsigned int next = (m_in_pos+1) % TM_SERIAL_BUFFER_SIZE;
if (next != (int)m_out_pos) {
m_buffer[m_in_pos] = rec;
m_in_pos = next;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
TasmotaSerial.h - Minimal implementation of software serial for Tasmota
Copyright (C) 2018 Theo Arends
Copyright (C) 2019 Theo Arends
This library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -22,7 +22,7 @@
/*********************************************************************************************\
* TasmotaSerial supports up to 115200 baud with fixed buffer size of 64 bytes using optional no iram
*
* Based on EspSoftwareSerial v3.3.1 by Peter Lerup (https://github.com/plerup/espsoftwareserial)
* Based on EspSoftwareSerial v3.4.3 by Peter Lerup (https://github.com/plerup/espsoftwareserial)
\*********************************************************************************************/

#define TM_SERIAL_BAUDRATE 9600 // Default baudrate
Expand Down
26 changes: 13 additions & 13 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ build_flags = ${esp82xx_defaults.build_flags}
-DVTABLES_IN_FLASH

[core_2_5_0]
; *** Esp8266 core for Arduino version Core 2.5.0 beta3 tested for Tasmota
; *** Esp8266 core for Arduino version 2.5.0 release (still not available via platformio)
platform = https://github.com/Jason2866/platform-espressif8266.git#Tasmota
build_flags = ${esp82xx_defaults.build_flags}
-Wl,-Teagle.flash.1m.ld
Expand Down Expand Up @@ -130,12 +130,12 @@ board_build.flash_mode = dout

platform = ${core_active.platform}
build_flags = ${core_active.build_flags}
; -DUSE_CLASSIC
; -DBE_MINIMAL
; -DUSE_SENSORS
; -DUSE_BASIC
; -DUSE_KNX_NO_EMULATION
; -DUSE_DISPLAYS
; -DFIRMWARE_CLASSIC
; -DFIRMWARE_MINIMAL
; -DFIRMWARE_SENSORS
; -DFIRMWARE_BASIC
; -DFIRMWARE_KNX_NO_EMULATION
; -DFIRMWARE_DISPLAYS
; -DUSE_CONFIG_OVERRIDE

; *** Fix [email protected] induced undesired all warnings
Expand Down Expand Up @@ -184,7 +184,7 @@ board = ${common.board}
board_build.flash_mode = ${common.board_build.flash_mode}
board_build.f_cpu = ${common.board_build.f_cpu}
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} -DBE_MINIMAL
build_flags = ${common.build_flags} -DFIRMWARE_MINIMAL
monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}
upload_resetmethod = ${common.upload_resetmethod}
Expand All @@ -198,7 +198,7 @@ board = ${common.board}
board_build.flash_mode = ${common.board_build.flash_mode}
board_build.f_cpu = ${common.board_build.f_cpu}
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} -DUSE_BASIC
build_flags = ${common.build_flags} -DFIRMWARE_BASIC
monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}
upload_resetmethod = ${common.upload_resetmethod}
Expand All @@ -212,7 +212,7 @@ board = ${common.board}
board_build.flash_mode = ${common.board_build.flash_mode}
board_build.f_cpu = ${common.board_build.f_cpu}
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} -DUSE_CLASSIC
build_flags = ${common.build_flags} -DFIRMWARE_CLASSIC
monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}
upload_resetmethod = ${common.upload_resetmethod}
Expand All @@ -226,7 +226,7 @@ board = ${common.board}
board_build.flash_mode = ${common.board_build.flash_mode}
board_build.f_cpu = ${common.board_build.f_cpu}
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} -DUSE_KNX_NO_EMULATION
build_flags = ${common.build_flags} -DFIRMWARE_KNX_NO_EMULATION
monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}
upload_resetmethod = ${common.upload_resetmethod}
Expand All @@ -240,7 +240,7 @@ board = ${common.board}
board_build.flash_mode = ${common.board_build.flash_mode}
board_build.f_cpu = ${common.board_build.f_cpu}
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} -DUSE_SENSORS
build_flags = ${common.build_flags} -DFIRMWARE_SENSORS
monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}
upload_resetmethod = ${common.upload_resetmethod}
Expand All @@ -254,7 +254,7 @@ board = ${common.board}
board_build.flash_mode = ${common.board_build.flash_mode}
board_build.f_cpu = ${common.board_build.f_cpu}
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} -DUSE_DISPLAYS
build_flags = ${common.build_flags} -DFIRMWARE_DISPLAYS
monitor_speed = ${common.monitor_speed}
upload_port = ${common.upload_port}
upload_resetmethod = ${common.upload_resetmethod}
Expand Down
28 changes: 27 additions & 1 deletion sonoff/_changelog.ino
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
/* 6.4.1.12 20190128
/* 6.4.1.16 20190211
* Initial support for online template change using command Template or GUI Configure Other (#5177)
*
* 6.4.1.15 20190208
* Change image name BE_MINIMAL to FIRMWARE_MINIMAL (#5106)
* Change image names USE_xyz to FIRMWARE_xyz (#5106)
* Add command SerialDelimiter 128 to filter reception of only characters between ASCII 32 and 127 (#5131)
* Add status message to former declined group commands (#5145)
*
* 6.4.1.14 20190203
* Add SetOption32 until SetOption49 diagnostic information to Status 3 report as replacement for second property value in SetOption property name
* Add Resolution property to Status 3 report providing previous SetOption second value property
* Fix IR local echo
* Add user configuration of HLW8012 and HJL-01/BL0937 Energy Monitoring as used in Sonoff S31, Pow Ra and many Tuya based devices
* Add user configuration of MCP39F501 Energy Monitoring as used in Shelly2
* Add support for multiple ADS1115 I2C devices (#5083)
* Add rule support for "==", "!=" ">=" and "<=" (#5122)
* Add Hass status sensor (#5139)
* Change GUI weblog solving possible empty screens (#5154)
* Change PN532 support from I2C to Serial for more stability (#5162)
* Add MHZ19 Temperature as Domoticz Temperature selection (#5128)
*
* 6.4.1.13 20190130
* Add command SetOption36 to control boot loop default restoration (#4645, #5063)
* Add resiliency to saved Settings (#5065)
*
* 6.4.1.12 20190128
* Change code use of boolean to bool and byte to uint8_t
* Change code uint8_t flags to bool flags
*
Expand Down
10 changes: 9 additions & 1 deletion sonoff/i18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
#define D_JSON_PROGRAMSIZE "ProgramSize"
#define D_JSON_REFERENCETEMPERATURE "ReferenceTemperature"
#define D_JSON_RESET "Reset"
#define D_JSON_RESOLUTION "Resolution"
#define D_JSON_RESTARTING "Restarting"
#define D_JSON_RESTARTREASON "RestartReason"
#define D_JSON_RSSI "RSSI"
Expand Down Expand Up @@ -159,6 +160,7 @@
#define D_JSON_ZERO_POINT_CALIBRATION "Zero Point Calibration"

#define D_RSLT_ENERGY "ENERGY"
#define D_RSLT_HASS_STATE "HASS_STATE"
#define D_RSLT_INFO "INFO"
#define D_RSLT_MARGINS "MARGINS"
#define D_RSLT_POWER "POWER"
Expand All @@ -168,6 +170,8 @@
#define D_RSLT_UPTIME "UPTIME"
#define D_RSLT_WARNING "WARNING"

#define D_LOG_SOME_SETTINGS_RESET "Some settings have been reset"

// Commands sonoff.ino
#define D_CMND_BACKLOG "Backlog"
#define D_CMND_DELAY "Delay"
Expand Down Expand Up @@ -259,7 +263,11 @@
#define D_CMND_SERIALSEND "SerialSend"
#define D_CMND_SERIALDELIMITER "SerialDelimiter"
#define D_CMND_BAUDRATE "Baudrate"
#define D_LOG_SOME_SETTINGS_RESET "Some settings have been reset"
#define D_CMND_TEMPLATE "Template"
#define D_JSON_NAME "NAME"
#define D_JSON_GPIO "GPIO"
#define D_JSON_FLAG "FLAG"
#define D_JSON_BASE "BASE"

// Commands xdrv_01_mqtt.ino
#define D_CMND_MQTTHOST "MqttHost"
Expand Down
Loading

0 comments on commit 6e240c7

Please sign in to comment.