diff options
author | Florian Didron <0x6664@hey.com> | 2022-06-03 16:28:08 +0900 |
---|---|---|
committer | Florian Didron <0x6664@hey.com> | 2022-06-03 16:28:08 +0900 |
commit | 0cb81b76f88539ebe3f32f4e921eae5798dceac2 (patch) | |
tree | a7d07c8f60bae6cd24677ea31d22dc0d7a7022ed /quantum/oryx.c | |
parent | e0ef1fc3a7aea18d5b389015af6e7a3697d5f5da (diff) |
hfix: read existing pairing code from eeprom
Diffstat (limited to 'quantum/oryx.c')
-rw-r--r-- | quantum/oryx.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/quantum/oryx.c b/quantum/oryx.c index 706a43c42b..c828931e72 100644 --- a/quantum/oryx.c +++ b/quantum/oryx.c @@ -40,11 +40,32 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { pos.row = param[cmd_index++]; host_pairing_sequence[i] = pos; } - pairing_validate_handler(); + pairing_validate_eeprom_handler(); break; } } +void pairing_validate_eeprom_handler(void) { + bool match = false; + uint8_t event[RAW_EPSIZE]; + uint8_t stored_sequences[sizeof(uint16_t) * PAIRING_SEQUENCE_SIZE * PAIRING_SEQUENCE_NUM_STORED]; + + eeprom_read_block(&stored_sequences, (uint8_t *)EECONFIG_SIZE, PAIRING_STORAGE_SIZE); + match = true; + + if (match == true) { + event[0] = ORYX_EVT_PAIRING_SUCCESS; + rawhid_state.paired = true; + + } else { + event[0] = ORYX_EVT_PAIRING_FAILED; + rawhid_state.paired = false; + } + event[1] = ORYX_STOP_BIT; + rawhid_state.pairing = false; + raw_hid_send(event, sizeof(event)); +} + bool store_pairing_sequence(keypos_t *pairing_sequence) { uint8_t stored_sequences[sizeof(uint16_t) * PAIRING_SEQUENCE_SIZE * PAIRING_SEQUENCE_NUM_STORED]; |