Lightly modified version of the BLE stack, that doesn't bring up a DFUService by default... as we have our own.
Fork of BLE_API by
Revision 380:2109a08c311c, committed 2015-05-13
- Comitter:
- rgrover1
- Date:
- Wed May 13 08:51:07 2015 +0100
- Parent:
- 379:b379d350aaab
- Child:
- 381:12cb29d3cea4
- Commit message:
- Synchronized with git rev 06529208
Author: Rohit Grover
add AdvertisementType_t
Changed in this revision
--- a/public/BLEDevice.h Wed May 13 08:51:07 2015 +0100 +++ b/public/BLEDevice.h Wed May 13 08:51:07 2015 +0100 @@ -20,6 +20,7 @@ #include "blecommon.h" #include "Gap.h" #include "GattServer.h" +#include "GapScanningParams.h" #include "BLEDeviceInstanceBase.h" /** @@ -232,6 +233,36 @@ ble_error_t stopAdvertising(void); /** + * Setup parameters for GAP scanning--i.e. observer mode. + * @param interval Scan interval (in milliseconds) [valid values lie between 2.5ms and 10.24s]. + * @param window Scan Window (in milliseconds) [valid values lie between 2.5ms and 10.24s]. + * @param timeout Scan timeout (in seconds) between 0x0001 and 0xFFFF, 0x0000 disables timeout. + */ + ble_error_t setScanningParams(uint16_t interval = GapScanningParams::SCAN_INTERVAL_MAX, + uint16_t window = GapScanningParams::SCAN_WINDOW_MAX, + uint16_t timeout = 0); + ble_error_t setScanningInterval(uint16_t interval); + ble_error_t setScanningWindow(uint16_t window); + ble_error_t setScanningTimeout(uint16_t timeout); + + /** + * Start scanning (Observer Procedure) based on the scan-params currently + * in effect. + * + * @param callback The application callback to be invoked upon receiving + * every advertisement report. Can be passed in as NULL, in which case + * scanning may not be enabled at all. + */ + ble_error_t startScanning(Gap::AdvertisementReportCallback_t callback); + + /** + * Stop scanning. The current scanning parameters remain in effect. + * + * @retval BLE_ERROR_NONE if successfully stopped scanning procedure. + */ + ble_error_t stopScanning(void); + + /** * This call initiates the disconnection procedure, and its completion will * be communicated to the application with an invocation of the * onDisconnection callback. @@ -544,6 +575,8 @@ * eventually result in a call to the target's setAdvertisingData() before * the server begins advertising. This flag marks the status of the pending update.*/ bool needToSetAdvPayload; + + GapScanningParams scanningParams; }; /* BLEDevice methods. Most of these simply forward the calls to the underlying
--- a/public/Gap.h Wed May 13 08:51:07 2015 +0100 +++ b/public/Gap.h Wed May 13 08:51:07 2015 +0100 @@ -38,6 +38,13 @@ typedef uint8_t Address_t[ADDR_LEN]; /* 48-bit address, LSB format. */ typedef Address_t address_t; /* @Note: deprecated. */ + enum AdvertisementType_t { + ADV_IND = 0x00, /**< Connectable undirected. */ + ADV_DIRECT_IND = 0x01, /**< Connectable directed. */ + ADV_SCAN_IND = 0x02, /**< Scannable undirected. */ + ADV_NONCONN_IND = 0x03, /**< Non connectable undirected. */ + }; + /** * Enumeration for disconnection reasons. The values for these reasons are * derived from Nordic's implementation; but the reasons are meant to be @@ -143,6 +150,13 @@ 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 *advertisingDataLenPtr, + const uint8_t **advertisingDataPtr); + friend class BLEDevice; private:
--- a/public/GapScanningParams.h Wed May 13 08:51:07 2015 +0100 +++ b/public/GapScanningParams.h Wed May 13 08:51:07 2015 +0100 @@ -45,7 +45,7 @@ } void setInterval(uint16_t newInterval) {_interval = newInterval;} - void setWindow(uint16_t newInterval) {_window = newWindow; } + void setWindow(uint16_t newWindow) {_window = newWindow; } void setTimeout(uint16_t newTimeout) {_timeout = newTimeout; } uint16_t getInterval(void) const {return _interval;}