OTA update continued

This commit is contained in:
Bertrand Songis
2019-04-24 17:23:28 +02:00
parent 1cd8c93455
commit bae1131a1b
6 changed files with 85 additions and 21 deletions
+17 -3
View File
@@ -109,7 +109,7 @@ void processRegisterFrame(uint8_t module, uint8_t * frame)
switch(frame[3]) {
case 0x00:
if (reusableBuffer.moduleSetup.pxx2.registerStep == REGISTER_START) {
if (reusableBuffer.moduleSetup.pxx2.registerStep == REGISTER_INIT) {
// RX_NAME follows, we store it for the next step
str2zchar(reusableBuffer.moduleSetup.pxx2.registerRxName, (const char *)&frame[4], PXX2_LEN_RX_NAME);
reusableBuffer.moduleSetup.pxx2.registerLoopIndex = frame[12];
@@ -141,7 +141,7 @@ void processBindFrame(uint8_t module, uint8_t * frame)
switch(frame[3]) {
case 0x00:
if (destination->step == BIND_START) {
if (destination->step == BIND_INIT) {
bool found = false;
for (uint8_t i=0; i<destination->candidateReceiversCount; i++) {
if (memcmp(destination->candidateReceiversNames[i], &frame[4], PXX2_LEN_RX_NAME) == 0) {
@@ -151,12 +151,15 @@ void processBindFrame(uint8_t module, uint8_t * frame)
}
if (!found && destination->candidateReceiversCount < PXX2_MAX_RECEIVERS_PER_MODULE) {
memcpy(destination->candidateReceiversNames[destination->candidateReceiversCount++], &frame[4], PXX2_LEN_RX_NAME);
if (moduleState[module].callback) {
moduleState[module].callback();
}
}
}
break;
case 0x01:
if (destination->step == BIND_OPTIONS_SELECTED) {
if (destination->step == BIND_START) {
if (memcmp(&destination->candidateReceiversNames[destination->selectedReceiverIndex], &frame[4], PXX2_LEN_RX_NAME) == 0) {
memcpy(g_model.moduleData[module].pxx2.receiverName[destination->rxUid], &frame[4], PXX2_LEN_RX_NAME);
storageDirty(EE_MODEL);
@@ -165,6 +168,17 @@ void processBindFrame(uint8_t module, uint8_t * frame)
}
}
break;
case 0x02:
if (destination->step == BIND_INFO_REQUEST) {
if (memcmp(&destination->candidateReceiversNames[destination->selectedReceiverIndex], &frame[4], PXX2_LEN_RX_NAME) == 0) {
memcpy(&destination->receiverInformation, &frame[12], sizeof(PXX2HardwareInformation));
if (moduleState[module].callback) {
moduleState[module].callback();
}
}
}
break;
}
}