Using custom OOB key and LESC

I'm working on a project were we require the use of a custom OOB key (not generated by the device itself) and LESC.

We have both the central and peripheral device to configure but from what I'm understanding the peripheral actually controls the link configuration.

I've read numerous posts on looking at examples projects like ble_hrs and glucose and such.

I have read them and understood them but it doesn't do what I want to do.

I have managed to get LESC security working by using a passkey and the BLE_GAP_EVT_CONN_SEC_UPDATE Security mode: 1. Security level: 4

I can also see on the central the BLE_GAP_EVT_AUTH_KEY_REQUEST event coming and providing the correct passkey style key.

 

If I disable LESC and enable OOB on my peripheral I can use a static custom OOB key and I manage to connect and receive Security mode: 1. Security level: 3

I can also see on the central the BLE_GAP_EVT_AUTH_KEY_REQUEST event coming and providing the correct OOB style key.

When I disable passkey, and enable LESC and OOB I get an error when I call the nrf_ble_lesc_request_handler() function. The error is NRF_ERROR_INTERNAL.

In both the peripheral and central I have nrf_ble_lesc_peer_oob_data_handler_set(&Ble_OobDataHandler); set so I have a handler.


The handler looks like this
static ble_gap_lesc_oob_data_t *Ble_OobDataHandler(uint16_t u16ConnectionHandle)
{
static ble_gap_lesc_oob_data_t stBleLescOobData = { 0 };
memcpy(&stBleLescOobData.addr, &s_stBleAddress, sizeof(ble_gap_addr_t));
memcpy(stBleLescOobData.c, s_u8OobKey, 16);
memcpy(stBleLescOobData.r, s_u8OobKey, 16);
return &stBleLescOobData;
}

For now I have both C and R keys set to the same 16 bytes, I don't know if this matters but I assume not.

I also assume that he address in this function is our own address and not the address of the other device. I've tested  both and both fail.

I can see that on both sides the handler is called. On the peripheral side I get an error of 0x1100 in the PM_EVT_CONN_SEC_FAILED event.

Could someone explain how I set this up or is it not possible to use a custom OOB key in combination with LESC?

Parents Reply Children
Related