This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

BLE connection handle value scope

I would like to use connection handle value as index to an array which store some per connection specific data. Some questions about connection handle:

  1. is connection handle value allocated by SD continuous?

  2. Suppose 6 connections has been established, and then one of them disconnected. Will this handle value be re-used to next built connection, or just abandoned?

Thanks in advance.

Parents
  • Hi,

    I have heard this idea before, but there are some pitfalls:

    Q1: Not necessarily. It is continuous as long as no devices disconnects. I.e. the first device will get handle 0, device number 2 gets handle 1, and so on. But if the first device disconnects, then device number 3 might get handle 0 again. Furthermore, due to the supervision timeout mechanism, it might in some cases take some time before the Softdevice detects that a device has lost its connection. And if the same device then tries to reconnect quickly (before the supervision timeout occurs) it might get assigned a new connection handle. Hence, it is actually possible that the same device has two connection handles at the same time, although only until the supervision timeout occurs.

    Q2: Yes, the Softdevice will reuse connection handles, and a particular device will not necessarily get the same connection handle value on every connection.

    Another solution to individually identify connected devices is to bond all your devices. Or you can use other information like e.g MAC addresses.

  • Martin, Probably i did not describe the question clearly. The root issue behind it is when there are multiple peer devices connecting at the same time to the same service/characteristic, I need to distinguish the data from different devices, so i can handle them differently, say, forward to different buffer for further processing.

    Using conn handle indexing seems OK except it has to go through a lookup table given it is not continuous which may consume some CPU cycles, when there is more connection number.

    So in this case i am not sure if bonding will help as in service write event seems no bonding information available help faster device indexing.

    Is there any better way to do this?

    thanks.

Reply
  • Martin, Probably i did not describe the question clearly. The root issue behind it is when there are multiple peer devices connecting at the same time to the same service/characteristic, I need to distinguish the data from different devices, so i can handle them differently, say, forward to different buffer for further processing.

    Using conn handle indexing seems OK except it has to go through a lookup table given it is not continuous which may consume some CPU cycles, when there is more connection number.

    So in this case i am not sure if bonding will help as in service write event seems no bonding information available help faster device indexing.

    Is there any better way to do this?

    thanks.

Children
No Data
Related