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

nRF51822/ BLE nano: Connect to a blue tooth by address

I am developing a script that runs on the nRF51822/ BLE nano to connect to other devices using blue tooth low energy. To do this currently I am looking at the heart rate example that comes with the Nordic SDK. The problem I am having is that the central device in this example searches for peripheral with a certain UUID. I want to search for a device by blue tooth address instead of UUID. How do I do this?

Parents
  • Hi,

    You can take a look at the Nordic UART Service Client example in the SDK. The address is present in the advertising packet and can be read as follows:

    static void on_ble_evt(ble_evt_t * p_ble_evt)
    {
        const ble_gap_evt_t * p_gap_evt = &p_ble_evt->evt.gap_evt;
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_ADV_REPORT:
            {
                const ble_gap_evt_adv_report_t * p_adv_report = &p_gap_evt->params.adv_report;
                printf("Advertising packet from: %02x%02x%02x%02x%02x%02x\r\n",
                          p_adv_report->peer_addr.addr[0],
                          p_adv_report->peer_addr.addr[1],
                          p_adv_report->peer_addr.addr[2],
                          p_adv_report->peer_addr.addr[3],
                          p_adv_report->peer_addr.addr[4],
                          p_adv_report->peer_addr.addr[5]
                          );
            }break; // BLE_GAP_EVT_ADV_REPORT
        }
    }
    

    Best regards,

    Jørgen

  • So if I set p_adv_report->peer_addr.addr to the peripherals bluetooth address and run the example code it will work? I'm trying to enter my bluetooth address into the ble_central and can't find how to add it in and also remove the search for the heart beat UUID.

Reply Children
No Data
Related