summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Didron <0x6664@hey.com>2022-06-03 16:28:08 +0900
committerFlorian Didron <0x6664@hey.com>2022-06-03 16:28:08 +0900
commit0cb81b76f88539ebe3f32f4e921eae5798dceac2 (patch)
treea7d07c8f60bae6cd24677ea31d22dc0d7a7022ed
parente0ef1fc3a7aea18d5b389015af6e7a3697d5f5da (diff)
hfix: read existing pairing code from eeprom
-rw-r--r--quantum/oryx.c23
-rw-r--r--quantum/oryx.h1
2 files changed, 23 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];
diff --git a/quantum/oryx.h b/quantum/oryx.h
index 5f6581235c..e7659fff27 100644
--- a/quantum/oryx.h
+++ b/quantum/oryx.h
@@ -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);