mirror of https://github.com/arendst/Tasmota.git
Merge branch 'development' of github.com:arendst/Tasmota into pr_tm1638
This commit is contained in:
commit
3c0f4bea13
|
@ -1,26 +1,10 @@
|
|||
**Fork of RC-SWITCH by @sui77**
|
||||
|
||||
# rc-switch
|
||||
[![Build Status](https://travis-ci.org/1technophile/rc-switch.svg?branch=master)](https://travis-ci.org/1technophile/rc-switch)
|
||||
|
||||
Use your Arduino or Raspberry Pi to operate remote radio controlled devices
|
||||
|
||||
## Download
|
||||
https://github.com/1technophile/rc-switch/releases/latest
|
||||
|
||||
rc-switch is also listed in the arduino library manager.
|
||||
|
||||
## Wiki
|
||||
https://github.com/1technophile/rc-switch/wiki
|
||||
**Modified Tasmota Fork of RC-SWITCH by @sui77 and @1technophile**
|
||||
|
||||
## Info
|
||||
### Send RC codes
|
||||
|
||||
Use your Arduino or Raspberry Pi to operate remote radio controlled devices.
|
||||
This will most likely work with all popular low cost power outlet sockets. If
|
||||
yours doesn't work, you might need to adjust the pulse length.
|
||||
This will most likely work with all popular low cost power outlet sockets.
|
||||
|
||||
All you need is a Arduino or Raspberry Pi, a 315/433MHz AM transmitter and one
|
||||
All you need is a 315/433MHz AM transmitter and one
|
||||
or more devices with one of the supported chipsets:
|
||||
|
||||
- SC5262 / SC5272
|
||||
|
@ -30,14 +14,3 @@ or more devices with one of the supported chipsets:
|
|||
- Intertechno outlets
|
||||
- HT6P20X
|
||||
|
||||
### Receive and decode RC codes
|
||||
|
||||
Find out what codes your remote is sending. Use your remote to control your
|
||||
Arduino.
|
||||
|
||||
All you need is an Arduino, a 315/433MHz AM receiver (altough there is no
|
||||
instruction yet, yes it is possible to hack an existing device) and a remote
|
||||
hand set.
|
||||
|
||||
For the Raspberry Pi, clone the https://github.com/ninjablocks/433Utils project to
|
||||
compile a sniffer tool and transmission commands.
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
{
|
||||
"name": "rc-switch",
|
||||
"description": "Use your Arduino or Raspberry Pi to operate remote radio controlled devices",
|
||||
"description": "Use ESP8266/ESP32 to operate remote radio controlled devices",
|
||||
"keywords": "rf, radio, wireless",
|
||||
"authors":
|
||||
{
|
||||
"name": "Suat Ozgur"
|
||||
"name": "Theo Arends"
|
||||
},
|
||||
"repository":
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/sui77/rc-switch.git"
|
||||
"url": "https://github.com/arendst/Tasmota.git"
|
||||
},
|
||||
"version": "2.6.2",
|
||||
"version": "1.0.0",
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"energia",
|
||||
"wiringpi"
|
||||
"arduino"
|
||||
],
|
||||
"platforms": "*"
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
name=rc-switch
|
||||
version=2.6.2
|
||||
author=sui77
|
||||
maintainer=sui77,fingolfin <noreply@sui.li>
|
||||
version=1.0.0
|
||||
author=@sui77 @1technophile and more
|
||||
maintainer=Theo Arends
|
||||
sentence=Operate 433/315Mhz devices.
|
||||
paragraph=Use your Arduino, ESP8266/ESP32 or Raspberry Pi to operate remote radio controlled devices. This will most likely work with all popular low cost power outlet sockets.
|
||||
paragraph=Use ESP8266/ESP32 to operate remote radio controlled devices.
|
||||
category=Device Control
|
||||
url=https://github.com/sui77/rc-switch
|
||||
architectures=avr,esp8266,esp32
|
||||
url=https://github.com/arendst/Tasmota
|
||||
architectures=esp8266,esp32
|
||||
includes=RCSwitch.h
|
||||
|
|
|
@ -2,39 +2,40 @@
|
|||
// compressed by tools/unishox/compress-html-uncompressed.py
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
const size_t HTTP_SCRIPT_CONSOL_SIZE = 911;
|
||||
const char HTTP_SCRIPT_CONSOL_COMPRESSED[] PROGMEM = "\x33\xBF\xAF\x71\xF0\xE3\x3A\x8B\x44\x3E\x1C\x67\x51\x18\xA3\xC1\x81\x7C\x1D\x6E"
|
||||
"\x72\x08\xEE\x8C\x3B\xC7\xB4\xCE\xFE\x83\x3A\xB0\xF8\x7D\x9F\x67\x80\xC2\x77\xF2"
|
||||
"\xAD\x1A\xF0\x5D\x1D\xD0\xA8\xEF\x02\x4C\xD3\x14\x77\x8F\x14\x7C\x63\x8E\xE9\xF7"
|
||||
"\x47\x21\xF6\x77\x8F\x05\xA6\x0E\xE8\xC3\xE1\xF0\xE4\x3B\xC7\xB4\x83\x3E\x31\xC7"
|
||||
"\x74\xFB\x0C\xE4\x3E\xCE\xF1\xE0\xB0\xF8\x7D\x9F\xA0\xCE\x43\xE1\xF6\x76\xC9\xF0"
|
||||
"\x78\x23\x21\x65\xF2\xD2\x0F\x06\x8C\xCE\x7D\x47\x74\x33\xA1\x9D\x84\x2D\x9D\xE3"
|
||||
"\xC0\x21\x45\x3E\x1F\x67\xD9\xE2\x8E\x9E\x0F\xF8\x10\x45\x58\x30\xF8\x71\x11\xBD"
|
||||
"\x2A\x01\xF1\xEE\x3E\x02\x35\x13\xC1\xEE\xD3\x07\x74\x11\xA6\x1F\x87\xCF\x71\xDE"
|
||||
"\x3D\xBA\x60\xEE\x9B\x0F\xE1\xF3\x85\x84\x11\xDE\x3D\xA6\xC3\xA5\x8E\xCF\xD1\xDD"
|
||||
"\x3B\xC7\x83\xDC\x6C\x3E\x73\x1F\x44\x6C\x21\xA4\x11\x0A\xAA\x18\x5F\x66\xA1\x6F"
|
||||
"\xD4\x77\x4E\xF1\xE0\xD8\x74\xCE\xFB\xB1\x0C\xBD\x57\x4C\x31\x57\xC3\xCC\xF8\x08"
|
||||
"\x7C\x2F\x9D\xD0\x41\xCA\x8E\x9F\x76\x21\x91\x7A\xAE\x99\xF0\xF8\x73\x0F\xD1\xFA"
|
||||
"\x23\x61\xD3\xD5\x74\x2F\xC7\xC3\xE1\xCA\x6C\x81\x07\x87\xF3\x69\xD4\x21\xE0\x43"
|
||||
"\xE1\xB0\xE9\xF7\xE1\x99\xDE\x65\x4C\xD9\x47\x4F\x0C\x0B\x68\xEE\x9D\x87\xB8\xE4"
|
||||
"\x3B\x0E\xF1\xE0\xB4\x43\xE0\x87\x4F\x0A\xD3\x14\x77\x4E\xF1\xE3\x4C\x1D\xD0\x44"
|
||||
"\x92\x7C\x3E\x1C\x67\x78\xF6\x95\x02\x2F\x0A\x27\xB8\xDA\x09\x38\x29\xB4\xE8\x13"
|
||||
"\xE1\xEA\x14\x7E\x02\x2E\x06\x76\xCF\x86\xD3\xC1\xEE\x05\xCE\x1E\x41\x33\x8F\xA0"
|
||||
"\xA8\xF9\xE7\x40\x89\xC8\xE9\xD4\x7D\x08\x77\x8F\x07\xB8\xF7\x1E\x0D\x87\x4C\x18"
|
||||
"\xF8\xEE\x9F\x64\x3C\x4C\xA8\xFB\x3A\x8F\xB0\xFC\x76\x83\x39\x47\xC3\xEC\xED\x96"
|
||||
"\x88\x76\xF0\xEA\xAF\x8B\x67\x78\xF0\x6C\x3A\x79\xF0\x87\x74\xEF\x1E\x0C\x02\x56"
|
||||
"\x3A\x72\x9B\x6C\xEF\x1E\x0F\x71\x7D\xD0\xBF\xF2\x31\x61\x79\x9E\x0F\x70\xF8\x47"
|
||||
"\x74\x23\xBC\x78\x33\xBF\xA1\x41\x9F\x0F\x78\xF7\xCE\xA0\xF8\xF8\x71\x90\x22\xF3"
|
||||
"\x62\x28\xEE\x9D\xE3\xDA\x08\x7C\xB6\x9D\x2C\x41\x09\x99\xBE\xA2\x0B\x7D\x4F\x9F"
|
||||
"\xCE\xE9\xF6\x68\xCC\x84\xC1\xFE\x3E\xCE\xA0\x44\xE3\x7D\x82\x0F\x17\xA3\x81\x13"
|
||||
"\x9A\x33\xA8\x33\xE3\x3A\x1A\x33\x22\x0F\x04\x67\x8D\x30\x77\x4E\x5F\xCF\x87\xC2"
|
||||
"\x0C\xFF\x1F\xE3\x98\xCF\x87\xC2\x0C\xEF\x1E\xD1\xC7\x4B\x17\x58\x1E\x0D\x18\x13"
|
||||
"\xA6\x7C\x3E\xF0\xC1\x83\xEC\xF0\x7B\x8E\x5F\xCF\x87\xC2\x0C\xED\x1D\xD3\xB6\x76"
|
||||
"\xC3\xE3\xF0\x50\x60\x85\xC5\x71\xFA\x3F\x47\x74\x3E\x3E\x02\x24\xB3\xBC\x75\x0E"
|
||||
"\x04\x2E\x38\x85\x06\x7B\xC1\xF1\xD6\x72\x1E\xF9\xFE\x3F\xC7\xD9\xF6\x77\x8F\x3C"
|
||||
"\x67\xC3\xE1\x06\x76\x8E\xE9\xC6\x7E\x1D\x67\x59\x07\xC0\x83\x88\x1C\x64\x0A\x78"
|
||||
"\x41\xC9\x67\xC3\xE1\x06\x7E\x8F\xD1\xDD\x04\x4C\xC4\xFC\x39\x11\xFA\x3F\x44\x28"
|
||||
"\x33\xA0\xCC\x18\x77\x4E\xF1\xD4\x28\x33\xA0\xBE\x04\x1E\x4E\x01\x0B\x1C\x3B\xC7"
|
||||
"\x50\x7C\x7C\x38\xCE\xF1\xEE\x3B\xC7\x83\xDC\x43\xE1\x1D\xD1\x47\x78\xF0";
|
||||
const size_t HTTP_SCRIPT_CONSOL_SIZE = 946;
|
||||
const char HTTP_SCRIPT_CONSOL_COMPRESSED[] PROGMEM = "\x33\xBF\xAF\x71\xF0\xE3\x3A\x8B\x44\x3E\x1C\x67\x51\x18\xA3\xA8\x2A\x2B\x1A\x7C"
|
||||
"\x3E\x84\x3C\x18\x17\xC1\xD6\xE7\x20\x8E\xE8\xC3\xBC\x7B\x4C\xEF\xE8\x33\xAB\x0F"
|
||||
"\x87\xD9\xF6\x78\x0C\x27\x7F\x2A\x2B\xD1\xAF\x05\xD1\xDD\x0A\x8E\xF0\x24\xCD\x31"
|
||||
"\x47\x78\xF1\x47\xC6\x38\xEE\x9F\x74\x72\x1F\x67\x78\xF0\x5A\x60\xEE\x8C\x3E\x1F"
|
||||
"\x0E\x43\xBC\x7B\x48\x33\xE3\x1C\x77\x4F\xB0\xCE\x43\xEC\xEF\x1E\x0B\x0F\x87\xD9"
|
||||
"\xFA\x0C\xE4\x3E\x1F\x67\x6C\x9F\x07\x82\x32\x16\x5F\x2D\x20\xF0\x68\xCC\xE7\xD4"
|
||||
"\x77\x43\x3A\x19\xD8\x42\xD9\xDE\x3C\x02\x14\x53\xE1\xF6\x7D\x9E\x28\xE9\xE0\xFF"
|
||||
"\x81\x04\x55\x83\x0F\x87\x11\x1B\xD0\x0F\x1E\xE3\xE0\x23\x51\x3C\x1E\xED\x30\x77"
|
||||
"\x41\x1A\x61\xF8\x7C\xF7\x1D\xE3\xDB\xA6\x0E\xE9\xB0\xFE\x1F\x38\x58\x41\x1D\xE3"
|
||||
"\xDA\x6C\x3A\x58\xEC\xFD\x1D\xD3\xBC\x78\x3D\xC6\xC3\xE7\x31\xF4\x46\xC2\x1A\x41"
|
||||
"\x10\xAA\xA1\x85\xF6\x6A\x16\xFD\x47\x74\xEF\x1E\x0D\x87\x4C\xEF\xBB\x10\xCB\xD5"
|
||||
"\x74\xC3\x15\x7C\x3C\xCF\x80\x87\xC2\xF9\xDD\x04\x1C\xA8\xE9\xF7\x62\x19\x17\xAA"
|
||||
"\xE9\x9F\x0F\x87\x30\xFD\x1F\xA2\x36\x1D\x3D\x57\x42\xFC\x7C\x3E\x1C\xA6\xC8\x10"
|
||||
"\x78\x7F\x36\x9D\x42\x1E\x04\x3E\x1B\x0E\x9F\x7E\x19\x9D\xE6\x54\xCD\x94\x74\xF0"
|
||||
"\xC0\xB6\x8E\xE9\xD8\x7B\x8E\x43\xB0\xEF\x1E\x0B\x44\x3E\x08\x74\xF0\xAD\x31\x47"
|
||||
"\x74\xEF\x1E\x34\xC1\xDD\x04\x49\x27\xC3\xE1\xC6\x77\x8F\x69\x50\x22\xF0\xA2\x7B"
|
||||
"\x8D\xA0\x93\x82\x9B\x4E\x81\x3E\x1E\xA1\x47\xE0\x22\xE0\x67\x6C\xF8\x6D\x3C\x1E"
|
||||
"\xE0\x5C\xE1\xE4\x13\x38\xFA\x0A\x8F\x9E\x74\x08\x9C\x8E\x9D\x41\x50\xD3\xBC\x78"
|
||||
"\x3D\xC7\xB8\xF0\x6C\x3A\x60\xC7\xC7\x74\xFB\x21\xE2\x65\x47\xD9\xD4\x7D\x87\xE3"
|
||||
"\xB4\x19\xCA\x3E\x1F\x67\x6C\xB4\x43\xB7\x87\x55\x7C\x5B\x3B\xC7\x83\x61\xD3\xCF"
|
||||
"\x84\x3B\xA7\x78\xF0\x60\x12\xB1\xE3\x94\xDB\x67\x78\xF0\x7B\x89\x85\xE6\x7B\x41"
|
||||
"\x47\x3B\xFB\xA1\x7F\xE4\x62\xC2\xF3\x3C\x1E\xE1\xF0\x8E\xE8\x47\x78\xF0\x67\x7F"
|
||||
"\x42\x83\x3E\x1E\xF1\xEF\x9D\x41\xF1\xF0\xE3\x20\x45\xE7\x34\x51\xDD\x3B\xC7\xB4"
|
||||
"\x10\xF9\x89\x3A\x58\x82\x13\x33\x7D\x44\x16\xFA\x9F\x3F\x9D\xD3\xEC\xD1\x99\x09"
|
||||
"\x83\xFC\x7D\x9D\x40\x89\xC7\xDB\x04\x1E\x36\x47\x02\x27\x37\xE7\x50\x67\xC6\x74"
|
||||
"\x34\x66\x44\x1E\x08\xCF\x1A\x60\xEE\x9C\xBF\x9F\x0F\x84\x19\xFE\x3F\xC7\x31\x9F"
|
||||
"\x0F\x84\x19\xDE\x3D\xA3\x8E\x96\x2E\xB0\x3C\x1A\x30\x27\x4C\xF8\x7D\xE1\x83\x07"
|
||||
"\xD9\xE0\xF7\x1C\xBF\x9F\x0F\x84\x19\xDA\x3B\xA7\x6C\xED\x87\xC7\xE0\xA0\xC1\x0B"
|
||||
"\x8C\xA3\xF4\x7E\x8E\xE8\x7C\x7C\x04\x49\x67\x78\xEA\x1C\x08\x5C\x7F\x0A\x0C\xF7"
|
||||
"\x83\xE3\xAC\xE4\x3D\xF3\xFC\x7F\x8F\xB3\xEC\xEF\x1E\x78\xCF\x87\xC2\x0C\xED\x1D"
|
||||
"\xD3\x8C\xFC\x3A\xCE\xB2\x0F\x81\x07\x10\x38\xC8\x14\xF0\x83\x92\xCF\x87\xC2\x0C"
|
||||
"\xFD\x1F\xA3\xBA\x08\x99\x89\xF8\x72\x23\xF4\x7E\x88\x50\x67\x41\x98\x30\xEE\x9D"
|
||||
"\xE3\xA8\x50\x67\x41\x7C\x08\x3C\xAA\x02\x16\x38\x77\x8E\xA0\xF8\xF8\x71\x9D\xE3"
|
||||
"\xDC\x77\x8F\x07\xB8\x87\xC2\x3B\xA2\x8E\xF1\xE0";
|
||||
|
||||
#define HTTP_SCRIPT_CONSOL Decompress(HTTP_SCRIPT_CONSOL_COMPRESSED,HTTP_SCRIPT_CONSOL_SIZE).c_str()
|
|
@ -1,5 +1,5 @@
|
|||
const char HTTP_SCRIPT_CONSOL[] PROGMEM =
|
||||
"var sn=0,id=0,ft;" // Scroll position, Get most of weblog initially
|
||||
"var sn=0,id=0,ft,ltm=%d;" // Scroll position, Get most of weblog initially
|
||||
"function l(p){" // Console log and command service
|
||||
"var c,o='';"
|
||||
"clearTimeout(lt);"
|
||||
|
@ -26,12 +26,14 @@ const char HTTP_SCRIPT_CONSOL[] PROGMEM =
|
|||
"t.scrollTop=99999;"
|
||||
"sn=t.scrollTop;"
|
||||
"clearTimeout(ft);"
|
||||
"lt=setTimeout(l,%d);" // webrefresh timer....
|
||||
"lt=setTimeout(l,ltm);" // webrefresh timer....
|
||||
"}"
|
||||
"};"
|
||||
"x.open('GET','cs?c2='+id+o,true);" // Related to Webserver->hasArg("c2") and WebGetArg("c2", stmp, sizeof(stmp))
|
||||
"x.send();"
|
||||
"ft=setTimeout(l,20000);" // fail timeout, triggered 20s after asking for XHR
|
||||
"}else{"
|
||||
"lt=setTimeout(l,ltm);" // webrefresh timer....
|
||||
"}"
|
||||
"return false;"
|
||||
"}"
|
||||
|
|
|
@ -402,7 +402,7 @@ void SendReceiveDeviceGroupMessage(struct device_group * device_group, struct de
|
|||
case DGR_ITEM_POWER:
|
||||
if (Settings.flag4.multiple_device_groups) { // SetOption88 - Enable relays in separate device groups
|
||||
uint32_t device = Settings.device_group_tie[device_group_index];
|
||||
if (device) {
|
||||
if (device && device <= TasmotaGlobal.devices_present) {
|
||||
bool on = (value & 1);
|
||||
if (on != ((TasmotaGlobal.power >> (device - 1)) & 1)) ExecuteCommandPower(device, (on ? POWER_ON : POWER_OFF), SRC_REMOTE);
|
||||
}
|
||||
|
|
|
@ -645,7 +645,7 @@ bool MCP230xx_Command(void)
|
|||
return serviced;
|
||||
}
|
||||
#ifdef USE_MCP230xx_OUTPUT
|
||||
if (Settings.mcp230xx_config[pin].pinmode >= 5) {
|
||||
if (Settings.mcp230xx_config[pin].pinmode >= 5 && paramcount == 2) {
|
||||
uint8_t pincmd = Settings.mcp230xx_config[pin].pinmode - 5;
|
||||
uint8_t relay_no = 0;
|
||||
for (relay_no = 0; relay_no < mcp230xx_pincount ; relay_no ++) {
|
||||
|
|
|
@ -912,6 +912,17 @@ void Dump2log(void) {
|
|||
#endif
|
||||
break;
|
||||
}
|
||||
} else if (meter_desc_p[(dump2log&7)-1].type=='v') {
|
||||
// vbus
|
||||
c=SML_SREAD;
|
||||
if (c==EBUS_SYNC) {
|
||||
index = 0;
|
||||
AddLogData(LOG_LEVEL_INFO, log_data);
|
||||
}
|
||||
sprintf(&log_data[index],"%02x ",c);
|
||||
if (index<sizeof(log_data)-3) {
|
||||
index+=3;
|
||||
}
|
||||
} else {
|
||||
// sml
|
||||
if (sml_start==0x77) {
|
||||
|
@ -929,7 +940,7 @@ void Dump2log(void) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (index>2) {
|
||||
if (index>2 && (meter_desc_p[(dump2log&7)-1].type!='v')) {
|
||||
log_data[index]=0;
|
||||
AddLogData(LOG_LEVEL_INFO, log_data);
|
||||
}
|
||||
|
@ -1208,7 +1219,7 @@ void sml_empty_receiver(uint32_t meters) {
|
|||
|
||||
void sml_shift_in(uint32_t meters,uint32_t shard) {
|
||||
uint32_t count;
|
||||
if (meter_desc_p[meters].type!='e' && meter_desc_p[meters].type!='m' && meter_desc_p[meters].type!='M' && meter_desc_p[meters].type!='p' && meter_desc_p[meters].type!='R') {
|
||||
if (meter_desc_p[meters].type!='e' && meter_desc_p[meters].type!='m' && meter_desc_p[meters].type!='M' && meter_desc_p[meters].type!='p' && meter_desc_p[meters].type!='R' && meter_desc_p[meters].type!='v') {
|
||||
// shift in
|
||||
for (count=0; count<SML_BSIZ-1; count++) {
|
||||
smltbuf[meters][count]=smltbuf[meters][count+1];
|
||||
|
@ -1251,6 +1262,17 @@ void sml_shift_in(uint32_t meters,uint32_t shard) {
|
|||
if (meter_spos[meters]>=SML_BSIZ) {
|
||||
meter_spos[meters]=0;
|
||||
}
|
||||
} else if (meter_desc_p[meters].type=='v') {
|
||||
if (iob==EBUS_SYNC) {
|
||||
SML_Decode(meters);
|
||||
smltbuf[meters][0] = iob;
|
||||
meter_spos[meters] = 1;
|
||||
} else {
|
||||
if (meter_spos[meters] < SML_BSIZ) {
|
||||
smltbuf[meters][meter_spos[meters]] = iob;
|
||||
meter_spos[meters]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (iob==EBUS_SYNC) {
|
||||
|
@ -1278,7 +1300,7 @@ void sml_shift_in(uint32_t meters,uint32_t shard) {
|
|||
}
|
||||
}
|
||||
sb_counter++;
|
||||
if (meter_desc_p[meters].type!='e' && meter_desc_p[meters].type!='m' && meter_desc_p[meters].type!='M' && meter_desc_p[meters].type!='p' && meter_desc_p[meters].type!='R') SML_Decode(meters);
|
||||
if (meter_desc_p[meters].type!='e' && meter_desc_p[meters].type!='m' && meter_desc_p[meters].type!='M' && meter_desc_p[meters].type!='p' && meter_desc_p[meters].type!='R' && meter_desc_p[meters].type!='v') SML_Decode(meters);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1297,6 +1319,33 @@ uint32_t meters;
|
|||
}
|
||||
}
|
||||
|
||||
#define VBUS_BAD_CRC 0
|
||||
// get vbus septet with 6 bytes
|
||||
uint32_t vbus_get_septet(uint8_t *cp) {
|
||||
uint32_t result = 0;
|
||||
|
||||
//AddLog(LOG_LEVEL_INFO,PSTR("septet: %02x %02x %02x %02x %02x %02x"),cp[0] ,cp[1],cp[2],cp[3],cp[4],cp[5]);
|
||||
|
||||
uint8_t Crc = 0x7F;
|
||||
for (uint32_t i = 0; i < 5; i++) {
|
||||
Crc = (Crc - cp[i]) & 0x7f;
|
||||
}
|
||||
if (Crc != cp[5]) {
|
||||
result = VBUS_BAD_CRC;
|
||||
} else {
|
||||
result = (cp[3] | ((cp[4]&8)<<4));
|
||||
result <<= 8;
|
||||
result |= (cp[2] | ((cp[4]&4)<<5));
|
||||
result <<= 8;
|
||||
result |= (cp[1] | ((cp[4]&2)<<6));
|
||||
result <<= 8;
|
||||
result |= (cp[0] | ((cp[4]&1)<<7));
|
||||
}
|
||||
|
||||
//AddLog(LOG_LEVEL_INFO,PSTR("septet r: %d"),result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void SML_Decode(uint8_t index) {
|
||||
const char *mp=(const char*)meter_p;
|
||||
|
@ -1342,7 +1391,7 @@ void SML_Decode(uint8_t index) {
|
|||
while (*mp>='0' && *mp<='9') mp++;
|
||||
if (ind<1 || ind>SML_MAX_VARS) ind=1;
|
||||
dvar=meter_vars[ind-1];
|
||||
for (uint8_t p=0;p<5;p++) {
|
||||
for (uint8_t p = 0; p < 5; p++) {
|
||||
if (*mp=='@') {
|
||||
// store result
|
||||
meter_vars[vindex]=dvar;
|
||||
|
@ -1438,12 +1487,20 @@ void SML_Decode(uint8_t index) {
|
|||
found=0;
|
||||
}
|
||||
} else {
|
||||
// ebus mbus pzem or raw
|
||||
// ebus mbus pzem vbus or raw
|
||||
// XXHHHHSSUU
|
||||
if (*mp=='x' && *(mp+1)=='x') {
|
||||
//ignore
|
||||
mp+=2;
|
||||
cp++;
|
||||
if (*mp=='x') {
|
||||
if (*(mp+1)=='x') {
|
||||
//ignore one byte
|
||||
mp += 2;
|
||||
cp++;
|
||||
} else {
|
||||
mp++;
|
||||
if (isdigit(*mp)) {
|
||||
uint8_t skip = strtol((char*)mp, (char**)&mp, 10);
|
||||
cp += skip;
|
||||
}
|
||||
}
|
||||
} else if (!strncmp(mp,"UUuuUUuu",8)) {
|
||||
uint32_t val= (cp[0]<<24)|(cp[1]<<16)|(cp[2]<<8)|(cp[3]<<0);
|
||||
ebus_dval=val;
|
||||
|
@ -1530,6 +1587,99 @@ void SML_Decode(uint8_t index) {
|
|||
mp+=4;
|
||||
cp+=2;
|
||||
}
|
||||
else if (*mp == 'v') {
|
||||
// vbus values vul, vsl, vuwh, vuwl, wswh, vswl, vswh
|
||||
// vub3, vsb3 etc
|
||||
mp++;
|
||||
int16_t offset = -1;
|
||||
if (*mp == 'o') {
|
||||
mp++;
|
||||
offset = strtol((char*)mp, (char**)&mp, 10);
|
||||
cp += (offset / 4) * 6;
|
||||
}
|
||||
uint8_t usign;
|
||||
if (*mp == 'u') {
|
||||
usign = 1;
|
||||
} else if (*mp == 's') {
|
||||
usign = 0;
|
||||
}
|
||||
mp++;
|
||||
switch (*mp) {
|
||||
case 'l':
|
||||
mp++;
|
||||
// get long value
|
||||
if (usign) {
|
||||
ebus_dval = vbus_get_septet(cp);
|
||||
} else {
|
||||
ebus_dval = (int32_t)vbus_get_septet(cp);
|
||||
}
|
||||
break;
|
||||
case 'w':
|
||||
mp++;
|
||||
char wflg;
|
||||
if (offset >= 0) {
|
||||
if (offset % 4) {
|
||||
wflg = 'h';
|
||||
} else {
|
||||
wflg = 'l';
|
||||
}
|
||||
} else {
|
||||
wflg = *mp;
|
||||
mp++;
|
||||
}
|
||||
// get word value
|
||||
if (wflg == 'h') {
|
||||
// high word
|
||||
if (usign) ebus_dval = (vbus_get_septet(cp) >> 16) & 0xffff;
|
||||
else ebus_dval = (int16_t)((vbus_get_septet(cp) >> 16) & 0xffff);
|
||||
} else {
|
||||
// low word
|
||||
if (usign) ebus_dval = vbus_get_septet(cp) & 0xffff;
|
||||
else (int16_t)(vbus_get_septet(cp) & 0xffff);
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
mp++;
|
||||
char bflg;
|
||||
if (offset >= 0) {
|
||||
bflg = 0x30 | (offset % 4);
|
||||
} else {
|
||||
bflg = *mp;
|
||||
mp++;
|
||||
}
|
||||
switch (bflg) {
|
||||
case '3':
|
||||
if (usign) ebus_dval = vbus_get_septet(cp) >> 24;
|
||||
else ebus_dval = (int8_t)(vbus_get_septet(cp) >> 24);
|
||||
break;
|
||||
case '2':
|
||||
if (usign) ebus_dval = (vbus_get_septet(cp) >> 16) & 0xff;
|
||||
else ebus_dval = (int8_t)((vbus_get_septet(cp) >> 16) & 0xff);
|
||||
break;
|
||||
case '1':
|
||||
if (usign) ebus_dval = (vbus_get_septet(cp) >> 8) & 0xff;
|
||||
else ebus_dval = (int8_t)((vbus_get_septet(cp) >> 8) & 0xff);
|
||||
break;
|
||||
case '0':
|
||||
if (usign) ebus_dval = vbus_get_septet(cp) & 0xff;
|
||||
else ebus_dval = (int8_t)(vbus_get_septet(cp) & 0xff);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
mp++;
|
||||
{ uint16_t time;
|
||||
if (offset % 4) {
|
||||
time = (vbus_get_septet(cp) >> 16) & 0xffff;
|
||||
} else {
|
||||
time = vbus_get_septet(cp) & 0xffff;
|
||||
}
|
||||
sprintf(&meter_id[mindex][0], "%02d:%02d", time / 60, time % 60);
|
||||
}
|
||||
break;
|
||||
}
|
||||
cp += 6;
|
||||
}
|
||||
else {
|
||||
uint8_t val = hexnibble(*mp++) << 4;
|
||||
val |= hexnibble(*mp++);
|
||||
|
@ -1550,21 +1700,23 @@ void SML_Decode(uint8_t index) {
|
|||
// get string value
|
||||
getstr:
|
||||
mp++;
|
||||
if (meter_desc_p[mindex].type == 'o') {
|
||||
uint32_t p;
|
||||
for (p = 0; p < METER_ID_SIZE - 2; p++) {
|
||||
if (*cp == *mp) {
|
||||
break;
|
||||
if (meter_desc_p[mindex].type != 'v') {
|
||||
if (meter_desc_p[mindex].type == 'o') {
|
||||
uint32_t p;
|
||||
for (p = 0; p < METER_ID_SIZE - 2; p++) {
|
||||
if (*cp == *mp) {
|
||||
break;
|
||||
}
|
||||
meter_id[mindex][p] = *cp++;
|
||||
}
|
||||
meter_id[mindex][p] = *cp++;
|
||||
meter_id[mindex][p] = 0;
|
||||
} else {
|
||||
sml_getvalue(cp,mindex);
|
||||
}
|
||||
meter_id[mindex][p] = 0;
|
||||
} else {
|
||||
sml_getvalue(cp,mindex);
|
||||
}
|
||||
} else {
|
||||
double dval;
|
||||
if (meter_desc_p[mindex].type!='e' && meter_desc_p[mindex].type!='r' && meter_desc_p[mindex].type!='m' && meter_desc_p[mindex].type!='M' && meter_desc_p[mindex].type!='p') {
|
||||
if (meter_desc_p[mindex].type!='e' && meter_desc_p[mindex].type!='r' && meter_desc_p[mindex].type!='m' && meter_desc_p[mindex].type!='M' && meter_desc_p[mindex].type!='p' && meter_desc_p[mindex].type!='v') {
|
||||
// get numeric values
|
||||
if (meter_desc_p[mindex].type=='o' || meter_desc_p[mindex].type=='c') {
|
||||
if (*mp == '(') {
|
||||
|
@ -1596,7 +1748,7 @@ void SML_Decode(uint8_t index) {
|
|||
dval = sml_getvalue(cp,mindex);
|
||||
}
|
||||
} else {
|
||||
// ebus pzem or mbus or raw
|
||||
// ebus pzem vbus or mbus or raw
|
||||
if (*mp=='b') {
|
||||
mp++;
|
||||
uint8_t shift = *mp&7;
|
||||
|
@ -1639,15 +1791,16 @@ void SML_Decode(uint8_t index) {
|
|||
#else
|
||||
meter_vars[vindex]=dval;
|
||||
#endif
|
||||
|
||||
|
||||
//AddLog_P(LOG_LEVEL_INFO, PSTR(">> %s"),mp);
|
||||
// get scaling factor
|
||||
double fac=CharToDouble((char*)mp);
|
||||
meter_vars[vindex]/=fac;
|
||||
SML_Immediate_MQTT((const char*)mp,vindex,mindex);
|
||||
}
|
||||
dvalid[vindex] = 1;
|
||||
}
|
||||
dvalid[vindex] = 1;
|
||||
//AddLog(LOG_LEVEL_INFO, PSTR("set valid in line %d"), vindex);
|
||||
}
|
||||
nextsect:
|
||||
// next section
|
||||
|
@ -1809,9 +1962,11 @@ void SML_Show(boolean json) {
|
|||
dtostrfd(meter_vars[index],dp,tpowstr);
|
||||
}
|
||||
|
||||
if (!dvalid[index]) nojson = 1;
|
||||
|
||||
if (json) {
|
||||
if (!dvalid[index]) {
|
||||
nojson = 1;
|
||||
//AddLog(LOG_LEVEL_INFO, PSTR("not yet valid line %d"), index);
|
||||
}
|
||||
// json export
|
||||
if (index==0) {
|
||||
//snprintf_P(b_mqtt_data, sizeof(b_mqtt_data), "%s,\"%s\":{\"%s\":%s", b_mqtt_data,meter_desc_p[mindex].prefix,jname,tpowstr);
|
||||
|
@ -2248,7 +2403,7 @@ init10:
|
|||
} else {
|
||||
// serial input, init
|
||||
#ifdef SPECIAL_SS
|
||||
if (meter_desc_p[meters].type=='m' || meter_desc_p[meters].type=='M' || meter_desc_p[meters].type=='p' || meter_desc_p[meters].type=='R') {
|
||||
if (meter_desc_p[meters].type=='m' || meter_desc_p[meters].type=='M' || meter_desc_p[meters].type=='p' || meter_desc_p[meters].type=='R' || meter_desc_p[meters].type=='v') {
|
||||
meter_ss[meters] = new TasmotaSerial(meter_desc_p[meters].srcpin,meter_desc_p[meters].trxpin,1,0,TMSBSIZ);
|
||||
} else {
|
||||
meter_ss[meters] = new TasmotaSerial(meter_desc_p[meters].srcpin,meter_desc_p[meters].trxpin,1,1,TMSBSIZ);
|
||||
|
|
Loading…
Reference in New Issue