mirror of
https://github.com/opentx/opentx.git
synced 2025-07-23 16:25:16 +03:00
BIND shared array filled with incoming models
This commit is contained in:
parent
aaa4206a1c
commit
80c34c7597
5 changed files with 32 additions and 10 deletions
|
@ -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_
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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<LEN_REGISTRATION_ID; i++) {
|
||||
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
|
||||
Pxx2Transport::addByte(g_model.modelRegistrationID[i]);
|
||||
}
|
||||
}
|
||||
|
@ -77,10 +77,9 @@ void Pxx2Pulses::setupBindFrame(uint8_t module)
|
|||
addFrameType(PXX2_TYPE_C_MODULE, PXX2_TYPE_ID_BIND);
|
||||
|
||||
Pxx2Transport::addByte(0x00);
|
||||
for (uint8_t i=0; i<LEN_REGISTRATION_ID; i++) {
|
||||
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
|
||||
Pxx2Transport::addByte(g_model.modelRegistrationID[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Pxx2Pulses::setupFrame(uint8_t module)
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <opentx.h>
|
||||
#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<reusableBuffer.modelsetup.pxx2_candidate_receivers_count; i++) {
|
||||
if (memcmp(reusableBuffer.modelsetup.pxx2_candidate_receivers[i], &frame[4], PXX2_LEN_RX_ID) == 0) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found && reusableBuffer.modelsetup.pxx2_candidate_receivers_count < PXX2_MAX_RECEIVERS_PER_MODULE) {
|
||||
memcpy(reusableBuffer.modelsetup.pxx2_candidate_receivers[reusableBuffer.modelsetup.pxx2_candidate_receivers_count], &frame[4], PXX2_LEN_RX_ID);
|
||||
++reusableBuffer.modelsetup.pxx2_candidate_receivers_count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void processRadioFrame(uint8_t module, uint8_t * frame)
|
||||
{
|
||||
switch (frame[2]) {
|
||||
case PXX2_TYPE_ID_REGISTER:
|
||||
processRegisterFrame(module, frame);
|
||||
break;
|
||||
|
||||
case PXX2_TYPE_ID_BIND:
|
||||
processBindFrame(module, frame);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue