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

Heart Rate collector example - how is it suppose to work?

Hi, 

i'm running the Heart Rate collector example and have a question. What is the expected behaviour? From the description on the infocenter I read that it should print out the HR reading from the connected HRM. And while it does so the first time I run it on a fresh dongle, it doesn't do it the next time or any other time for that matter. I cannot figure out the difference and don't know what is going on. The following runs only print out the following info on the log:

00> <info> app_timer: RTC: initialized.
00> 
00> <info> app: Heart Rate collector example started.
00> 
00> <info> app: Starting scan.
00> 
00> <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update, no change
00> 
00> <info> app: Connected.
00> 
00> <info> app: GATT ATT MTU on connection 0x0 changed to 23.
00> 
00> <info> peer_manager_handler: Connection secured: role: Central, conn_handle: 0, procedure: Encryption
00> 
00> <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update, no change
00> 
00> <info> app: Data length for connection 0x0 updated to 27.
00> 
00> <info> peer_manager_handler: Connection secured: role: Central, conn_handle: 0, procedure: Encryption
00> 
00> <info> peer_manager_handler: Peer data updated in flash: peer_id: 0, data_id: Peer rank, action: Update, no change
00> 
00> <info> app: Battery Level Read as 85 %.

PS: I use the NRF52 dongle together with a j-link debugger and I'm displyaing the logs via RTT. I use the example from the SDK 17.0.2, with SD 340.

  • I removed the gatt files but it is still the same. Also I need to discovery process in my app.

    Anyway, can you try to explain why the services are recognized as insie the "Generic Attribute Profile"? They both are (body sensor location an heart rate). Looks like the dscovery process is wrong? When you view the HRM DUAL in nRF Connect BLE you can clearly see the structure of Services and I think it is in accordance to all standards.  

  • My suspicion is that Wireshark recognized the service wrongly. Note that what you see there is just the interpreting of wireshark. 
    That's why I suggest to find away to not doing service discovery. 

  • f you can find away to not do service discovery from the phone

    I'm not doing a service discovery from the phone. My setup is the following:

    1. NRF52840 dongle with the HRS_C demo (with modifications like removed gatt files, turned of paring and bonding, etc)

    2. NRF52840 dongle with sniffer app

    3. HRM Dual from Garmin

    4. PC with Wireshark to sniff the traffic

    The other setup, which works, is:

    1. PC with NRF Connect BLE application (and correspongin NRF52840 dongle)

    2,3,4 as above

    So, the discovery process is done by the HRS_C app. 

    Is there a way to modify it, so that it doesn't have to do service discovery and still connect to my HRM and enable notifications on it?

  • You can modify the HRS_C app to not doing service discovery (please look for the ble_db_discovery_start() function in the code) and then manually do a write request to handle 0x28 to enable CCCD notification. 

    On PC with nRF Connect BLE application it will do service discovery automatically. 

    Please note that the nRF52 dongle that corresponding to the NRF Connect BLE app also run the same softdevice as the hrs_c .

    So you can copy the whole procedure that the nRF Connect does to the HRM dual.

  • I can disable the ble_db_discovery_start, but I need a reference to "ble_hrs_c_t * p_hrs_c" to start ble_hrs_c_hrm_notif_enable and I only get in the hrs_c_evt_handler. How do I obtain it lets say in the ble_evt_handler function to start it after the HRM is connected?

    edit: I tried

    m_hrs_c.conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
    err_code = ble_hrs_c_hrm_notif_enable(&m_hrs_c);
    APP_ERROR_CHECK(err_code);

    But then I get:

    00> <info> app: Connected.
    00> 
    00> <debug> ble_hrs_c: Configuring CCCD. CCCD Handle = 0, Connection Handle = 0
    00> 
    00> <debug> nrf_ble_gq: Adding item to the request queue
    00> 
    00> <error> app: ERROR 7 [NRF_ERROR_INVALID_PARAM] at ..\..\..\main.c:275
    00> 
    00> PC at: 0x00038E73
    00> 
    00> <error> app: End of error report

    the 275th line in main is the 3rd line above(APP_ERROR_CHECK)

    edit2: some more debugging later...

    If I do:

    m_hrs_c.conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
    m_hrs_c.peer_hrs_db.hrm_cccd_handle = 0x28;
    m_hrs_c.peer_hrs_db.hrm_handle      = 0x27;
    err_code = ble_hrs_c_hrm_notif_enable(&m_hrs_c);
    APP_ERROR_CHECK(err_code);

    Then in nrf_ble_gq_item_add it fails in check:

    if ((p_req->type >= NRF_BLE_GQ_REQ_NUM) || (conn_id == p_gatt_queue->max_conns))

    The second condition is true (conn_id is 1).

    edit3: I've added 

    ret_code_t err_code = nrf_ble_gq_conn_handle_register(p_ble_hrs_c->p_gatt_queue, p_ble_hrs_c->conn_handle);
    VERIFY_SUCCESS(err_code);

    before nrf_ble_gq_item_add, and the program runs, but I'm missing a lot of data in the request.

    Can you help me fill this in?

Related