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
+7 -1
View File
@@ -131,8 +131,11 @@ struct BindInformation {
uint8_t rxUid;
uint8_t lbtMode;
uint8_t flexMode;
PXX2HardwareInformation receiverInformation;
};
typedef void (* ModuleCallback)();
PACK(struct ModuleState {
uint8_t protocol:4;
uint8_t mode:4;
@@ -144,9 +147,12 @@ PACK(struct ModuleState {
ModuleSettings * moduleSettings;
BindInformation * bindInformation;
};
void startBind(BindInformation * destination)
ModuleCallback callback;
void startBind(BindInformation * destination, ModuleCallback bindCallback = nullptr)
{
bindInformation = destination;
callback = bindCallback;
mode = MODULE_MODE_BIND;
#if defined(SIMU)
bindInformation->candidateReceiversCount = 2;
+8 -2
View File
@@ -228,14 +228,20 @@ void Pxx2Pulses::setupBindFrame(uint8_t module)
if (get_tmr10ms() > destination->timeout) {
moduleState[module].mode = MODULE_MODE_NORMAL;
destination->step = BIND_OK;
POPUP_INFORMATION(STR_BIND_OK);
POPUP_INFORMATION(STR_BIND_OK); // TODO rather use the new callback
}
return;
}
addFrameType(PXX2_TYPE_C_MODULE, PXX2_TYPE_ID_BIND);
if (destination->step == BIND_OPTIONS_SELECTED) {
if (destination->step == BIND_INFO_REQUEST) {
Pxx2Transport::addByte(0x02);
for (uint8_t i=0; i<PXX2_LEN_RX_NAME; i++) {
Pxx2Transport::addByte(destination->candidateReceiversNames[destination->selectedReceiverIndex][i]);
}
}
else if (destination->step == BIND_START) {
Pxx2Transport::addByte(0x01);
for (uint8_t i=0; i<PXX2_LEN_RX_NAME; i++) {
Pxx2Transport::addByte(destination->candidateReceiversNames[destination->selectedReceiverIndex][i]);
+4 -10
View File
@@ -115,25 +115,21 @@ enum PXX2Variant {
};
enum PXX2RegisterSteps {
REGISTER_START,
REGISTER_INIT,
REGISTER_RX_NAME_RECEIVED,
REGISTER_RX_NAME_SELECTED,
REGISTER_OK
};
enum PXX2BindSteps {
BIND_START,
BIND_INIT,
BIND_RX_NAME_SELECTED,
BIND_OPTIONS_SELECTED,
BIND_INFO_REQUEST,
BIND_START,
BIND_WAIT,
BIND_OK
};
enum PXX2ResetSteps {
RESET_START,
RESET_OK
};
enum PXX2ReceiverStatus {
PXX2_HARDWARE_INFO,
PXX2_SETTINGS_READ,
@@ -220,8 +216,6 @@ class Pxx2Pulses: public PxxPulses<Pxx2Transport> {
void addFrameType(uint8_t type_c, uint8_t type_id)
{
// TYPE_C + TYPE_ID
// TODO optimization ? Pxx2Transport::addByte(0x26); // This one is CRC-ed on purpose
Pxx2Transport::addByte(type_c);
Pxx2Transport::addByte(type_id);
}