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

Pairing(bonding) data communication PROBLEM

Hi, every developers,

I am testing the example of ble_app_hrs_c and ble_app_hrs using 2 nRF52840 (in SDK 15.3.0 VERSION).

My goal is that data communication with two DK in pairing state. The data to be sent is not a heart rate or a battery level but a string or byte data sequence.

I have chosen two examples that support bonding via pm_manager, but I am having difficulty using the function to send and receive data.

I tried to use pm_peer_data_load () and pm_peer_data_store () functions, but calling both functions will cause a connection security error.

ERROR : <info> peer_manager_handler: Connection security failed: role: Central, conn_handle: 0x0, procedure: Encryption, error: 4102

I declare the function PEER_ID and function usage of two functions as follows.

pm_peer_id_t p_peer_id;

ret_code_t error_code = pm_peer_id_get(m_conn_handle,&p_peer_id);

pm_store_token_t * p_token;
void const * p_data;
p_data = "TESTING";

pm_peer_data_store(p_peer_id,PM_PEER_DATA_ID_BONDING,p_data, 20, p_token);

Could someone help me with the proper use of the two functions or with the function to send and receive data in the BONDING state?

Thank you.

Parents
  • The number 4102 (0x1006) indicates that you got the error PM_CONN_SEC_ERROR_PIN_OR_KEY_MISSING, which means that encryption failed because  the peripheral has lost the LTK for this bond.

    Try erasing the flash of both chips through nrfjprog --eraseall, then build, program and run the examples once again. I think this will make the devices able to bond successfully.

    Best regards,

    Simon

  • Thank you for your response. Yes, as you say, through nrfjprog --eraseall, the error is gone, so it does.

    Do you know anything about functions that send and receive data?

  • sjheo said:
    Do you know anything about functions that send and receive data?

     Could you elaborate more?

    Best regards,

    Simon

  • Hi, Simon

    I want the two modules to be paired via the peer manager to send and receive data.

    However, the two functions mentioned in the text (pm_peer_data_load and pm_peer_data_store) that update and retrieve the data received from the peer, not related to transport the data.

    So, I asked if you know about the functions that send and receive data from the two paired modules. 

    In the multilink_central example, do I need to send data to paired peers like the lbs(Led Button Service) handler?

    Thank you.

  • The functions pm_peer_data_load() and pm_peer_data_store() are not use to send/receive data between the devices (central and peripheral). The functions are used to store information in flash memory, like bonding information, GATT data and address resolution.

    In order to send data from a server (e.g. ble_app_hrs) to a client (e.g. ble_app_hrs_c) over BLE, you have to notify the data (attribute value). This can be done by using the function sd_ble_gatts_hvx() in ble_gatts.h

    In order to send data from a client to a server over BLE, you have to write the data (e.g. a characteristic value). This can be done by using the function sd_ble_gattc_write() in ble_gattc.h.

    Best regards,

    Simon

Reply
  • The functions pm_peer_data_load() and pm_peer_data_store() are not use to send/receive data between the devices (central and peripheral). The functions are used to store information in flash memory, like bonding information, GATT data and address resolution.

    In order to send data from a server (e.g. ble_app_hrs) to a client (e.g. ble_app_hrs_c) over BLE, you have to notify the data (attribute value). This can be done by using the function sd_ble_gatts_hvx() in ble_gatts.h

    In order to send data from a client to a server over BLE, you have to write the data (e.g. a characteristic value). This can be done by using the function sd_ble_gattc_write() in ble_gattc.h.

    Best regards,

    Simon

Children
Related