Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
There is bug in last nRF51822 revision.
On disconnect event application level onDisconnect callback is not always called.
In library:
btle/btle.cpp
case BLE_GAP_EVT_DISCONNECTED: { Gap::Handle_t handle = p_ble_evt->evt.gap_evt.conn_handle; // Since we are not in a connection and have not started advertising, // store bonds nRF51Gap::getInstance().setConnectionHandle (BLE_CONN_HANDLE_INVALID); #if NEED_BOND_MANAGER /* disabled by default */ ASSERT_STATUS_RET_VOID ( ble_bondmngr_bonded_centrals_store()); #endif if (p_ble_evt->evt.gap_evt.params.disconnected.reason == BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION) { nRF51Gap::getInstance().processDisconnectionEvent(handle, Gap::LOCAL_HOST_TERMINATED_CONNECTION); } break; }But it needs to be changed to something like this:
btle/btle.cpp
case BLE_GAP_EVT_DISCONNECTED: { Gap::Handle_t handle = p_ble_evt->evt.gap_evt.conn_handle; // Since we are not in a connection and have not started advertising, // store bonds nRF51Gap::getInstance().setConnectionHandle (BLE_CONN_HANDLE_INVALID); #if NEED_BOND_MANAGER /* disabled by default */ ASSERT_STATUS_RET_VOID ( ble_bondmngr_bonded_centrals_store()); #endif if (p_ble_evt->evt.gap_evt.params.disconnected.reason == BLE_HCI_LOCAL_HOST_TERMINATED_CONNECTION) { nRF51Gap::getInstance().processDisconnectionEvent(handle, Gap::LOCAL_HOST_TERMINATED_CONNECTION); } else { nRF51Gap::getInstance().processDisconnectionEvent(handle, Gap::UNKNOWN_DISCONNECTION_REASON); } break; }And add UNKNOWN_DISCONNECTION_REASON in enum in BLE_API library:
public/Gap.h
enum DisconnectionReason_t { REMOTE_USER_TERMINATED_CONNECTION, CONN_INTERVAL_UNACCEPTABLE, LOCAL_HOST_TERMINATED_CONNECTION, UNKNOWN_DISCONNECTION_REASON, };