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
Diff: public/Gap.h
- Revision:
- 139:baaf1c5f0db2
- Parent:
- 135:6cf6e7bd21c9
- Child:
- 140:407d134c179d
--- a/public/Gap.h Fri Nov 21 09:23:23 2014 +0000 +++ b/public/Gap.h Fri Nov 21 09:23:24 2014 +0000 @@ -17,7 +17,6 @@ #ifndef __GAP_H__ #define __GAP_H__ -#include "mbed.h" #include "blecommon.h" #include "GapAdvertisingData.h" #include "GapAdvertisingParams.h" @@ -41,7 +40,6 @@ } addr_type_t; static const unsigned ADDR_LEN = 6; - typedef uint8_t address_t[ADDR_LEN]; /** * enumeration for disconnection reasons. The values for these reasons are @@ -65,55 +63,48 @@ typedef uint16_t Handle_t; typedef struct { - uint16_t minConnectionInterval; /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/ - uint16_t maxConnectionInterval; /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/ - uint16_t slaveLatency; /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/ - uint16_t connectionSupervisionTimeout; /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/ + uint16_t minConnectionInterval; /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/ + uint16_t maxConnectionInterval; /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/ + uint16_t slaveLatency; /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/ + uint16_t connectionSupervisionTimeout; /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/ } ConnectionParams_t; - static const uint16_t UNIT_1_25_MS = 1250; /**< Number of microseconds in 1.25 milliseconds. */ - static uint16_t MSEC_TO_GAP_DURATION_UNITS(uint32_t durationInMillis) { - return (durationInMillis * 1000) / UNIT_1_25_MS; - } - public: /* These functions must be defined in the sub-class */ - virtual ble_error_t setAddress(addr_type_t type, const address_t address) = 0; - virtual ble_error_t getAddress(addr_type_t *typeP, address_t address) = 0; + virtual ble_error_t setAddress(addr_type_t type, const uint8_t address[ADDR_LEN]) = 0; + virtual ble_error_t getAddress(addr_type_t *typeP, uint8_t address[ADDR_LEN]) = 0; 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 disconnect(DisconnectionReason_t reason) = 0; - virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params) = 0; - virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params) = 0; - virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params) = 0; + virtual ble_error_t startAdvertising(const GapAdvertisingParams &) = 0; + virtual ble_error_t stopAdvertising(void) = 0; + virtual ble_error_t disconnect(DisconnectionReason_t reason) = 0; + virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params) = 0; + virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params) = 0; + virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params) = 0; - virtual ble_error_t setDeviceName(const uint8_t *deviceName) = 0; + virtual ble_error_t setDeviceName(const uint8_t *deviceName) = 0; virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP) = 0; - virtual ble_error_t setAppearance(uint16_t appearance) = 0; - virtual ble_error_t getAppearance(uint16_t *appearanceP) = 0; + virtual ble_error_t setAppearance(uint16_t appearance) = 0; + virtual ble_error_t getAppearance(uint16_t *appearanceP) = 0; typedef void (*EventCallback_t)(void); - typedef void (*ConnectionEventCallback_t)(Handle_t, addr_type_t peerAddrType, const address_t peerAddr, const ConnectionParams_t *); + typedef void (*ConnectionEventCallback_t)(Handle_t, const ConnectionParams_t *); typedef void (*DisconnectionEventCallback_t)(Handle_t, DisconnectionReason_t); /* Event callback handlers */ void setOnTimeout(EventCallback_t callback) { onTimeout = callback; } - void setOnConnection(ConnectionEventCallback_t callback) { onConnection = callback; } - void setOnDisconnection(DisconnectionEventCallback_t callback) { onDisconnection = callback; } - void processConnectionEvent(Handle_t handle, addr_type_t type, const address_t addr, const ConnectionParams_t *params) { + void processConnectionEvent(Handle_t handle, const ConnectionParams_t *params) { state.connected = 1; if (onConnection) { - onConnection(handle, type, addr, params); + onConnection(handle, params); } } @@ -145,7 +136,7 @@ } protected: - GapState_t state; + GapState_t state; private: EventCallback_t onTimeout;