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

Cannot Pair with Vendor UUID using Central device

Hello, 

 I am using SDK 15.2 with softdevice 140 on nrf52840 board. I have been trying to get the development board to pair with a peripheral sensor with UUID "E7D4AA0F-5ACB-55C0-B177-A07D4525E1FA". I've been looking at the ble_app_uart_c example to see how to best do this. I have tried replacing the line with the original nus_base_uuid with this: 

 

//#define NUS_BASE_UUID                   {{0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E}} /**< Used vendor specific UUID. */

#define NUS_BASE_UUID                   {{0xFA, 0xE1, 0x25, 0x45, 0x7D, 0xA0, 0x77, 0xB1, 0xC0, 0x55, 0xCB, 0x5A, 0x0F, 0xAA, 0xD4, 0xE7}} /**< Used vendor specific UUID. */

 From what I've read about the pairing process, this should pair with my peripheral using this example, is that not correct? I can successfully pair with my peripheral using a phone that has the nrf_connect app or the lightblue app and see all the characteristics as well as being able to write/read from/to them.   

I have paired with other devices in the past through the multilink example using their names however that has not worked with this one. I have also used some of the search functions such as ble_advdata_name_find(p_gap_evt->params.adv_report.data.p_data, p_gap_evt->params.adv_report.data.len , "VitalgramBLE #35015"  ) however i cannot find the name or the uuid in the advertisement packets. 

The device is clearly advertising however I cannot seem to find it. 

Any ideas? 

Regards, 

Gian

Parents
  • Hi,

     From what I've read about the pairing process, this should pair with my peripheral using this example, is that not correct?

    If the UUID filter is correctly configured, it should connect. But, the ble_app_uart and ble_app_uart_c examples does not use the peer manager, so pairing/bonding is by default not supported for these examples.

    I have tried replacing the line with the original nus_base_uuid
    UUID "E7D4AA0F-5ACB-55C0-B177-A07D4525E1FA"

    Try setting the BLE_UUID_NUS_SERVICE in ble_nus_c.h to 0xAA0F

    #define BLE_UUID_NUS_SERVICE            0xAA0F                      /**< The UUID of the Nordic UART Service. */

  • Sigurd, 

     I have changed the line as you suggested in the ble_nus_c.h file however nothing seems to be happening. The Scanning LED continues blink and scanning continues as normal.  It seems as if the central application is not even finding the device. I think this is true because I keep receiving  NRF_BLE_SCAN_EVT_NOT_FOUND within the scan event callback in the application. 

    How should i proceed? 

  • In addition, inside the BLE_GAP_EVT_ADV_REPORT event I added : 

            if(ble_advdata_uuid_find(p_ble_evt->evt.gap_evt.params.adv_report.data.p_data, p_ble_evt->evt.gap_evt.params.adv_report.data.len, &m_nus_uuid))
            {
              NRF_LOG_INFO("\n FOUND UUID OF VITALGRAM APP\n");
            }
    However the code never finds the UUID. I'm thinking that something within the scan settings might not be correct.

  • Could it be that you have reversed the byte order of the UUID ?

    If a non-whitelisted 128bit UUID is found in the event NRF_BLE_SCAN_EVT_NOT_FOUND, you can print it like this:

    typedef struct
    {
        uint8_t * p_data;   /**< Pointer to data. */
        uint16_t  data_len; /**< Length of data. */
    } data_t;
    
    #define N_AD_TYPES 2
    #define UUID128_SIZE    16  /**< Size of 128 bit UUID. */
    #include "ble_advdata.h"
    
    /**@brief Function for handling Scanning Module events.
     */
    static void scan_evt_handler(scan_evt_t const * p_scan_evt)
    {
        ret_code_t err_code;
        data_t   adv_data;
        // Initialize advertisement report for parsing
        adv_data.p_data   = (uint8_t *) p_scan_evt->params.p_not_found->data.p_data;
        
        adv_data.data_len = p_scan_evt->params.p_not_found->data.len;
    
        uint16_t        data_offset = 0;
        uint8_t         ad_types[N_AD_TYPES];
        uint8_t       * p_parsed_uuid;
        uint16_t        parsed_uuid_len = adv_data.data_len;
        uint8_t   uuid_buffer[UUID128_SIZE];      
    
        switch(p_scan_evt->scan_evt_id)
        {
             case NRF_BLE_SCAN_EVT_CONNECTING_ERROR:
             {
                  err_code = p_scan_evt->params.connecting_err.err_code;
                  APP_ERROR_CHECK(err_code);
             } break;
    
             case NRF_BLE_SCAN_EVT_CONNECTED:
             {
                  ble_gap_evt_connected_t const * p_connected =
                                   p_scan_evt->params.connected.p_connected;
                 // Scan is automatically stopped by the connection.
                 NRF_LOG_INFO("Connecting to target %02x%02x%02x%02x%02x%02x",
                          p_connected->peer_addr.addr[0],
                          p_connected->peer_addr.addr[1],
                          p_connected->peer_addr.addr[2],
                          p_connected->peer_addr.addr[3],
                          p_connected->peer_addr.addr[4],
                          p_connected->peer_addr.addr[5]
                          );
             } break;
    
             case NRF_BLE_SCAN_EVT_SCAN_TIMEOUT:
             {
                 NRF_LOG_INFO("Scan timed out.");
                 scan_start();
             } break;
    
             case NRF_BLE_SCAN_EVT_NOT_FOUND:
    
                ad_types[0] = BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE;
                ad_types[1] = BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE;
    
                for (uint8_t i = 0; (i < N_AD_TYPES) && (data_offset == 0); i++)
                {
                    parsed_uuid_len = ble_advdata_search(adv_data.p_data, adv_data.data_len, &data_offset, ad_types[i]);
                }
    
                if (data_offset == 0 )
                {
                    // Could not find any relevant UUIDs in the encoded data.
                    return;
                }
               
                p_parsed_uuid = &adv_data.p_data[data_offset]; //The UUID we found 
    
                //Copy the UUID to our list of devices
                memset(uuid_buffer,0,UUID128_SIZE);
                memcpy(uuid_buffer, p_parsed_uuid, parsed_uuid_len);
    
                 NRF_LOG_INFO("Device-addr %02x:%02x:%02x:%02x:%02x:%02x",
                 p_scan_evt->params.p_not_found->peer_addr.addr[5],
                 p_scan_evt->params.p_not_found->peer_addr.addr[4],
                 p_scan_evt->params.p_not_found->peer_addr.addr[3],
                 p_scan_evt->params.p_not_found->peer_addr.addr[2],
                 p_scan_evt->params.p_not_found->peer_addr.addr[1],
                 p_scan_evt->params.p_not_found->peer_addr.addr[0]
                 );
    
    
    
                NRF_LOG_INFO("Hexdump:");
                NRF_LOG_HEXDUMP_INFO(p_parsed_uuid,parsed_uuid_len);
    
                break;
    
    
             default:
                 break;
        }
    }

  • Sigurd, 

     This has been very helpful. I think we are getting closer. Using the code you provided I can see the UUID of the device i want to pair with being printed to the terminal. I am guessing this means that the device is not being white-listed correctly with the filter. So this has to do with a filtering issue? What can i do to have this 128 bit UUID successfully white-listed and found by the scanner and then paired with?   

  • Disregard this last comment, it turns out that the BLE_UUID_NUS_SERVICE had one incorrect digit. The code works.

Reply Children
No Data
Related