BLE disconnection

04 Dec 2015

Hi everybody,

I'm trying to detect in my BLE nano when a disconnection event happens So I try to use the syntax similar to connection

something like that

Quote:

MAIN CLASS

ble.onConnection(connectionCallback);

void connectionCallback(Gap::ConnectionCallbackParams_t *params) { it does what I want }

BLE CLASS

void onConnection(Gap::ConnectionEventCallback_t connectionCallback) { gap().onConnection(connectionCallback); }

So when I tried to do something to disconnection i uses

Quote:

MAIN CLASS

ble.onDisconnection(disconnectionCallback);

void disconnectionCallback(Gap::DisconnectionEventCallback_t callback ) {

}

So i check it out the BLE class and found

/**

  • Set up a callback for connection events. Refer to Gap::ConnectionEventCallback_t.
  • @note: This API is now *deprecated* and will be dropped in the future.
  • You should use the parallel API from Gap directly. A former call
  • to ble.onConnection(callback) should be replaced with
  • ble.gap().onConnection(callback).
  • / void onConnection(Gap::ConnectionEventCallback_t connectionCallback) { gap().onConnection(connectionCallback); } /
  • Append to a chain of callbacks to be invoked upon GAP disconnection.
  • @note: This API is now *deprecated* and will be dropped in the future.
  • You should use the parallel API from Gap directly. A former call
  • to ble.onDisconnection(callback) should be replaced with
  • ble.gap().onDisconnection(callback).
  • / void onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback) { gap().onDisconnection(disconnectionCallback); }

So I decided update my code using ble.gap().onDisconnetion(...) with the same function but still it doesn't work What can i do to solve the issue?

04 Dec 2015

Hi,

I don't understand the question completely. Are you saying that ble.onDisconnection() works but ble.gap().onDisconnection() doesn't work? They should both work because they are equivalent: https://github.com/ARMmbed/ble/blob/master/ble/BLE.h#L1193

Take a look at the HeartRate demo for a use of onDisconnection(): https://developer.mbed.org/teams/Bluetooth-Low-Energy/code/BLE_HeartRate/file/8b36a7c45cd2/main.cpp

04 Dec 2015

First thank for reply,

I know that ble.onDisconnection() is equal to ble.gap().onDisconnection() I see it inside BLE class. the problem is I was trying to uses BLE.onDisconnection() and then I read method deprecated but ble.OnDisconnection() doesn't work so I decided uses ble.gap().OnDisconnection() but It always appear the same error.

http://i66.tinypic.com/2a5j5tf.jpg

even using the function callback at HeartRate demo, which is the next:

void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
{
  
}

What i mean it's independent the function ble.gap() or ble I get the same error, I thought that was the function callback but I'm using the same at Heart Rate demo. So I don't know what i'm doing wrong

04 Dec 2015

All right, it was my bad.

I was changing the function but not its prototype.