From 80c34c7597e6ce256bd2c2d949bc3e5143b6f9e2 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 6 Feb 2019 11:40:21 +0100 Subject: [PATCH] BIND shared array filled with incoming models --- radio/src/dataconstants.h | 5 +++-- radio/src/datastructs.h | 6 +++--- radio/src/opentx.cpp | 2 +- radio/src/pulses/pxx2.cpp | 5 ++--- radio/src/telemetry/telemetry.cpp | 24 +++++++++++++++++++++++- 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/radio/src/dataconstants.h b/radio/src/dataconstants.h index 9b146fd8b..cc8b07933 100644 --- a/radio/src/dataconstants.h +++ b/radio/src/dataconstants.h @@ -787,7 +787,8 @@ enum BluetoothModes { }; // PXX2 constants -#define LEN_REGISTRATION_ID 4 -#define LEN_RX_ID 4 +#define PXX2_LEN_REGISTRATION_ID 4 +#define PXX2_LEN_RX_ID 4 +#define PXX2_MAX_RECEIVERS_PER_MODULE 5 #endif // _DATACONSTANTS_H_ diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index a81d3cf2c..003a9c552 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -419,7 +419,7 @@ PACK(struct ReceiverData { uint8_t telemetry:1; uint8_t spare:6; uint64_t channelMapping; // each receiver output (16) can be assigned to one of the 16 channels - uint8_t rxID[LEN_RX_ID]; + uint8_t rxID[PXX2_LEN_RX_ID]; }); /* @@ -632,7 +632,7 @@ PACK(struct ModelData { CUSTOM_SCREENS_DATA - uint8_t modelRegistrationID[LEN_REGISTRATION_ID]; + uint8_t modelRegistrationID[PXX2_LEN_REGISTRATION_ID]; }); /* @@ -798,7 +798,7 @@ PACK(struct RadioData { THEME_DATA - uint8_t ownerRegistrationID[LEN_REGISTRATION_ID]; + uint8_t ownerRegistrationID[PXX2_LEN_REGISTRATION_ID]; }); #undef SWITCHES_WARNING_DATA diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index faf88d879..9a116ab75 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -449,7 +449,7 @@ void modelDefault(uint8_t id) applyDefaultTemplate(); - memcpy(g_model.modelRegistrationID, g_eeGeneral.ownerRegistrationID, LEN_REGISTRATION_ID); + memcpy(g_model.modelRegistrationID, g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID); #if defined(LUA) && defined(PCBTARANIS) //Horus uses menuModelWizard() for wizard if (isFileAvailable(WIZARD_PATH "/" WIZARD_NAME)) { diff --git a/radio/src/pulses/pxx2.cpp b/radio/src/pulses/pxx2.cpp index fd672d567..a46c85051 100644 --- a/radio/src/pulses/pxx2.cpp +++ b/radio/src/pulses/pxx2.cpp @@ -63,7 +63,7 @@ void Pxx2Pulses::setupRegisterFrame(uint8_t module) if (counter == REGISTER_COUNTER_ID_RECEIVED) { Pxx2Transport::addByte(0x01); - for (uint8_t i=0; i #include "opentx.h" uint8_t telemetryStreaming = 0; @@ -79,18 +80,39 @@ void processRegisterFrame(uint8_t module, uint8_t * frame) } else if (frame[3] == 0x01) { // PASSWORD follows, we check it is good - if (memcmp(&frame[4], g_model.modelRegistrationID, LEN_REGISTRATION_ID) == 0) { + if (memcmp(&frame[4], g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID) == 0) { moduleSettings[module].counter = REGISTER_COUNTER_PASSWORD_RECEIVED; } } } +void processBindFrame(uint8_t module, uint8_t * frame) +{ + if (frame[3] == 0x00) { + bool found = false; + for (uint8_t i=0; i