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

ble heart rate monitor device connects but no data

Hello,

Apologies as I'm very new to C and I may be missing something obvious. I have an actual ble Heart Rate device which I wish to connect to my pca10028 (nrf51422_xxAC.

I am using the example code from the following path.

C:\nordic\examples\ble_central\ble_apps_hrs_c\pca10028\s130\arm5_no_packs\ble_apps_hrs_c_s130_pca10028uvprojx

I've added the necessary files to get SEGGER_RTT_printf to send data to J-Link so I know where the program has execute. It appears the device connects to hrt successfully as it stops advertising.

This line in code fires suggesting it's found the device:

   if(extracted_uuid == TARGET_UUID)
                    {	SEGGER_RTT_printf(0,"uuids match %d",TARGET_UUID);

and this line executes to suggest it had bonded

  // Initiate bonding.
            err_code = dm_security_setup_req(&m_dm_device_handle);
            APP_ERROR_CHECK(err_code);
						
            m_peer_count++;

            if (m_peer_count < MAX_PEER_COUNT)
            {
                scan_start();
            }
            APPL_LOG("[APPL]: << DM_EVT_CONNECTION\r\n");
						SEGGER_RTT_printf(0,"bonded %d", err_code);

But the Heart Rate Collector Handler or Battery Level Collector Handler never fire. So the last output I get on j-link is "bonded0"

Any help would be greatly appreciated.

UPDATE: I've replaced all logging information with SEGGER_RTT and this is the output. Disconnection happens after a minute or so

 0> Heart rate collector example
 0> sd_ble_enable: RAM START at 0x20001EB0
 0> [DM]: >> dm_init.
 0> [DM]: Storage handle 0x0003F800.
 0> [DM]: >> dm_register.
 0> [DM]: Application Instance allocated.
 0> [DM]: Created whitelist, number of IRK = 0x00, number of addr = 0x00
 0> 	[APPL]: 180D
 0> [DM]:[00]: Connection Instance Allocated.
 0> [APPL]: >> DM_EVT_CONNECTION
 0> [DM]: >> dm_security_setup_req
 0> [DM]: Allocated device instance 0x00
 0> [DM]: Initiating authentication request
 0> [APPL]: << DM_EVT_CONNECTION
 0> [DM]: >> BLE_GAP_EVT_AUTH_STATUS, status 00000085
 0> [APPL]: >> DM_EVT_SECURITY_SETUP_COMPLETE
 0> [APPL]: << DM_EVT_SECURITY_SETUP_COMPLETE
 0> [DM]: Disconnect Reason 0x0013
 0> [APPL]: >> DM_EVT_DISCONNECTION
 0> [DM]: >> dm_whitelist_create
 0> [DM]: Created whitelist, number of IRK = 0x00, number of addr = 0x00
 0> [APPL]: << DM_EVT_DISCONNECTION
 0> [DM]:[00]: Freed connection instance.
  • Hi PaulR, I'm a user of similar software using an mBed sample code (BLE_HeartRate) left for users on the mBed website...up until yesterday I could connect and if the connection stayed up for more than a second, the device started running thru the sample code loop that repeated:

        hrmCounter++;
    
            if (hrmCounter == 175) { //  100 <= HRM bps <=175
    
                hrmCounter = 100;
    

    line 97-100, hrmCounter was initialized on line 30 as 100.

    It would repeat so you'd get a series of these reading seen on the smart phone generating a saw-tooth like output.

    It took me about a week to get use to the smart phone required sequence of screen touches and I eventually changed the advertise rate from 1000 (1 second) to 100 so when the phone searched, it would find HRM1 faster.

    Hope this helps

  • Hi Tim,

    Thank you for taking the time to respond. Unfortunately I'm trying to setup the NRF as a Central BLE role to connect to an off the shelf heart rate monitor that acts as a peripheral. So essentially I'm trying to do things the other way around from what you have achieved.

    Interesting to discover the mBed resource, although currently their API doesn't support programming the device as a Central role . developer.mbed.org/.../

    Paul

  • Okay so I've got it working finally. I'm not convinced this hack is the correct solution but it works. It seems like it was failing on securing the connection so in main.c I changed the switch statement as below:

    switch (p_event->event_id)
    

    so that the case of DM_EVT_LINK_SECURED and DM_EVT_SECURITY_SETUP_COMPLETE have their code blocks switched over. Which implies that the link never gets secured but is complete, atleast then the heart rate and battery notifications start to come through.

    case DM_EVT_LINK_SECURED:
    {
        SEGGER_RTT_printf(0,"[APPL]: >> DM_EVT_SECURITY_SETUP_COMPLETE\r\n");
        SEGGER_RTT_printf(0,"[APPL]: << DM_EVT_SECURITY_SETUP_COMPLETE\r\n");
        break;
    }
    
    case DM_EVT_SECURITY_SETUP_COMPLETE:
        SEGGER_RTT_printf(0,"[APPL]: >> DM_LINK_SECURED_IND\r\n");
        // Discover peer's services. 
        err_code = ble_db_discovery_start(&m_ble_db_discovery,
                                          p_event->event_param.p_gap_param->conn_handle);
        APP_ERROR_CHECK(err_code);
        SEGGER_RTT_printf(0,"[APPL]: << DM_LINK_SECURED_IND\r\n");
        break;
    

    Heart rate values take a few seconds to come online. J-Logger output below :

     0> Heart rate collector example
     0> sd_ble_enable: RAM START at 0x20001EB0
     0> [DM]: >> dm_init.
     0> [DM]: Storage handle 0x0003F800.
     0> [DM]: >> dm_register.
     0> [DM]: Application Instance allocated.
     0> initializing HRCinitializing HRC error code 0initializing HR battery error code 0j[DM]: >> dm_whitelist_create
     0> [DM]: Created whitelist, number of IRK = 0x00, number of addr = 0x00
     0> 	[APPL]: 180D
     0> [DM]:[00]: Connection Instance Allocated.
     0> [APPL]: >> DM_EVT_CONNECTION
     0> [DM]: >> dm_security_setup_req
     0> [DM]: Allocated device instance 0x00
     0> [DM]: Initiating authentication request
     0> [APPL]: << DM_EVT_CONNECTION
     0> [DM]: >> BLE_GAP_EVT_AUTH_STATUS, status 00000085
     0> [APPL]: >> DM_LINK_SECURED_IND
     0> [DB]: Starting discovery of service with UUID 0x180D for Connection handle 0
     0> [APPL]: << DM_LINK_SECURED_IND
     0> Found service UUID 0x180D
     0> [DB]: Discovery of service with UUID 0x180D completed with success for Connectionhandle 0
     0> [DB]: Starting discovery of service with UUID 0x180F for Connection handle 0
     0> Found service UUID 0x180F
     0> [HRS_C]: received HVX on handle 0x12, hrm_handle 0x12
     0> [APPL]: HR Measurement received 0 
     0> Heart Rate = 0
     0> Heart Rate = 0
    
Related