Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_API by
Revision 406:cec6778acc66, committed 2015-05-18
- Comitter:
- rgrover1
- Date:
- Mon May 18 09:54:27 2015 +0100
- Parent:
- 405:8fc6e6855806
- Child:
- 407:ca6b956b33d1
- Commit message:
- Synchronized with git rev aebfbce3
Author: Rohit Grover
redefine AdvertisementReportCallback_t in terms of AdvertisementCallbackParams_t.
This allows us to make use of FunctionPointerWithContext.
Changed in this revision
| public/BLEDevice.h | Show annotated file Show diff for this revision Revisions of this file |
| public/Gap.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/public/BLEDevice.h Mon May 18 09:54:27 2015 +0100
+++ b/public/BLEDevice.h Mon May 18 09:54:27 2015 +0100
@@ -269,7 +269,7 @@
* every advertisement report. Can be passed in as NULL, in which case
* scanning may not be enabled at all.
*/
- ble_error_t startScan(Gap::AdvertisementReportCallback_t callback);
+ ble_error_t startScan(void (*callback)(const Gap::AdvertisementCallbackParams_t *params));
/**
* Stop scanning. The current scanning parameters remain in effect.
@@ -783,7 +783,7 @@
}
inline ble_error_t
-BLEDevice::startScan(Gap::AdvertisementReportCallback_t callback) {
+BLEDevice::startScan(void (*callback)(const Gap::AdvertisementCallbackParams_t *params)) {
return transport->getGap().startScan(scanningParams, callback);
}
--- a/public/Gap.h Mon May 18 09:54:27 2015 +0100
+++ b/public/Gap.h Mon May 18 09:54:27 2015 +0100
@@ -21,6 +21,7 @@
#include "GapAdvertisingParams.h"
#include "GapEvents.h"
#include "CallChain.h"
+#include "FunctionPointerWithContext.h"
using namespace mbed;
@@ -152,12 +153,15 @@
typedef void (*LinkSecuredCallback_t)(Handle_t handle, SecurityMode_t securityMode);
typedef void (*PasskeyDisplayCallback_t)(Handle_t handle, const Passkey_t passkey);
- typedef void (*AdvertisementReportCallback_t)(const address_t peerAddr,
- int8_t rssi,
- bool isScanResponse,
- AdvertisementType_t type,
- uint8_t advertisingDataLen,
- const uint8_t *advertisingData);
+ struct AdvertisementCallbackParams_t {
+ Address_t peerAddr;
+ int8_t rssi;
+ bool isScanResponse;
+ AdvertisementType_t type;
+ uint8_t advertisingDataLen;
+ const uint8_t *advertisingData;
+ };
+ typedef FunctionPointerWithContext<const AdvertisementCallbackParams_t *> AdvertisementReportCallback_t;
friend class BLEDevice;
@@ -168,7 +172,7 @@
virtual ble_error_t setAdvertisingData(const GapAdvertisingData &, const GapAdvertisingData &) = 0;
virtual ble_error_t startAdvertising(const GapAdvertisingParams &) = 0;
virtual ble_error_t stopAdvertising(void) = 0;
- virtual ble_error_t startScan(const GapScanningParams &scanningParams, AdvertisementReportCallback_t callback) = 0;
+ virtual ble_error_t startScan(const GapScanningParams &scanningParams, void (*callback)(const AdvertisementCallbackParams_t *params)) = 0;
virtual ble_error_t stopScan() = 0;
virtual uint16_t getMinAdvertisingInterval(void) const = 0;
virtual uint16_t getMinNonConnectableAdvertisingInterval(void) const = 0;
@@ -322,9 +326,14 @@
AdvertisementType_t type,
uint8_t advertisingDataLen,
const uint8_t *advertisingData) {
- if (onAdvertisementReport) {
- onAdvertisementReport(peerAddr, rssi, isScanResponse, type, advertisingDataLen, advertisingData);
- }
+ AdvertisementCallbackParams_t params;
+ memcpy(params.peerAddr, peerAddr, ADDR_LEN);
+ params.rssi = rssi;
+ params.isScanResponse = isScanResponse;
+ params.type = type;
+ params.advertisingDataLen = advertisingDataLen;
+ params.advertisingData = advertisingData;
+ onAdvertisementReport.call(¶ms);
}
void processEvent(GapEvents::gapEvent_e type) {
