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

Multilink - sending data to many peers

Hello.
I'm working with multilink example and I've got some problem. I want to send data to specific peer device, but after restart central or one of the peer, they reconnects in different order.
So I made procedure to write peer address and conn_handle to my own structure while connecting. I'm doing it in:

  

static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)

After reconnecting and changing peer order I want to send data to peer via:

uint32_t ble_lbs_led_status_send(ble_lbs_c_t * p_ble_lbs_c, uint8_t status)

I'm going to to compare each address from my structure with new peer address, but....
Where I should find peer addresses assign after restart? I can catch them i while connection but where are they store after that?

Best regards 

PW

  • Addresses are not stored, unless you use bonding. If you do not want bonding, then you will have to store the addresses to flash yourself.

  • So in that case, I should probably check address while peer connect to central and assign it with right conn_handle. This conn_handle which was write in my "write procedure". And I'm little confused, because I don't know how does central device knows which peer to send data to? I thought that is address :)

  • The connection handle does not belong to a device, but an index of connections in the BLE controller(f.ex 0-7). Once a connection is broken the connection handle is released and it will be given to the next connection that is established. Since you cannot control which device connects in what order you cannot use the connection handle to identify a device once its connection is broken. Therefore you must use another set of information such as address, UUIDs, device name, RSSI, or Identity Resolving Key. 

    Most BLE devices uses a static address and in that case the address is permanent and therefore an excellent method of identifying a device.

    However there are some devices that has a revolving address that is changed after its connection is broken, in that case you need to get its Identity Resolving Key in order to identify the device(new address each time you connect to it). This privacy mode is used by devices that does not want to be tracked by 3rd parties. 

  • Most BLE devices uses a static address and in that case the address is permanent and therefore an excellent method of identifying a device.

    I'm going to use devices with static address. So should I do it as I write in my first answer? I don't have another idea like assign reconnecting device to appropriate conn_handle accordingly with my structere which was create in my "write procedure" (write procedure: made one time, enabled by button, write address and conn_handle in flash). My idea follows from ble_app_multilink_central example, where I have to point at: "p_ble_lbs_c " to send data. Maybe there is a better method?

  • That might work, why don't you write some sudo code and show us?

Related