This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

getting adv device name of peripheral in central connection once connected

hai ,

          In my application to connect 5 peripherals with central and here i am connecting with  device names

static char const m_target_periph_name1[] = "Nordic_Blinky1";
static char const m_target_periph_name2[] = "Nordic_Blinky2";

i am able to print the device names in  BLE_GAP_EVT_ADV_REPORT

const ble_gap_evt_adv_report_t *p_adv_report = &p_gap_evt->params.adv_report;
const ble_data_t *data = &p_adv_report->data;

uint8_t *device_name = ble_advdata_parse(data->p_data, data->len, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME);
// int8_t report = p_ble_evt->evt.gap_evt.params.adv_report.rssi;

if(data->len == 0)
{
printf("nothing\n");
}
else{
printf("%s \r\n",device_name);
}

here my question is ,

i should get the connected name and connection id for every connection  in central 

how to get the connected device name  and  connected ID and also once it disconnected should get name the disconnected device  name and id ??

regards,

sowmiya

Parents Reply Children
  • static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
        ret_code_t err_code;
     uint8_array_t adv_data;
        uint8_array_t dev_name;
        // For readability.
        ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
      const ble_gap_evt_adv_report_t *p_adv_report = &p_gap_evt->params.adv_report;
     const ble_data_t *data = &p_adv_report->data;
        switch (p_ble_evt->header.evt_id)
        {   
            case BLE_GAP_EVT_ADV_REPORT:
            {
         
                 ret_code_t err;
    
            
    
    uint8_t *device_name = ble_advdata_parse(data->p_data, data->len, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME);
        int8_t report = p_ble_evt->evt.gap_evt.params.adv_report.rssi;
    
        if(data->len == 0)
        {
          printf("nothing\n");
        }
        else{
          printf("%s \r\n",device_name);  
        }
        }
         case BLE_GAP_EVT_CONNECTED:
            { 
              
              printf("CONNECTED\n");
                NRF_LOG_INFO("Connected.");
                  NRF_LOG_INFO("connected to %02x,%02x,%02x,%02x,%02x,%02x\n", p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr[0],
                                                                           p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr[1],
                                                                           p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr[2],
                                                                           p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr[3],
                                                                           p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr[4],
                                                                           p_ble_evt->evt.gap_evt.params.connected.peer_addr.addr[5]) 
                                                                           
                                                                           
                                                                           break;
                                                                           }
                                                                           }
                                                                           }

    static char const m_target_periph_name1[] = "Nordic_Blinky1";
    static char const m_target_periph_name2[] = "Nordic_Blinky2";

    For connection , above is my device name

    here my question is ,

    i should get the connected name and connection id for every connection  in central 

    how to get the connected device name  and  connected ID and also once it disconnected should get name the disconnected device  name and id ??

Related