setup Gap::onConnection()
This commit is contained in:
parent
42d440b3ce
commit
692fe6d445
2 changed files with 21 additions and 13 deletions
19
public/BLE.h
19
public/BLE.h
|
@ -1066,7 +1066,18 @@ public:
|
|||
gap().onTimeout(timeoutCallback);
|
||||
}
|
||||
|
||||
void onConnection(Gap::ConnectionEventCallback_t connectionCallback);
|
||||
/**
|
||||
* Setup 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 GattServer 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to setup a callback for GAP disconnection.
|
||||
*/
|
||||
|
@ -1167,12 +1178,6 @@ typedef BLE BLEDevice; /* DEPRECATED. This type alias is retained for the sake o
|
|||
/* BLE methods. Most of these simply forward the calls to the underlying
|
||||
* transport.*/
|
||||
|
||||
inline void
|
||||
BLE::onConnection(Gap::ConnectionEventCallback_t connectionCallback)
|
||||
{
|
||||
gap().setOnConnection(connectionCallback);
|
||||
}
|
||||
|
||||
inline void
|
||||
BLE::onDisconnection(Gap::DisconnectionEventCallback_t disconnectionCallback)
|
||||
{
|
||||
|
|
15
public/Gap.h
15
public/Gap.h
|
@ -255,7 +255,7 @@ public:
|
|||
* @param scanParams
|
||||
* Paramters to be used while scanning for the peer.
|
||||
* @return BLE_ERROR_NONE if connection establishment procedure is started
|
||||
* successfully. The onConnection callback (if set) will be invoked upon
|
||||
* successfully. The connectionCallback (if set) will be invoked upon
|
||||
* a connection event.
|
||||
*/
|
||||
virtual ble_error_t connect(const Address_t peerAddr,
|
||||
|
@ -760,7 +760,10 @@ public:
|
|||
*/
|
||||
void onTimeout(TimeoutEventCallback_t callback) {timeoutCallback = callback;}
|
||||
|
||||
void setOnConnection(ConnectionEventCallback_t callback) {onConnection = callback;}
|
||||
/**
|
||||
* Setup a callback for connection events. Refer to ConnectionEventCallback_t.
|
||||
*/
|
||||
void onConnection(ConnectionEventCallback_t callback) {connectionCallback = callback;}
|
||||
|
||||
/**
|
||||
* Set the application callback for disconnection events.
|
||||
|
@ -827,7 +830,7 @@ protected:
|
|||
_scanResponse(),
|
||||
state(),
|
||||
timeoutCallback(NULL),
|
||||
onConnection(NULL),
|
||||
connectionCallback(NULL),
|
||||
onDisconnection(NULL),
|
||||
onRadioNotification(),
|
||||
onSecuritySetupInitiated(),
|
||||
|
@ -850,9 +853,9 @@ public:
|
|||
const Address_t ownAddr,
|
||||
const ConnectionParams_t *connectionParams) {
|
||||
state.connected = 1;
|
||||
if (onConnection) {
|
||||
if (connectionCallback) {
|
||||
ConnectionCallbackParams_t callbackParams(handle, role, peerAddrType, peerAddr, ownAddrType, ownAddr, connectionParams);
|
||||
onConnection(&callbackParams);
|
||||
connectionCallback(&callbackParams);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -926,7 +929,7 @@ protected:
|
|||
|
||||
protected:
|
||||
TimeoutEventCallback_t timeoutCallback;
|
||||
ConnectionEventCallback_t onConnection;
|
||||
ConnectionEventCallback_t connectionCallback;
|
||||
DisconnectionEventCallback_t onDisconnection;
|
||||
RadioNotificationEventCallback_t onRadioNotification;
|
||||
SecuritySetupInitiatedCallback_t onSecuritySetupInitiated;
|
||||
|
|
Loading…
Reference in a new issue