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

How to connect two nrf DK boards through BLE

hi, i have a requirement to connect two nrf51(PCA10028) boards to connect each other.

1).if i turn on the Board1 should scan the bluetooth devices if any other bluetooth devices(other Board2(PCA10028)) present it should connect.

2).if i send any data using ble_nus_string_send by board1 PCA10028 the other board2 should receive the data.

3).is there any example code in sdk for the above functionality.

please provide any example code.

Thankyou

Parents
  • Hi,

    The Nordic UART Service Client example should fit your needs. This example scans for devices that advertises with the NUS UUID in its advertisement report, and connects to the device. You can then transfer data between the boards using the Nordic UART service.

    You will have to modify the example if you want it to only connect to nRF51 devices, or if you want the central to be able to connect to multiple client-boards.

    [EDIT:]

    To extract name from advertising report, you can use a function like this:

        static bool get_name_from_adv_report(char *p_dev_name,
                            const ble_gap_evt_adv_report_t *p_adv_report)
    {
        uint32_t index = 0;
        uint8_t *p_data = (uint8_t *)p_adv_report->data;
        char *name;
        while (index < p_adv_report->dlen)
        {
            uint8_t field_length = p_data[index];
            uint8_t field_type   = p_data[index + 1];
    
        if ( (field_type == BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME )
           || (field_type == BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME)
           )
        {
            name =  (char *)&p_data[index + 2];
            name[field_length-1] = '\0';
            memcpy(p_dev_name,name, field_length);
            p_dev_name = name;
            return true;
        }
        index += field_length + 1;
    }
    return false;
    

    }

    You can then call this function in BLE_GAP_EVT_ADV_REPORT event and check the name agains what you have set as your target device name.

    Best regards, Jørgen

  • hey, sorry (i have flashed SDK12 ble_app_uart_c on nrf52 )

    the central device is keep on connecting and disconnecting to peripheral device which is PCA1001 & s110. it is restarting every time. but LED on the nRF52 is keep on glowing.

    how to maintain stable connection.

    the info in the UART is like this..

    Uart_c Scan started

    Connecting to target fd50cc82b8ca

    The device has the Nordic UART Service

    ////data which i am recieving from PCA1001

    <3-0:L1,R1>[00]<1-1,2-2,3-3>[00]<1-1,2-2,3-3>[00]

    Disconnected

    Connecting to target fd50cc82b8ca

    The device has the Nordic UART Service

    Disconnected

    Connecting to target fd50cc82b8ca

    The device has the Nordic UART Service

    Disconnected

    Connecting to target fd50cc82b8ca

    The device has the Nordic UART Servic

    ////data which i am recieving from PCA1001

    <3-0:L1,R1>[00]<1-1,2-2,3-3>[00]<1-1,2-2,3-3>[00]

    Disconnected

    Connecting to target fd50cc82b8ca

    The device has the Nordic UART Service

    Disconnected

Reply
  • hey, sorry (i have flashed SDK12 ble_app_uart_c on nrf52 )

    the central device is keep on connecting and disconnecting to peripheral device which is PCA1001 & s110. it is restarting every time. but LED on the nRF52 is keep on glowing.

    how to maintain stable connection.

    the info in the UART is like this..

    Uart_c Scan started

    Connecting to target fd50cc82b8ca

    The device has the Nordic UART Service

    ////data which i am recieving from PCA1001

    <3-0:L1,R1>[00]<1-1,2-2,3-3>[00]<1-1,2-2,3-3>[00]

    Disconnected

    Connecting to target fd50cc82b8ca

    The device has the Nordic UART Service

    Disconnected

    Connecting to target fd50cc82b8ca

    The device has the Nordic UART Service

    Disconnected

    Connecting to target fd50cc82b8ca

    The device has the Nordic UART Servic

    ////data which i am recieving from PCA1001

    <3-0:L1,R1>[00]<1-1,2-2,3-3>[00]<1-1,2-2,3-3>[00]

    Disconnected

    Connecting to target fd50cc82b8ca

    The device has the Nordic UART Service

    Disconnected

Children
No Data
Related