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

nRF51822 does not found service

Hi Guys,

I am new in BLE world, so sorry if I ask stupid questions.

I have a Simblee RFD77101 and a nRF 51822 chip. I would like to connect from nRF51 to Simblee and change data via BLE.

I started to use SDK 11 and tutorial ble_central/ble_app_uart_c project with s130 v2.0.0 soft device. To find Simblee and connect to it works well, but data changing not. ble_db_discovery does not find any services, so I cannot send and receive data on any characteristics... I do not get any callback to get "something happend". So my questions:

  1. Shouldn't nRF51 find at least the base services?

  2. Should I add custom service to find Simblee's service?

  3. I started to use wrong project? Or what am I doing/thinking wrong?

Thanks for help! :)

Edit 01:

The Simblee firmware is unknown for me, but yes, i register the service (in ble_nus_c.c, ble_nus_c_init function). Now, I get some debug info:

Connected to target
[DB]: Starting discovery of service with UUID 0xfe84 for Connection handle 0
BLE Event: 48
[DIS]: Services (0), Status: 266
Service UUID 0xfe84 Not found

If I do not specify the service uuid (pass NULL for sd_ble_gattc_primary_services_discover third parameter), i get the base service with characteristics (0x2a00, 0x2a01, 0x2a02, 0x2a04 If i remember well)

Now, if i delete these rows, in ble_nus_c.c, ble_nus_c_init function

err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_ble_nus_c->uuid_type);
VERIFY_SUCCESS(err_code);

I get this debug text, and after that, the nRF51 chip crashed, restarted

Connecting to target 77a68eed44c1
BLE Event: 29
BLE Event: 16
Connected to target
[DB]: Starting discovery of service with UUID 0xfe84 for Connection handle 0
BLE Event: 48
[DIS]: Services (0), Status: 0
Found service UUID 0xfe84
BLE Event: 50
previously discovered: 0
currently discovered: 1
Char uuid: 0, read: 1, write: 0, write_no: 0, notify: 1
BLE Event: 50
previously discovered: 1
currently discovered: 1
Char uuid: 0, read: 0, write: 1, write_no: 1, notify: 0
BLE Event: 50
previously discovered: 2
currently discovered: 1
Char uuid: 0, read: 0, write: 1, write_no: 1, notify: 0
BLE Event: 50
BLE Event: 51

I red the documentation about sd_ble_uuid_vs_add , but I do not understand it... :/ What is vendor specific uuid?!

And there are some defines, what i am using for

//#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  {{0x96, 0x07, 0x0C, 0x49, 0x10, 0x11, 0x0E, 0xDF, 0x53, 0x2B, 0x91, 0x23, 0x60, 0x0B, 0x57, 0x4D}}
#define NUS_BASE_UUID  {{0x2D, 0x30, 0xC0, 0x80, 0xF3, 0x9F, 0x4C, 0xE6, 0x92, 0x3F, 0x34, 0x84, 0xEA, 0x48, 0x05, 0x96}}

#define BLE_UUID_NUS_SERVICE           0xFE84                      /**< The UUID of the Nordic UART Service. */
#define BLE_UUID_NUS_TX_CHARACTERISTIC 0xC081                      /**< The UUID of the TX Characteristic. */
#define BLE_UUID_NUS_RX_CHARACTERISTIC 0xC082                      /**< The UUID of the RX Characteristic. */

Here is an additional image with infos, what i know about Simblee https://ibb.co/jDgfaG

As a result about this debug, i just setup something wrong. But what?

  • Ok, service discovered, characteristics discovered. But all characteristics with 0 UUID? Is it valid?

  • Not really but to be fair I don't use the modules you use for discovery so I have no idea what these writes mean. Go into your code and either push out more debugging info or debug yourself. I actually never understood benefit of using modules which you don't know how they work internally so then you are completely lost when you need to debug them because they don't work as you expect. GATT Service discovery is pretty easy thing writable directly in SD GATT API calls and events' handling especially if you are looking for single Service and single Characteristic.

  • The solution was:

    I deleted these rows from ble_nus_c.c, ble_nus_c_init function

    err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_ble_nus_c->uuid_type);
    VERIFY_SUCCESS(err_code);
    

    After that, the nRF51 discovered the services, but I do not know why the uuids were 0. So, I also modified the ble_nus_c_on_db_disc_evt fuction in ble_nus_c.c to the following:

    void ble_nus_c_on_db_disc_evt(ble_nus_c_t * p_ble_nus_c, ble_db_discovery_evt_t * p_evt)
    {
        ble_nus_c_evt_t nus_c_evt;
        memset(&nus_c_evt,0,sizeof(ble_nus_c_evt_t));
    
        ble_gatt_db_char_t * p_chars = p_evt->params.discovered_db.charateristics;
    
        // Check if the NUS was discovered.
        if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE)
        {
            uint32_t i;
    
            for (i = 0; i < p_evt->params.discovered_db.char_count; i++)
            {
    						if (i == 0) {
    								nus_c_evt.handles.nus_rx_handle = p_chars[i].characteristic.handle_value;
                    nus_c_evt.handles.nus_rx_cccd_handle = p_chars[i].cccd_handle;
    						
    						} else if (i == 1) {
    							nus_c_evt.handles.nus_tx_handle = p_chars[i].characteristic.handle_value;
    						}
            }
            if (p_ble_nus_c->evt_handler != NULL) 
            {
                nus_c_evt.conn_handle = p_evt->conn_handle;
                nus_c_evt.evt_type    = BLE_NUS_C_EVT_DISCOVERY_COMPLETE;
                p_ble_nus_c->evt_handler(p_ble_nus_c, &nus_c_evt);
            }
        }
    }
    

    And finally can send with ble_nus_c_string_send function and I get callback on receive at ble_nus_c_evt_handler function in main.c file (BLE_NUS_C_EVT_NUS_RX_EVT event).

Related