I've finished to read the OCF specification, and as far as I understand for the bridge, each discovered device is associated to a virtual OCF device.
I would like to bridge some bluetooth devices.
So I discover them, pair them (here I think I missed something. How do we pair a bluetooth device that requires a pin?), and then I create a device using oc_add_device() with its associated resources.
So far so good.
But I need to know the "index" of this new virtual device. (currently I have a counter incremented each time I add a device)
However, if the bluetooth device is removed, there is no oc_remove_device() function.... and this will also need the oc_add_device function to return the index too.
Looking at the code, I see that the oc_add_device() just add a device struct to an array (static or dynamically allocated).
The index is then used everywhere to reference this device.
Maybe a simple solution is to:
1- change the implementation to have to look into the array for a free slot, and associate the index.
2- return this index
3- add oc_remove_device(int index), taking care of de-registering properly the associated resources (or return an error and let the user remove the resources first before calling this function)
I have the feeling that it will not be that easy, so here I am asking you what you think?
Thank you for you help!