Hi,
I am working with the nRF54L15 and I want to use it both as a BLE central and as a BLE peripheral. So, I have two separate source files: one for central and one for peripheral functionality. In each file, I have registered callbacks like this:
Peri:
BT_CONN_CB_DEFINE(peripheral_conn_callbacks) = { .connected = on_periph_connected_cb, .disconnected = on_periph_disconnected_cb, .recycled = on_periph_recycled_cb, };
Central:
BT_CONN_CB_DEFINE(central_conn_callbacks) = { .connected = on_central_connected_cb, .disconnected = on_central_disconnected_cb, .security_changed = on_central_security_changed_cb, .recycled = on_central_recycled_cb, .le_cs_read_remote_capabilities_complete = on_cs_remote_capabilities_cb, .le_cs_config_complete = on_cs_config_create_cb, .le_cs_security_enable_complete = on_cs_security_enable_cb, .le_cs_procedure_enable_complete = on_cs_procedure_enable_cb, .le_cs_subevent_data_available = on_cs_subevent_result_cb, };
However, when I connect to my nRF54L15 (acting as peripheral) with a mobile phone, the on_central_connected_cb
callback is called instead of
on_periph_connected_cb. (I haven’t been able to test the reverse scenario yet).
Is it necessary to check inside the callback who actually connected, if it is a central or a peripheral? How is this usually handled in Zephyr/nRF Connect SDK? Is there a recommended way to distinguish whether the connection is from a central or a peripheral device in these callbacks?
Thank you.