Browse Source

Merge pull request #257 from liamcottle/fix/valid-ble-pin

ble pin must be zero or a valid 6 digit pin
pull/270/head
ripplebiz 1 year ago
committed by GitHub
parent
commit
90b3b1b6fe
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 17
      examples/companion_radio/main.cpp

17
examples/companion_radio/main.cpp

@ -1490,9 +1490,20 @@ public:
writeErrFrame(ERR_CODE_TABLE_FULL);
}
} else if (cmd_frame[0] == CMD_SET_DEVICE_PIN && len >= 5) {
memcpy(&_prefs.ble_pin, &cmd_frame[1], 4);
savePrefs();
writeOKFrame();
// get pin from command frame
uint32_t pin;
memcpy(&pin, &cmd_frame[1], 4);
// ensure pin is zero, or a valid 6 digit pin
if(pin == 0 || (pin >= 100000 && pin <= 999999)){
_prefs.ble_pin = pin;
savePrefs();
writeOKFrame();
} else {
writeErrFrame(ERR_CODE_ILLEGAL_ARG);
}
} else if (cmd_frame[0] == CMD_GET_CUSTOM_VARS) {
out_frame[0] = RESP_CODE_CUSTOM_VARS;
char* dp = (char *) &out_frame[1];

Loading…
Cancel
Save