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

Issues on implementing DIS client on multilink central

Hi all,

I'm trying to writing a device information service client on top of ble_app_multilink_central example on nRF52830 using SDK14.1.0 and softdevice 5.0 and have a big trouble getting it works.

I have defined only one instance do m_db_disc as on this link.

But it is very strange that the end_handle reported on BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP is invalid (65536). The UUID looks fine (0x180A) and start_handle returned is 17. Also, it can scan the UUIDs of all the characteristics. But it doesn't feel right to have an end_handle 65536.

Another issue is that the discovery stops on discovering the descriptors for the second service. If I call lbs_init_c() first, I could get the discovery success message on debug log for LBS. If I call the dis_init_c() first, then I could have a successful discovery for DIS but LBS stuck at descriptor discovery. The code is broken somewhere in descriptors_discover() in ble_db_discovery.c but I cannot pinpoint the exact location yet.

Any help and comment is very much appreciated and thanks in advance!

Arthur

ble_dis_c.c ble_dis_c.h Makefile sdk_config.h ble_db_discovery.c main.c ble_app_blinky_dis.zip

  • Yes, I have added the DIS service to the ble_app_blinky example. The modified codes are uploaded in the file ble_app_blinky_dis.zip.

  • Thanks. I have been able to reproduce, but I'm not 100 % sure what is going on. Looking into it.

  • I think this is happening because you have dis_c_init_obj.evt_handler = NULL; in dis_c_init() in main.c and when the discovery is complete the application jumps to an invalid address.

    I also think that there should be something like

    VERIFY_PARAM_NOT_NULL(p_ble_lbs_c_init->evt_handler);

    in ble_dis_c_init() like it is in ble_lbs_c_init().

    Try doing dis_c_init_obj.evt_handler = dis_c_evt_handler; and something like:

    /**@brief Handles events coming from the DIS central module.
     *
     * @param[in] p_dis_c     The instance of DIS_C that triggered the event.
     * @param[in] p_dis_c_evt The DIS_C event.
     */
    static void dis_c_evt_handler(ble_dis_c_t * p_lbs_c, ble_dis_c_evt_t * p_dis_c_evt)
    {
        switch (p_dis_c_evt->evt_type)
        {
            case BLE_DIS_C_EVT_DISCOVERY_COMPLETE:
            {
    
                NRF_LOG_INFO("DIS service discovered on conn_handle 0x%x",
                             p_dis_c_evt->conn_handle);
    
            } break; // BLE_DIS_C_EVT_DISCOVERY_COMPLETE
            default:
                // No implementation needed.
                break;
        }
    }
    
  • Hi Petter,

    Thank you for your help. The fix does keep it running and the LBS works fine. However, I still see two issues even it doesn't break.

    First, the end_handle for DIS is still invalid. Second, I still see a failure message (I cannot find out where the code located yet). Below is the log I've got.

    app: Multilink example started.

    app: Start scanning for device name Nordic_Blinky.

    app: Connection 0x0 established, starting DB discovery.

    ble_db_disc: Starting discovery of service with UUID 0x1523 on connection handle 0x0.

    app: Start scanning for device name Nordic_Blinky.

    ble_db_disc: Found service UUID 0x1523.

    ble_db_disc: primary srv discovery rsp uuid 1523 handle: start B end 16

    ble_db_disc: entering descriptors_discover()

    ble_db_disc: leaving descriptors_discover() - return code

    ble_db_disc: entering descriptors_discover()

    ble_db_disc: leaving descriptors_discover() - success

    ble_db_disc: Discovery of service with UUID 0x1523 completed with success on connection handle 0x0.

    ble_db_disc: Starting discovery of service with UUID 0x180A on connection handle 0x0.

    ble_db_disc: Found service UUID 0x180A.

    ble_db_disc: primary srv discovery rsp uuid 180A handle: start 11 end 65535

    ble_db_disc: entering descriptors_discover()

    ble_db_disc: leaving descriptors_discover() - return code

    ble_db_disc: Discovery of service with UUID 0x180A completed with success on connection handle 0x0.

    app: call to ble_lbs_on_db_disc_evt for instance 0 and link 0x0!

    ble_lbs_c: Led Button Service discovered at peer.

    app: LED Button service discovered on conn_handle 0x0

    ble_lbs_c: Configuring CCCD. CCCD Handle = 14, Connection Handle = 0

    ble_lbs_c: SD Read/Write API returns Success..

    ble_dis_c: Device Information Service discovery failure .

    app: BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST.

    ble_lbs_c: writing LED status 0x1

    ble_lbs_c: SD Read/Write API returns Success..

    app: LBS write LED state 1

    ble_lbs_c: writing LED status 0x0

    ble_lbs_c: SD Read/Write API returns Success..

    app: LBS write LED state 0

    app: Link 0x0, Button state changed on peer to 0x1

    app: Link 0x0, Button state changed on peer to 0x0

  • Sorry for the late reply, I have had the flu for some days now. Have you solved this? The end handle of primary service discovery response being 0xFFFF shouldn't be a problem, it is normal. It is not used for anything is it?

    If you haven't solved it, I will try to look into the fault. Let me know.

Related