1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-16 12:55:12 +03:00

REGISTER Fix

This commit is contained in:
Bertrand Songis 2019-02-21 18:07:25 +01:00
parent a4434bc5f3
commit cc5838ad49
4 changed files with 10 additions and 10 deletions

View file

@ -303,7 +303,7 @@ void generalDefault()
#endif
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
g_eeGeneral.ownerRegistrationID[i] = (cpu_uid[1 + i] & 0x3f) - 32;
g_eeGeneral.ownerRegistrationID[i] = (cpu_uid[1 + i] & 0x3f) - 26;
}
g_eeGeneral.chkSum = 0xFFFF;

View file

@ -435,7 +435,7 @@ char zchar2char(int8_t idx);
int8_t char2zchar(char c);
void str2zchar(char *dest, const char *src, int size);
int zchar2str(char *dest, const char *src, int size);
int cmpStrWithZchar(char * charString, char * zcharString, int size);
bool cmpStrWithZchar(const char * charString, const char * zcharString, int size);
#include "keys.h"
#include "pwr.h"

View file

@ -52,7 +52,7 @@ int8_t char2zchar(char c)
#endif
if (c >= 'a') return 'a' - c - 1;
if (c >= 'A') return c - 'A' + 1;
if (c >= '0') return -(c - '0' + 27);
if (c >= '0') return c - '0' + 27;
if (c == '-') return 38;
if (c == '.') return 39;
if (c == ',') return 40;
@ -78,14 +78,14 @@ int zchar2str(char * dest, const char * src, int size)
return size+1;
}
int cmpStrWithZchar(char * charString, char * zcharString, int size)
bool cmpStrWithZchar(const char * charString, const char * zcharString, int size)
{
for(int i=0; i < size; i++) {
if((uint8_t)char2zchar(charString[i]) != (uint8_t)zcharString[i]) {
return 1;
for (int i=0; i<size; i++) {
if (char2zchar(charString[i]) != (int8_t)zcharString[i]) {
return false;
}
}
return 0;
return true;
}
unsigned int effectiveLen(const char * str, unsigned int size)

View file

@ -84,8 +84,8 @@ void processRegisterFrame(uint8_t module, uint8_t * frame)
}
else if (frame[3] == 0x01 && reusableBuffer.modelSetup.pxx2.registerStep == REGISTER_RX_NAME_SELECTED) {
// RX_NAME + PASSWORD follow, we check they are good
if (cmpStrWithZchar((char *) &frame[4], reusableBuffer.modelSetup.pxx2.registerRxName, PXX2_LEN_RX_NAME) == 0 &&
cmpStrWithZchar((char *)&frame[12], g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID) == 0) {
if (cmpStrWithZchar((char *)&frame[4], reusableBuffer.modelSetup.pxx2.registerRxName, PXX2_LEN_RX_NAME) &&
cmpStrWithZchar((char *)&frame[12], g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID)) {
reusableBuffer.modelSetup.pxx2.registerStep = REGISTER_OK;
moduleSettings[module].mode = MODULE_MODE_NORMAL;
POPUP_INFORMATION(STR_REG_OK);