Add hex/decimal receive control for RF and IR

6.0.0a
* Add command SetOption28 to switch between hex or decimal Sonoff Bridge
RF received data format (#3008)
* Add command SetOption29 to switch between hex or decimal IR received
data format
This commit is contained in:
Theo Arends 2018-06-25 12:33:23 +02:00
parent 63ee0a5870
commit 176c39dfe3
5 changed files with 27 additions and 7 deletions

View File

@ -1,4 +1,7 @@
/* 6.0.0a
* Add command SetOption28 to switch between hex or decimal Sonoff Bridge RF received data format (#3008)
* Add command SetOption29 to switch between hex or decimal IR received data format
* Add performance improvement when updating multiple individual WS2812 pixels (#3007)
* Add debug facilities using optional xdrv_99_debug.ino to enable in user_config.h
* Add KNX support for DS18S20 Temperature sensor
* Add CRC to Settings making future upgrades more fail-safe

View File

@ -53,8 +53,8 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t knx_enabled : 1; // bit 25 (v5.12.0l) KNX
uint32_t device_index_enable : 1; // bit 26 (v5.13.1a)
uint32_t knx_enable_enhancement : 1; // bit 27 (v5.14.0a) KNX
uint32_t spare28 : 1;
uint32_t spare29 : 1;
uint32_t rf_receive_decimal : 1; // bit 28 (v6.0.0a)
uint32_t ir_receive_decimal : 1; // bit 29 (v6.0.0a)
uint32_t spare30 : 1;
uint32_t spare31 : 1;
};

View File

@ -569,7 +569,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
XsnsCall(FUNC_COMMAND);
// if (!XsnsCall(FUNC_COMMAND)) type = NULL;
}
else if ((CMND_SETOPTION == command_code) && ((index <= 26) || ((index > 31) && (index <= P_MAX_PARAM8 + 31)))) {
else if ((CMND_SETOPTION == command_code) && ((index <= 29) || ((index > 31) && (index <= P_MAX_PARAM8 + 31)))) {
if (index <= 31) {
ptype = 0; // SetOption0 .. 31
} else {
@ -604,6 +604,9 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
// case 24: // rules_once
// case 25: // knx_enabled
case 26: // device_index_enable
// case 27: // knx_enable_enhancement
case 28: // rf_receive_decimal
case 29: // ir_receive_decimal
bitWrite(Settings.flag.data, index, payload);
}
if (12 == index) { // stop_flash_rotate

View File

@ -89,6 +89,7 @@ void IrReceiveInit(void)
void IrReceiveCheck()
{
char sirtype[14]; // Max is AIWA_RC_T501
char stemp[16];
int8_t iridx = 0;
decode_results results;
@ -107,8 +108,15 @@ void IrReceiveCheck()
if ((iridx < 0) || (iridx > 14)) {
iridx = 0;
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_IRRECEIVED "\":{\"" D_JSON_IR_PROTOCOL "\":\"%s\",\"" D_JSON_IR_BITS "\":%d,\"" D_JSON_IR_DATA "\":\"%lX\"}}"),
GetTextIndexed(sirtype, sizeof(sirtype), iridx, kIrRemoteProtocols), results.bits, (uint32_t)results.value);
if (Settings.flag.ir_receive_decimal) {
snprintf_P(stemp, sizeof(stemp), PSTR("%u"), (uint32_t)results.value);
} else {
snprintf_P(stemp, sizeof(stemp), PSTR("\"%lX\""), (uint32_t)results.value);
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_IRRECEIVED "\":{\"" D_JSON_IR_PROTOCOL "\":\"%s\",\"" D_JSON_IR_BITS "\":%d,\"" D_JSON_IR_DATA "\":%s}}"),
GetTextIndexed(sirtype, sizeof(sirtype), iridx, kIrRemoteProtocols), results.bits, stemp);
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_IRRECEIVED));
XdrvRulesProcess();
#ifdef USE_DOMOTICZ

View File

@ -252,6 +252,7 @@ void SonoffBridgeReceived()
uint16_t high_time = 0;
uint32_t received_id = 0;
char rfkey[8];
char stemp[16];
AddLogSerial(LOG_LEVEL_DEBUG);
@ -295,8 +296,13 @@ void SonoffBridgeReceived()
}
}
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_RFRECEIVED "\":{\"" D_JSON_SYNC "\":%d,\"" D_JSON_LOW "\":%d,\"" D_JSON_HIGH "\":%d,\"" D_JSON_DATA "\":\"%06X\",\"" D_CMND_RFKEY "\":%s}}"),
sync_time, low_time, high_time, received_id, rfkey);
if (Settings.flag.rf_receive_decimal) {
snprintf_P(stemp, sizeof(stemp), PSTR("%u"), received_id);
} else {
snprintf_P(stemp, sizeof(stemp), PSTR("\"%06X\""), received_id);
}
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_RFRECEIVED "\":{\"" D_JSON_SYNC "\":%d,\"" D_JSON_LOW "\":%d,\"" D_JSON_HIGH "\":%d,\"" D_JSON_DATA "\":%s,\"" D_CMND_RFKEY "\":%s}}"),
sync_time, low_time, high_time, stemp, rfkey);
MqttPublishPrefixTopic_P(RESULT_OR_TELE, PSTR(D_JSON_RFRECEIVED));
XdrvRulesProcess();
#ifdef USE_DOMOTICZ