Skip to content

Commit

Permalink
Version 2.0.10
Browse files Browse the repository at this point in the history
- Simplified the ISR for CC1101 packet handling to one boolean set to improve stability
- Moved all CC1101 related code to its own task
- Added a CC1101 task timeout logging to monitor possible CC1101 issues
  • Loading branch information
arjenhiemstra committed Feb 1, 2021
1 parent eb66059 commit 70d9191
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 236 deletions.
4 changes: 2 additions & 2 deletions compiled_firmware_files/firmware.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"link":"https://github.com/arjenhiemstra/ithowifi/raw/master/compiled_firmware_files/hardware_rev_1/NRG_itho_wifi_HW1x_FW2.0.9.bin"
},
"2": {
"latest_fw":"2.0.9",
"link":"https://github.com/arjenhiemstra/ithowifi/raw/master/compiled_firmware_files/hardware_rev_2/NRG_itho_wifi_HW2x_FW2.0.9.bin"
"latest_fw":"2.0.10",
"link":"https://github.com/arjenhiemstra/ithowifi/raw/master/compiled_firmware_files/hardware_rev_2/NRG_itho_wifi_HW2x_FW2.0.10.bin"
}
}
}
Binary file not shown.
2 changes: 1 addition & 1 deletion software/NRG_itho_wifi/06_Websock_func.ino
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void jsonWifiscanresult(int id, const char* ssid, int sigval, int sec) {

}
// Convert & Transfer Arduino elements to JSON elements
void jsonMessageBox(char* message1, char* message2) {
void jsonMessageBox(const char* message1, const char* message2) {
StaticJsonDocument<512> root;
//JsonObject root = jsonBuffer.createObject();
JsonObject messagebox = root.createNestedObject("messagebox");
Expand Down
37 changes: 0 additions & 37 deletions software/NRG_itho_wifi/09_init_code.ino
Original file line number Diff line number Diff line change
Expand Up @@ -385,40 +385,3 @@ void logWifiInfo() {


}
#if defined (__HW_VERSION_TWO__)
void initRFmodule() {
Ticker reboot;

//switch off rf_support
strlcpy(systemConfig.itho_rf_support, "off", sizeof(systemConfig.itho_rf_support));
systemConfig.rfInitOK = false;

//attacht saveConfig and reboot script to fire after 2 sec
reboot.attach(2, []() {
logInput("Setup: init of CC1101 RF module failed");
saveSystemConfig();
esp_task_wdt_init(1, true);
esp_task_wdt_add(NULL);
while (true);
});

//init the RF module
rf.init();
pinMode(ITHO_IRQ_PIN, INPUT);
attachInterrupt(ITHO_IRQ_PIN, ITHOinterrupt, FALLING);
rf.initReceive();

//this portion of code will not be reached when no RF module is present: detach reboot script, switch on rf_supprt and load remotes config
reboot.detach();
logInput("Setup: init of CC1101 RF module successful");
strlcpy(systemConfig.itho_rf_support, "on", sizeof(systemConfig.itho_rf_support));
loadRemotesConfig();
systemConfig.rfInitOK = true;

}

void disableRFsupport() {
detachInterrupt(ITHO_IRQ_PIN);
}

#endif
189 changes: 1 addition & 188 deletions software/NRG_itho_wifi/10_Gen_func.ino
Original file line number Diff line number Diff line change
Expand Up @@ -257,198 +257,11 @@ void printNewline(Print* _logOutput) {
}


void logInput(char * inputString) {
void logInput(const char * inputString) {
filePrint.open();

Log.notice(inputString);

filePrint.close();

}

#if defined (__HW_VERSION_TWO__)
ICACHE_RAM_ATTR void ITHOinterrupt() {

ITHOcheck();

}

ICACHE_RAM_ATTR void ITHOcheck() {

if (rf.checkForNewPacket()) {

int *lastID = rf.getLastID();
int id[8];
for (uint8_t i = 0; i < 8; i++) {
id[i] = lastID[i];
}
IthoCommand cmd = rf.getLastCommand();
if (++RFTcommandpos > 2) RFTcommandpos = 0; // store information in next entry of ringbuffers
RFTcommand[RFTcommandpos] = cmd;
RFTRSSI[RFTcommandpos] = rf.ReadRSSI();
//int *lastID = rf.getLastID();
bool chk = remotes.checkID(id);
//bool chk = rf.checkID(RFTid);
RFTidChk[RFTcommandpos] = chk;

if (debugLevel >= 2) {
if (chk || debugLevel == 3) {
RFDebug(true, id, cmd);
}
}
if (cmd != IthoUnknown) { // only act on good cmd
if (debugLevel == 1) {
RFDebug(false, id, cmd);
}
if (cmd == IthoLeave && remotes.remoteLearnLeaveStatus()) {
//Serial.print("Leave command received. Trying to remove remote... ");
int result = remotes.removeRemote(id);
switch (result) {
case -1: // failed! - remote not registered
break;
case -2: // failed! - no remotes registered
break;
case 1: // success!
saveRemotes = true;
break;
}
}
if (cmd == IthoJoin && remotes.remoteLearnLeaveStatus()) {
int result = remotes.registerNewRemote(id);
switch (result) {
case -1: // failed! - remote already registered
break;
case -2: //failed! - max number of remotes reached"
break;
case 1:
saveRemotes = true;
break;
}
}
if (chk) {
if (cmd == IthoLow) {
nextIthoVal = systemConfig.itho_low;
nextIthoTimer = 0;
updateItho = true;
}
if (cmd == IthoMedium) {
nextIthoVal = systemConfig.itho_medium;
nextIthoTimer = 0;
updateItho = true;
}
if (cmd == IthoHigh || cmd == IthoFull) {
nextIthoVal = systemConfig.itho_high;
nextIthoTimer = 0;
updateItho = true;
}
if (cmd == IthoTimer1) {
nextIthoVal = systemConfig.itho_high;
nextIthoTimer = systemConfig.itho_timer1;
updateItho = true;
}
if (cmd == IthoTimer2) {
nextIthoVal = systemConfig.itho_high;
nextIthoTimer = systemConfig.itho_timer2;
updateItho = true;
}
if (cmd == IthoTimer3) {
nextIthoVal = systemConfig.itho_high;
nextIthoTimer = systemConfig.itho_timer3;
updateItho = true;
}
if (cmd == IthoJoin && !remotes.remoteLearnLeaveStatus()) {
}
if (cmd == IthoLeave && !remotes.remoteLearnLeaveStatus()) {
ithoQueue.clear_queue();
}

}
else {
//Unknown remote
}
//Serial.print("Number of know remotes: ");
//Serial.println(remotes.getRemoteCount());
}
else {
//("--- RF CMD reveiced but of unknown type ---");
}
}
}


uint8_t findRFTlastCommand() {
if (RFTcommand[RFTcommandpos] != IthoUnknown) return RFTcommandpos;
if ((RFTcommandpos == 0) && (RFTcommand[2] != IthoUnknown)) return 2;
if ((RFTcommandpos == 0) && (RFTcommand[1] != IthoUnknown)) return 1;
if ((RFTcommandpos == 1) && (RFTcommand[0] != IthoUnknown)) return 0;
if ((RFTcommandpos == 1) && (RFTcommand[2] != IthoUnknown)) return 2;
if ((RFTcommandpos == 2) && (RFTcommand[1] != IthoUnknown)) return 1;
if ((RFTcommandpos == 2) && (RFTcommand[0] != IthoUnknown)) return 0;
return -1;
}

void RFDebug(bool chk, int * id, IthoCommand cmd) {

strcpy(debugLog, "");
sprintf(debugLog, "RemoteID=%d,%d,%d,%d,%d,%d,%d,%d / Command=", id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7]);
if (chk) {
strcpy(debugLogMsg2, "");
strlcpy(debugLogMsg2, rf.getLastMessage2CMDstr().c_str(), sizeof(debugLogMsg2));
}
//log command
switch (cmd) {
case IthoUnknown:
strcat(debugLog, "unknown");
break;
case IthoLow:
strcat(debugLog, "low");
break;
case IthoMedium:
strcat(debugLog, "medium");
break;
case IthoHigh:
strcat(debugLog, "high");
break;
case IthoFull:
strcat(debugLog, "full");
break;
case IthoTimer1:
strcat(debugLog, "timer1");
break;
case IthoTimer2:
strcat(debugLog, "timer2");
break;
case IthoTimer3:
strcat(debugLog, "timer3");
break;
case IthoJoin:
strcat(debugLog, "join");
break;
case IthoLeave:
strcat(debugLog, "leave");
break;
}
debugLogInput = true;

}

void toggleRemoteLLmode() {
if (remotes.toggleLearnLeaveMode()) {
timerLearnLeaveMode.attach(1, setllModeTimer);
}
else {
timerLearnLeaveMode.detach();
remotes.setllModeTime(0);
sysStatReq = true;
}
}

void setllModeTimer() {
remotes.updatellModeTimer();
sysStatReq = true;
if (remotes.getllModeTime() == 0) {
timerLearnLeaveMode.detach();
}

}
#endif
Loading

0 comments on commit 70d9191

Please sign in to comment.