8 years, 6 months ago.

Issue with onConnect callback function

This is how I am setting the onConnection call back in my code.

ble.gap().onConnection(aConnectionCallback);

This is the signature of my onConnection call back following the code for ConnectionCallbackParams_t in Gap.h :

void aConnectionCallback(Gap::Handle_t handleIn, Gap::Role_t roleIn, Gap::AddressType_t peerAddrTypeIn, const uint8_t *peerAddrIn, Gap::AddressType_t ownAddrTypeIn, const uint8_t *ownAddrIn, const Gap::ConnectionParams_t *connectionParamsIn)

And I get this error:

Error: Argument of type "void (*)(Gap::Handle_t, Gap::Role_t, Gap::AddressType_t, const std::uint8_t *, Gap::AddressType_t, const std::uint8_t *, const Gap::ConnectionParams_t *)" is incompatible with parameter of type "Gap::ConnectionEventCallback_t"

Would someone tell me what exactly should be the signature for the callback?

Question relating to:

Bluetooth Low Energy (a.k.a Bluetooth LE, BTLE, Bluetooth Smart)

1 Answer

8 years, 6 months ago.

refer to https://github.com/ARMmbed/ble/blob/master/ble/Gap.h#L145. A connection callback is expected to take a pointer to a const Gap::ConnectionEventCallback_t.

please refer to connectionCallback() in https://developer.mbed.org/teams/Bluetooth-Low-Energy/code/BLE_LEDBlinker/file/507318f2afda/main.cpp for a sample use.