diff --git a/ble/central_device_db_memory.c b/ble/central_device_db_memory.c index f2ca7805f..a8904e4be 100644 --- a/ble/central_device_db_memory.c +++ b/ble/central_device_db_memory.c @@ -43,45 +43,75 @@ // Central Device db implemenation using static memory typedef struct central_device_memory_db { + + // Identification int addr_type; bd_addr_t addr; - sm_key_t csrk; sm_key_t irk; - uint32_t signing_counter; + + // Stored pairing information allows to re-establish an enncrypted connection + // with a peripheral that doesn't have any persistent memory + sm_key_t ltk; + uint16_t ediv; + uint8_t rand[8]; + + // Signed Writes by remote + sm_key_t csrk; + uint32_t remote_counter; + + // Signed Writes to remote (local CSRK is fixed) + uint32_t local_counter; + } central_device_memory_db_t; #define CENTRAL_DEVICE_MEMORY_SIZE 4 +#define INVALID_ENTRY_ADDR_TYPE 0xff + static central_device_memory_db_t central_devices[CENTRAL_DEVICE_MEMORY_SIZE]; -static int central_devices_count; void central_device_db_init(){ - central_devices_count = 0; + int i; + for (i=0;i= CENTRAL_DEVICE_MEMORY_SIZE) return -1; + int i; + int index = -1; + for (i=0;i