Address Theo's requests & some cleanups + errors

Removed all code changes out i18n.h  & support_command.ino
This commit is contained in:
BBBits 2020-12-06 10:45:01 +13:00
parent c62c6a821a
commit c5c28dec25
3 changed files with 51 additions and 55 deletions

View File

@ -497,9 +497,6 @@
#define D_JSON_RFRECEIVED "RfReceived" #define D_JSON_RFRECEIVED "RfReceived"
#define D_CMND_RFRAW "RfRaw" #define D_CMND_RFRAW "RfRaw"
#define D_CMND_RFRXPROTOCOL "RfRxProtocol"
#define D_JSON_ENABLED_MASK "Enabled-Mask"
// Commands xdrv_08_serial_bridge.ino // Commands xdrv_08_serial_bridge.ino
#define D_CMND_SSERIALSEND "SSerialSend" #define D_CMND_SSERIALSEND "SSerialSend"
#define D_CMND_SBAUDRATE "SBaudrate" #define D_CMND_SBAUDRATE "SBaudrate"

View File

@ -18,9 +18,6 @@
*/ */
const char kTasmotaCommands[] PROGMEM = "|" // No prefix const char kTasmotaCommands[] PROGMEM = "|" // No prefix
#ifdef USE_RC_SWITCH
D_CMND_RFRXPROTOCOL "|"
#endif
D_CMND_BACKLOG "|" D_CMND_DELAY "|" D_CMND_POWER "|" D_CMND_STATUS "|" D_CMND_STATE "|" D_CMND_SLEEP "|" D_CMND_UPGRADE "|" D_CMND_UPLOAD "|" D_CMND_OTAURL "|" D_CMND_BACKLOG "|" D_CMND_DELAY "|" D_CMND_POWER "|" D_CMND_STATUS "|" D_CMND_STATE "|" D_CMND_SLEEP "|" D_CMND_UPGRADE "|" D_CMND_UPLOAD "|" D_CMND_OTAURL "|"
D_CMND_SERIALLOG "|" D_CMND_RESTART "|" D_CMND_POWERONSTATE "|" D_CMND_PULSETIME "|" D_CMND_BLINKTIME "|" D_CMND_BLINKCOUNT "|" D_CMND_SAVEDATA "|" D_CMND_SERIALLOG "|" D_CMND_RESTART "|" D_CMND_POWERONSTATE "|" D_CMND_PULSETIME "|" D_CMND_BLINKTIME "|" D_CMND_BLINKCOUNT "|" D_CMND_SAVEDATA "|"
D_CMND_SO "|" D_CMND_SETOPTION "|" D_CMND_TEMPERATURE_RESOLUTION "|" D_CMND_HUMIDITY_RESOLUTION "|" D_CMND_PRESSURE_RESOLUTION "|" D_CMND_POWER_RESOLUTION "|" D_CMND_SO "|" D_CMND_SETOPTION "|" D_CMND_TEMPERATURE_RESOLUTION "|" D_CMND_HUMIDITY_RESOLUTION "|" D_CMND_PRESSURE_RESOLUTION "|" D_CMND_POWER_RESOLUTION "|"
@ -47,9 +44,6 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
#endif // ESP32 #endif // ESP32
; ;
void (* const TasmotaCommand[])(void) PROGMEM = { void (* const TasmotaCommand[])(void) PROGMEM = {
#ifdef USE_RC_SWITCH
&CmndRfRxProtocol,
#endif
&CmndBacklog, &CmndDelay, &CmndPower, &CmndStatus, &CmndState, &CmndSleep, &CmndUpgrade, &CmndUpgrade, &CmndOtaUrl, &CmndBacklog, &CmndDelay, &CmndPower, &CmndStatus, &CmndState, &CmndSleep, &CmndUpgrade, &CmndUpgrade, &CmndOtaUrl,
&CmndSeriallog, &CmndRestart, &CmndPowerOnState, &CmndPulsetime, &CmndBlinktime, &CmndBlinkcount, &CmndSavedata, &CmndSeriallog, &CmndRestart, &CmndPowerOnState, &CmndPulsetime, &CmndBlinktime, &CmndBlinkcount, &CmndSavedata,
&CmndSetoption, &CmndSetoption, &CmndTemperatureResolution, &CmndHumidityResolution, &CmndPressureResolution, &CmndPowerResolution, &CmndSetoption, &CmndSetoption, &CmndTemperatureResolution, &CmndHumidityResolution, &CmndPressureResolution, &CmndPowerResolution,

View File

@ -16,11 +16,6 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <Arduino.h>
#include "my_user_config.h"
// doesn't pickup defines while editing without this
// dunno if this is unique to my enviroment or everyone experiences it ..
#ifdef USE_RC_SWITCH #ifdef USE_RC_SWITCH
/*********************************************************************************************\ /*********************************************************************************************\
* RF send and receive using RCSwitch library https://github.com/sui77/rc-switch/ * RF send and receive using RCSwitch library https://github.com/sui77/rc-switch/
@ -35,12 +30,15 @@
#define D_CMND_RFSEND "RFSend" #define D_CMND_RFSEND "RFSend"
#define D_JSON_RF_PULSE "Pulse" #define D_JSON_RF_PULSE "Pulse"
#define D_JSON_RF_REPEAT "Repeat" #define D_JSON_RF_REPEAT "Repeat"
#define D_CMND_RFRXPROTOCOL "RfRxProtocol"
#define D_JSON_NONE_ENABLED "None Enabled"
const char kRfSendCommands[] PROGMEM = "|" D_CMND_RFSEND; // No prefix
void (* const RfSendCommand[])(void) PROGMEM = { const char kRfCommands[] PROGMEM = "|" D_CMND_RFSEND "|" D_CMND_RFRXPROTOCOL; // No prefix
&CmndRfSend };
void (* const RfCommands[])(void) PROGMEM = {
&CmndRfSend,&CmndRfRxProtocol };
#include <RCSwitch.h> #include <RCSwitch.h>
@ -90,58 +88,66 @@ void RfInit(void)
if (PinUsed(GPIO_RFRECV)) { if (PinUsed(GPIO_RFRECV)) {
pinMode( Pin(GPIO_RFRECV), INPUT); pinMode( Pin(GPIO_RFRECV), INPUT);
mySwitch.enableReceive(Pin(GPIO_RFRECV)); mySwitch.enableReceive(Pin(GPIO_RFRECV));
mySwitch.enabled_protocol_mask.longs.high32 = Settings.ex_adc_param1; GetMaskFromSettings();
mySwitch.enabled_protocol_mask.longs.low32 = Settings.ex_adc_param2;
} }
} }
void GetMaskFromSettings(){
mySwitch.enabled_protocol_mask.longs.high32 = Settings.ex_adc_param1 ;
mySwitch.enabled_protocol_mask.longs.low32 = Settings.ex_adc_param2 ;
}
void SaveMaskToSettings(){
Settings.ex_adc_param1 = mySwitch.enabled_protocol_mask.longs.high32;
Settings.ex_adc_param2 = mySwitch.enabled_protocol_mask.longs.low32;
SettingsSave(1);
}
/*********************************************************************************************\ /*********************************************************************************************\
* Commands * Commands
\*********************************************************************************************/ \*********************************************************************************************/
void CmndRfRxProtocol(void){ void CmndRfRxProtocol(void){
uint64_t thisbit; if(!PinUsed(GPIO_RFRECV))return;
// AddLog_P(LOG_LEVEL_INFO, PSTR("RFR: index:%d usridx:%d data_len:%d data:%s"),XdrvMailbox.index, XdrvMailbox.usridx, XdrvMailbox.data_len,XdrvMailbox.data); // AddLog_P(LOG_LEVEL_INFO, PSTR("RFR:CmndRfRxProtocol:: index:%d usridx:%d data_len:%d data:\"%s\""),XdrvMailbox.index, XdrvMailbox.usridx, XdrvMailbox.data_len,XdrvMailbox.data);
// AddLog_P(LOG_LEVEL_INFO, PSTR("RFR: test data_len >0"));
//if (XdrvMailbox.data_len > 0) { uint64_t thisdat;
// AddLog_P(LOG_LEVEL_INFO, PSTR("RFR: test usridx ==1")); if (XdrvMailbox.usridx==1) {
if (XdrvMailbox.usridx==1) { if(XdrvMailbox.payload >=0){
// AddLog_P(LOG_LEVEL_INFO, PSTR("RFR: test payload >=0")); thisdat = (1ULL << (XdrvMailbox.index-1) );
if(XdrvMailbox.payload >=0){ if(XdrvMailbox.payload &1){
thisbit = (1ULL << (XdrvMailbox.index-1) ); mySwitch.enabled_protocol_mask.value |= thisdat;
if(XdrvMailbox.payload &1){
mySwitch.enabled_protocol_mask.value |= thisbit;
}else{
mySwitch.enabled_protocol_mask.value &= ~thisbit;
}
}
}else{
// AddLog_P(LOG_LEVEL_INFO, PSTR("RFR: test for a"));
if(XdrvMailbox.data[0]=='a'){
// AddLog_P(LOG_LEVEL_INFO, PSTR("RFR: set mask all"));
mySwitch.enabled_protocol_mask.value= (1ULL << mySwitch.getNumProtos())-1 ;
}else{ }else{
// AddLog_P(LOG_LEVEL_INFO, PSTR("RFR: set mask with value")); mySwitch.enabled_protocol_mask.value &= ~thisdat;
mySwitch.enabled_protocol_mask.value = strtoull(XdrvMailbox.data,nullptr, 0); }
SaveMaskToSettings();
}else if(XdrvMailbox.data_len > 0) return; // not a number
}else{
if(XdrvMailbox.data_len >0){
if(XdrvMailbox.data[0]=='a'){
mySwitch.enabled_protocol_mask.value= (1ULL << mySwitch.getNumProtos())-1 ;
SaveMaskToSettings();
}else{
thisdat = strtoull(XdrvMailbox.data,nullptr, 0);
if(thisdat>0 || XdrvMailbox.data[0]=='0' ){
mySwitch.enabled_protocol_mask.value = thisdat;
SaveMaskToSettings();
}else return; // not a number
} }
} }
Settings.ex_adc_param1 = mySwitch.enabled_protocol_mask.longs.high32; }
Settings.ex_adc_param2 = mySwitch.enabled_protocol_mask.longs.low32; // AddLog_P(LOG_LEVEL_INFO, PSTR("RFR:CmndRfRxProtocol:: Start responce"));
//}
ResponseClear(); ResponseClear();
ResponseAppend_P(PSTR("{\"" D_CMND_RFRXPROTOCOL "\":")); ResponseAppend_P(PSTR("{\"" D_CMND_RFRXPROTOCOL "\":"));
ResponseAppend_P(PSTR("\"")); ResponseAppend_P(PSTR("\""));
bool gotone = false; bool gotone = false;
thisbit=1; thisdat=1;
for (int i=0;i<mySwitch.getNumProtos();i++){ for (int i=0;i<mySwitch.getNumProtos();i++){
// ResponseAppend_P(PSTR("%s%s%d"), (i) ? "," : "",(mySwitch.enabled_protocol_mask.value & thisbit) ? "" : "!", i+1); if(mySwitch.enabled_protocol_mask.value & thisdat){
if(mySwitch.enabled_protocol_mask.value & thisbit){
ResponseAppend_P(PSTR("%s%d"), (gotone) ? "," : "", i+1); ResponseAppend_P(PSTR("%s%d"), (gotone) ? "," : "", i+1);
gotone = true; gotone = true;
} }
thisbit <<=1; thisdat <<=1;
} }
if(!gotone)ResponseAppend_P(PSTR("None Enabled")); if(!gotone)ResponseAppend_P(PSTR( D_JSON_NONE_ENABLED ));
ResponseAppend_P(PSTR("\"")); ResponseAppend_P(PSTR("\""));
ResponseJsonEnd(); ResponseJsonEnd();
@ -149,6 +155,7 @@ void CmndRfRxProtocol(void){
void CmndRfSend(void) void CmndRfSend(void)
{ {
if(!PinUsed(GPIO_RFSEND))return;
bool error = false; bool error = false;
if (XdrvMailbox.data_len) { if (XdrvMailbox.data_len) {
@ -229,10 +236,8 @@ bool Xdrv17(uint8_t function)
} }
break; break;
case FUNC_COMMAND: case FUNC_COMMAND:
if (PinUsed(GPIO_RFSEND)) { result = DecodeCommand(kRfCommands, RfCommands);
result = DecodeCommand(kRfSendCommands, RfSendCommand); break;
}
break;
case FUNC_INIT: case FUNC_INIT:
RfInit(); RfInit();
break; break;