This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How can I know the event is peri or central?

Hi. I'm using nRF51822, SDK12.2.0, S130 v2.0.1.

I'm using nRF chip as Multi-connection Central and 1 Peripheral as well.

My event function is

static void on_ble_evt(ble_evt_t * p_ble_evt) {

ret_code_t err_code;

// For readability.
const ble_gap_evt_t * const p_gap_evt = &p_ble_evt->evt.gap_evt;

switch (p_ble_evt->header.evt_id)
{
case BLE_GATTS_EVT_WRITE:
{
                 ......
}
break;
    case BLE_GAP_EVT_CONNECTED:
    {
        ......
    }
break;
        ......

}

static void ble_evt_dispatch(ble_evt_t * p_ble_evt) {

uint16_t conn_handle;
conn_handle = p_ble_evt->evt.gap_evt.conn_handle;

ble_conn_state_on_ble_evt(p_ble_evt);
on_ble_evt(p_ble_evt);

// Make sure taht an invalid connection handle are not passed since
// our array of modules is bound to TOTAL_LINK_COUNT.
if (conn_handle < TOTAL_LINK_COUNT)
{
    ble_db_discovery_on_ble_evt(&m_ble_db_discovery[conn_handle], p_ble_evt);
    ble_lbs_c_on_ble_evt(&m_ble_lbs_c[conn_handle], p_ble_evt);
}

}

In "on_ble_evt" function, when it makes connection with periphral, it goes to "case BLE_GAP_EVT_CONNECTED:" event, And when it makes connection with central, it goes to "case BLE_GAP_EVT_CONNECTED:" event too.

How can I know whether it is central events or peripheral events?

I need your help.

Related