sandeepmistry / arduino-BLEPeripheral

An Arduino library for creating custom BLE peripherals with Nordic Semiconductor's nRF8001 or nR51822.
MIT License
464 stars 180 forks source link

nRF8001: Dynamic data not saved unless disconnected from central #135

Open prossel opened 7 years ago

prossel commented 7 years ago

Symptoms

Using with RedBearLab BLE Shield v 2.1 on Arduino Uno, the peripheral cannot reconnect after first successful connection. Unless is it disconnected first from central without being powered down. That is the only way I have found to trigger the save of dynamic data in EEPROM.

To reproduce

More information

To make it work, after connecting to the central, use the Bluetooth menu to disconnect the HIDKeyboard or turn off Bluetooth. Do not power off the Arduino. When the connection is lost on Arduino, we can see in the serial monitor that the dynamic data is read (from the shield) and stored to EEPROM (to see these messages, on has to activate debug traces in nRF8001.cpp, search for #define NRF_8001_DEBUG).

I wonder why theses dynamic data is only saved when the peripheral is disconnected from host and not when the bond is successfully established. Also I don't see the ACI_EVT_BOND_STATUS message come when the peripheral is connected (and bond) for the first time.

sandeepmistry commented 7 years ago

@prossel this is a limitation of the nRF8001 as far as I understand.

Let me know if you have any ideas on how we can avoid this.

prossel commented 7 years ago

I would suggest to try requesting the dynamic data after the connection has been successfully established, without waiting for the central to disconnect. Maybe nRF8001 support could help find a way.

sandeepmistry commented 7 years ago

I would suggest to try requesting the dynamic data after the connection has been successfully established, without waiting for the central to disconnect.

@prossel I don't think this is possible, have you tried it out yourself. If so, please submit a PR.

prossel commented 7 years ago

@sandeepmistry I tried but with no success.

sandeepmistry commented 7 years ago

Ok, we'll just leave this issue open to track it as a known limitation.