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.
Parents
  • 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
    
Reply
  • 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
    
Children
No Data
Related