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

nRF51 to nRF52 migration, can't discover services

Hi. I have some nRF51 firmware I'm migrating to the nRF52. It's a peripheral with bunch of vendor specific services, using SDK 13.0.0 and SD 132 v4.0.2.

My code builds and runs and the device advertises OK. I can see it in the nRF Connect app for Android, and in my own Android app. But when I connect to it and try to discover services, nothing happens.

I've been through the migration guide (infocenter.nordicsemi.com/index.jsp and can't see anything I've missed.

How do I debug the service discovery/connection issue? How do I get logging out of the BLE sources in the SDK? There are no log flags for these in sdk_config.h.

The BLE_GAP_EVT_CONNECTED event is happening, I can see that much.

Edit: Adding two Wireshark captures, one when connecting from our custom Android app, the other when connecting from the nRF Connect Android app.

bike-tracker-nRF52-discovery-from-custom-android-app-2017-07.pcapng

bike-tracker-nRF52-discovery-from-nrf-connect-android-app-2017-07.pcapng

Edit: Adding two more Wireshark captures.

Capture 3: Connection from the nRF Connect Android app to our (Bike Tracker) peripheral app. Same as above, but another attempt at getting a good capture. Shows nothing but empty PDUs after the CONNECT_REQ in this case.

bike-tracker-nRF52-discovery-from-nrf-connect-android-app-2017-07-b.pcapng

Capture 4: Connection from the nRF Connect Android app to the ble_app_hrs example app in SDK 13.0.0. For comparison. Shows service discovery starting right after the connection.

ble_app_hrs-nRF52-discovery-from-nrf-connect-android-app-2017-07.pcapng

  • I don't see any problem from the peripheral side according to your sniffer trace. You may want to record another one. Also try to test with the SDK example for nRF52 for comparison.

  • @Hung Bui Added two more captures above. How do I get logging out of the BLE sources in the SDK? What next?

  • These two captures are targeting two advertisers each having different MAC address. Are you sure that one of them wasn't cached as GATT Server on mobile side in any previous encounter? Also advertising data look like you are using DFU nor HRS demo for comparison (shouldn't matter but it is confusing). Otherwise there is no obvious reason why should the phone (assuming it's the same device?) do GATT Service Discovery on one target and not on the other....

  • Do you have this function in your code ?

    /**@brief Function for initializing the GATT library. */
    void gatt_init(void)
    {
        ret_code_t err_code;
    
        err_code = nrf_ble_gatt_init(&s_Gatt, gatt_evt_handler);
        APP_ERROR_CHECK(err_code);
    
        err_code = nrf_ble_gatt_att_mtu_periph_set(&s_Gatt, 64);
        APP_ERROR_CHECK(err_code);
    }
    

    to be called in your ble initialization after gap_param_init

    #if (NRF_SD_BLE_API_VERSION > 3)
        gatt_init();
    #endif
    

    Could that be the problem ?

  • I have to go for caching as well - there's nothing on the nordic side in those traces, the connection has been made, the peripheral is responding on time when requested, it's the central which has sent out no single packet to ask any questions.

    @endnode to remove bonding on iPhone you just select the one device in the list and say 'forget this device', no need to remove all connections, I've done this a lot

    @eliot simple test - generate yourself a random MAC address before starting up the stack and set it, then test, if it's caching that'll prove it, if it's not I'm fairly out of ideas.

Related