mirror of
https://github.com/opentx/opentx.git
synced 2025-07-21 15:25:17 +03:00
Bind and registration ok (hoppefully...)
This commit is contained in:
parent
9472fd2132
commit
2559a84a24
5 changed files with 18 additions and 17 deletions
|
@ -337,7 +337,7 @@ void defaultInputs()
|
||||||
expo->mode = 3; // TODO constant
|
expo->mode = 3; // TODO constant
|
||||||
#if defined(TRANSLATIONS_CZ)
|
#if defined(TRANSLATIONS_CZ)
|
||||||
for (int c=0; c<4; c++) {
|
for (int c=0; c<4; c++) {
|
||||||
g_model.inputNames[i][c] = char2idx(STR_INPUTNAMES[1+4*(stick_index-1)+c]);
|
g_model.inputNames[i][c] = char2zchar(STR_INPUTNAMES[1+4*(stick_index-1)+c]);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
for (int c=0; c<3; c++) {
|
for (int c=0; c<3; c++) {
|
||||||
|
|
|
@ -435,6 +435,7 @@ char zchar2char(int8_t idx);
|
||||||
int8_t char2zchar(char c);
|
int8_t char2zchar(char c);
|
||||||
void str2zchar(char *dest, const char *src, int size);
|
void str2zchar(char *dest, const char *src, int size);
|
||||||
int zchar2str(char *dest, const char *src, int size);
|
int zchar2str(char *dest, const char *src, int size);
|
||||||
|
int cmpStrWithZchar(char * charString, char * zcharString, int size);
|
||||||
|
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "pwr.h"
|
#include "pwr.h"
|
||||||
|
|
|
@ -61,10 +61,10 @@ bool Pxx2Pulses::setupRegisterFrame(uint8_t module)
|
||||||
if (reusableBuffer.modelSetup.pxx2.registerStep == REGISTER_RX_NAME_SELECTED) {
|
if (reusableBuffer.modelSetup.pxx2.registerStep == REGISTER_RX_NAME_SELECTED) {
|
||||||
Pxx2Transport::addByte(0x01);
|
Pxx2Transport::addByte(0x01);
|
||||||
for (uint8_t i=0; i<PXX2_LEN_RX_NAME; i++) {
|
for (uint8_t i=0; i<PXX2_LEN_RX_NAME; i++) {
|
||||||
Pxx2Transport::addByte(reusableBuffer.modelSetup.pxx2.registerRxName[i]);
|
Pxx2Transport::addByte(zchar2char(reusableBuffer.modelSetup.pxx2.registerRxName[i]));
|
||||||
}
|
}
|
||||||
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
|
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
|
||||||
Pxx2Transport::addByte(g_model.modelRegistrationID[i]);
|
Pxx2Transport::addByte(zchar2char(g_model.modelRegistrationID[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -97,7 +97,7 @@ bool Pxx2Pulses::setupBindFrame(uint8_t module)
|
||||||
else {
|
else {
|
||||||
Pxx2Transport::addByte(0x00);
|
Pxx2Transport::addByte(0x00);
|
||||||
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
|
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
|
||||||
Pxx2Transport::addByte(g_model.modelRegistrationID[i]);
|
Pxx2Transport::addByte(zchar2char(g_model.modelRegistrationID[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,16 @@ int zchar2str(char * dest, const char * src, int size)
|
||||||
return size+1;
|
return size+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cmpStrWithZchar(char * charString, char * zcharString, int size)
|
||||||
|
{
|
||||||
|
for(int i=0; i < size; i++) {
|
||||||
|
if((uint8_t)char2zchar(charString[i]) != (uint8_t)zcharString[i]) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int effectiveLen(const char * str, unsigned int size)
|
unsigned int effectiveLen(const char * str, unsigned int size)
|
||||||
{
|
{
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
|
|
|
@ -79,13 +79,13 @@ void processRegisterFrame(uint8_t module, uint8_t * frame)
|
||||||
|
|
||||||
if (frame[3] == 0x00 && reusableBuffer.modelSetup.pxx2.registerStep == REGISTER_START) {
|
if (frame[3] == 0x00 && reusableBuffer.modelSetup.pxx2.registerStep == REGISTER_START) {
|
||||||
// RX_NAME follows, we store it for the next step
|
// RX_NAME follows, we store it for the next step
|
||||||
memcpy(reusableBuffer.modelSetup.pxx2.registerRxName, &frame[4], PXX2_LEN_RX_NAME);
|
str2zchar(reusableBuffer.modelSetup.pxx2.registerRxName, (const char *)&frame[4], PXX2_LEN_RX_NAME);
|
||||||
reusableBuffer.modelSetup.pxx2.registerStep = REGISTER_RX_NAME_RECEIVED;
|
reusableBuffer.modelSetup.pxx2.registerStep = REGISTER_RX_NAME_RECEIVED;
|
||||||
}
|
}
|
||||||
else if (frame[3] == 0x01 && reusableBuffer.modelSetup.pxx2.registerStep == REGISTER_RX_NAME_SELECTED) {
|
else if (frame[3] == 0x01 && reusableBuffer.modelSetup.pxx2.registerStep == REGISTER_RX_NAME_SELECTED) {
|
||||||
// RX_NAME + PASSWORD follow, we check they are good
|
// RX_NAME + PASSWORD follow, we check they are good
|
||||||
if (memcmp(&frame[4], reusableBuffer.modelSetup.pxx2.registerRxName, PXX2_LEN_RX_NAME) == 0 &&
|
if (cmpStrWithZchar((char *) &frame[4], reusableBuffer.modelSetup.pxx2.registerRxName, PXX2_LEN_RX_NAME) == 0 &&
|
||||||
memcmp(&frame[12], g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID) == 0) {
|
cmpStrWithZchar((char *)&frame[12], g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID) == 0) {
|
||||||
reusableBuffer.modelSetup.pxx2.registerStep = REGISTER_OK;
|
reusableBuffer.modelSetup.pxx2.registerStep = REGISTER_OK;
|
||||||
moduleSettings[module].mode = MODULE_MODE_NORMAL;
|
moduleSettings[module].mode = MODULE_MODE_NORMAL;
|
||||||
POPUP_INFORMATION(STR_REG_OK);
|
POPUP_INFORMATION(STR_REG_OK);
|
||||||
|
@ -109,16 +109,6 @@ void processBindFrame(uint8_t module, uint8_t * frame)
|
||||||
}
|
}
|
||||||
if (!found && reusableBuffer.modelSetup.pxx2.bindCandidateReceiversCount < PXX2_MAX_RECEIVERS_PER_MODULE) {
|
if (!found && reusableBuffer.modelSetup.pxx2.bindCandidateReceiversCount < PXX2_MAX_RECEIVERS_PER_MODULE) {
|
||||||
memcpy(reusableBuffer.modelSetup.pxx2.bindCandidateReceiversNames[reusableBuffer.modelSetup.pxx2.bindCandidateReceiversCount], &frame[4], PXX2_LEN_RX_NAME);
|
memcpy(reusableBuffer.modelSetup.pxx2.bindCandidateReceiversNames[reusableBuffer.modelSetup.pxx2.bindCandidateReceiversCount], &frame[4], PXX2_LEN_RX_NAME);
|
||||||
/*char * c = reusableBuffer.modelSetup.pxx2.bindCandidateReceiversNames[reusableBuffer.modelSetup.pxx2.bindCandidateReceiversCount];
|
|
||||||
for (uint8_t i=0; i<PXX2_LEN_RX_NAME; i++) {
|
|
||||||
uint8_t byte = frame[4 + i];
|
|
||||||
uint8_t quartet = (byte >> 4);
|
|
||||||
*c++ = (quartet >= 10 ? quartet + 'A' - 10 : quartet + '0');
|
|
||||||
quartet = (byte & 0x0f);
|
|
||||||
*c++ = (quartet >= 10 ? quartet + 'A' - 10 : quartet + '0');
|
|
||||||
*c++ = ' ';
|
|
||||||
}
|
|
||||||
*c = '\0';*/
|
|
||||||
++reusableBuffer.modelSetup.pxx2.bindCandidateReceiversCount;
|
++reusableBuffer.modelSetup.pxx2.bindCandidateReceiversCount;
|
||||||
reusableBuffer.modelSetup.pxx2.bindStep = BIND_RX_NAME_RECEIVED;
|
reusableBuffer.modelSetup.pxx2.bindStep = BIND_RX_NAME_RECEIVED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue