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

Connecting a peripheral device to a central device

Hi, I am trying to connect a peripheral device which in this case is a BLE device called DELTA and I am trying to connect it to a central device which is the NRF52 board. However, I am not successful because they are not connected to each other somehow, even though I put the correct UUID in the I used the ble_uart_c example that was provided on the Nordic website and changed the default base UUID, BLE_UUID_NUS_SERVICE, and the BLE_UUID_NUS_TX_CHARACTERISTIC from the ble_nus_c. I put 0x2902 because that was the UUID under the longer version of the UUID. Is this how to properly set up the UUID in the code listed below?

The UUID for the peripheral device is c1d0f554-a142-4b56-b02d-2bc23da2df50

This is what I have for the connection. Any help will be appreciated :)

#define NUS_BASE_UUID                  {{0xC1, 0xD0, 0xF5, 0x54, 0xA1, 0x42, 0x4B, 0x56, 0xB0, 0x2D, 0x2B, 0xC2, 0x3D, 0xA2, 0xDF, 0x50}} /**< Used vendor specific UUID. */
#define BLE_UUID_NUS_SERVICE           0x2902                 
#define BLE_UUID_NUS_TX_CHARACTERISTIC 0x2A4B                      /**< The UUID of the TX Characteristic. */
#define BLE_UUID_NUS_RX_CHARACTERISTIC 0x0001                     /**< The UUID of the RX Characteristic. */

UPDATE:

I think I got the issue with the UUID. However I am not sure, if I am doing the array in the method static bool is_uuid_present(const ble_uuid_t *p_target_uuid, const ble_gap_evt_adv_report_t *p_adv_report) correctly.

I know it is the 128 bit service that has to be executed,

if ( (field_type == BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE) || (field_type == BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE) ) { err_code = sd_ble_uuid_decode(UUID128_SIZE, &p_data[index], &extracted_uuid); if (err_code == NRF_SUCCESS) { if ((extracted_uuid.uuid == p_target_uuid->uuid) && (extracted_uuid.type == p_target_uuid->type)) { return true; } } } index += field_length + 1; }

However, the extracted uuid is different from the target uuid when debugging. Is there a problem with that?

Parents
  • In the ble_app_uart_c example the central will check the UUID type and UUID service found in the advertising/scan response packet. This is done by the function is_uuid_present(&m_nus_uuid, p_adv_report) line 345 in main.c (SDK12.1). The m_nus_uuid is a struct containing the BLE_UUID_NUS_SERVICE (0x0001) and NUS_SERVICE_UUID_TYPE(0x02 Vendor UUID type 128-bit). If these values match the values in p_adv_report the central will connect to the peripheral.

  • The BLE_UUID_NUS_SERVICE is 0x0001. The NUS_SERVICE_UUID_TYPE is a BLE_UUID_TYPE_VENDOR_BEGIN, this is defined in ble_types.h as 0x02. I don’t believe you need to change the is_uuid_present(), the UUID gets decoded from the advertising data using the sd_ble_uuid_decode().

    Also, If the goal is just to connect the devices, and you know what the extracted_uuid is, just add this as the target_uuid, and the central will connect to the device.

Reply
  • The BLE_UUID_NUS_SERVICE is 0x0001. The NUS_SERVICE_UUID_TYPE is a BLE_UUID_TYPE_VENDOR_BEGIN, this is defined in ble_types.h as 0x02. I don’t believe you need to change the is_uuid_present(), the UUID gets decoded from the advertising data using the sd_ble_uuid_decode().

    Also, If the goal is just to connect the devices, and you know what the extracted_uuid is, just add this as the target_uuid, and the central will connect to the device.

Children
No Data
Related