hfix: read existing pairing code from eeprom

This commit is contained in:
Florian Didron
2022-06-03 16:28:08 +09:00
parent e0ef1fc3a7
commit 0cb81b76f8
2 changed files with 23 additions and 1 deletions

View File

@@ -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];

View File

@@ -50,6 +50,7 @@ bool store_pairing_sequence(keypos_t* pairing_sequence);
keypos_t get_random_keypos(void);
void pairing_init_handler(void);
void pairing_validate_handler(void);
void pairing_validate_eeprom_handler(void);
void pairing_init_event(void);
void pairing_key_input_event(void);
void pairing_failed_event(void);