Caching the advertising data and the scan response.
Fork of MaximBLE by
MaximGap.h@0:b562096246b3, 2016-03-03 (annotated)
- Committer:
- enginerd
- Date:
- Thu Mar 03 14:13:21 2016 +0000
- Revision:
- 0:b562096246b3
- Child:
- 1:4e764337d5c5
Initial commit of Maxim Integrated Bluetooth LE Library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
enginerd | 0:b562096246b3 | 1 | /******************************************************************************* |
enginerd | 0:b562096246b3 | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
enginerd | 0:b562096246b3 | 3 | * |
enginerd | 0:b562096246b3 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
enginerd | 0:b562096246b3 | 5 | * copy of this software and associated documentation files (the "Software"), |
enginerd | 0:b562096246b3 | 6 | * to deal in the Software without restriction, including without limitation |
enginerd | 0:b562096246b3 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
enginerd | 0:b562096246b3 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
enginerd | 0:b562096246b3 | 9 | * Software is furnished to do so, subject to the following conditions: |
enginerd | 0:b562096246b3 | 10 | * |
enginerd | 0:b562096246b3 | 11 | * The above copyright notice and this permission notice shall be included |
enginerd | 0:b562096246b3 | 12 | * in all copies or substantial portions of the Software. |
enginerd | 0:b562096246b3 | 13 | * |
enginerd | 0:b562096246b3 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
enginerd | 0:b562096246b3 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
enginerd | 0:b562096246b3 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
enginerd | 0:b562096246b3 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
enginerd | 0:b562096246b3 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
enginerd | 0:b562096246b3 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
enginerd | 0:b562096246b3 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
enginerd | 0:b562096246b3 | 21 | * |
enginerd | 0:b562096246b3 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
enginerd | 0:b562096246b3 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
enginerd | 0:b562096246b3 | 24 | * Products, Inc. Branding Policy. |
enginerd | 0:b562096246b3 | 25 | * |
enginerd | 0:b562096246b3 | 26 | * The mere transfer of this software does not imply any licenses |
enginerd | 0:b562096246b3 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
enginerd | 0:b562096246b3 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
enginerd | 0:b562096246b3 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
enginerd | 0:b562096246b3 | 30 | * ownership rights. |
enginerd | 0:b562096246b3 | 31 | ******************************************************************************* |
enginerd | 0:b562096246b3 | 32 | */ |
enginerd | 0:b562096246b3 | 33 | |
enginerd | 0:b562096246b3 | 34 | #ifndef _MAXIM_GAP_H_ |
enginerd | 0:b562096246b3 | 35 | #define _MAXIM_GAP_H_ |
enginerd | 0:b562096246b3 | 36 | |
enginerd | 0:b562096246b3 | 37 | #include "mbed.h" |
enginerd | 0:b562096246b3 | 38 | #include "ble/blecommon.h" |
enginerd | 0:b562096246b3 | 39 | #include "ble/GapAdvertisingParams.h" |
enginerd | 0:b562096246b3 | 40 | #include "ble/GapAdvertisingData.h" |
enginerd | 0:b562096246b3 | 41 | #include "ble/Gap.h" |
enginerd | 0:b562096246b3 | 42 | #include "ble/GapScanningParams.h" |
enginerd | 0:b562096246b3 | 43 | #include "dm_api.h" |
enginerd | 0:b562096246b3 | 44 | #include "att_api.h" |
enginerd | 0:b562096246b3 | 45 | |
enginerd | 0:b562096246b3 | 46 | /**************************************************************************/ |
enginerd | 0:b562096246b3 | 47 | /*! |
enginerd | 0:b562096246b3 | 48 | \brief |
enginerd | 0:b562096246b3 | 49 | |
enginerd | 0:b562096246b3 | 50 | */ |
enginerd | 0:b562096246b3 | 51 | /**************************************************************************/ |
enginerd | 0:b562096246b3 | 52 | class MaximGap : public Gap |
enginerd | 0:b562096246b3 | 53 | { |
enginerd | 0:b562096246b3 | 54 | public: |
enginerd | 0:b562096246b3 | 55 | static MaximGap &getInstance(); |
enginerd | 0:b562096246b3 | 56 | |
enginerd | 0:b562096246b3 | 57 | /* Functions that must be implemented from Gap */ |
enginerd | 0:b562096246b3 | 58 | virtual ble_error_t setAddress(AddressType_t type, const Address_t address); |
enginerd | 0:b562096246b3 | 59 | virtual ble_error_t getAddress(AddressType_t *typeP, Address_t address); |
enginerd | 0:b562096246b3 | 60 | virtual ble_error_t setAdvertisingData(const GapAdvertisingData &, const GapAdvertisingData &); |
enginerd | 0:b562096246b3 | 61 | |
enginerd | 0:b562096246b3 | 62 | #define BLE_GAP_ADV_INTERVAL_MIN 0x0020 /**< Minimum Advertising interval in 625 us units, i.e. 20 ms. */ |
enginerd | 0:b562096246b3 | 63 | #define BLE_GAP_ADV_NONCON_INTERVAL_MIN 0x00A0 /**< Minimum Advertising interval in 625 us units for non connectable mode, i.e. 100 ms. */ |
enginerd | 0:b562096246b3 | 64 | #define BLE_GAP_ADV_INTERVAL_MAX 0x4000 /**< Maximum Advertising interval in 625 us units, i.e. 10.24 s. */ |
enginerd | 0:b562096246b3 | 65 | |
enginerd | 0:b562096246b3 | 66 | virtual uint16_t getMinAdvertisingInterval(void) const { return BLE_GAP_ADV_INTERVAL_MIN; } |
enginerd | 0:b562096246b3 | 67 | virtual uint16_t getMinNonConnectableAdvertisingInterval(void) const { return BLE_GAP_ADV_NONCON_INTERVAL_MIN; } |
enginerd | 0:b562096246b3 | 68 | virtual uint16_t getMaxAdvertisingInterval(void) const { return BLE_GAP_ADV_INTERVAL_MAX; } |
enginerd | 0:b562096246b3 | 69 | |
enginerd | 0:b562096246b3 | 70 | virtual ble_error_t startAdvertising(const GapAdvertisingParams &); |
enginerd | 0:b562096246b3 | 71 | virtual ble_error_t stopAdvertising(void); |
enginerd | 0:b562096246b3 | 72 | virtual ble_error_t disconnect(Handle_t connectionHandle, DisconnectionReason_t reason); |
enginerd | 0:b562096246b3 | 73 | virtual ble_error_t disconnect(DisconnectionReason_t reason); |
enginerd | 0:b562096246b3 | 74 | |
enginerd | 0:b562096246b3 | 75 | virtual ble_error_t setDeviceName(const uint8_t *deviceName); |
enginerd | 0:b562096246b3 | 76 | virtual ble_error_t getDeviceName(uint8_t *deviceName, unsigned *lengthP); |
enginerd | 0:b562096246b3 | 77 | virtual ble_error_t setAppearance(GapAdvertisingData::Appearance appearance); |
enginerd | 0:b562096246b3 | 78 | virtual ble_error_t getAppearance(GapAdvertisingData::Appearance *appearanceP); |
enginerd | 0:b562096246b3 | 79 | |
enginerd | 0:b562096246b3 | 80 | virtual ble_error_t setTxPower(int8_t txPower); |
enginerd | 0:b562096246b3 | 81 | virtual void getPermittedTxPowerValues(const int8_t **valueArrayPP, size_t *countP); |
enginerd | 0:b562096246b3 | 82 | |
enginerd | 0:b562096246b3 | 83 | void setConnectionHandle(uint16_t m_connectionHandle); |
enginerd | 0:b562096246b3 | 84 | uint16_t getConnectionHandle(void); |
enginerd | 0:b562096246b3 | 85 | |
enginerd | 0:b562096246b3 | 86 | virtual ble_error_t getPreferredConnectionParams(ConnectionParams_t *params); |
enginerd | 0:b562096246b3 | 87 | virtual ble_error_t setPreferredConnectionParams(const ConnectionParams_t *params); |
enginerd | 0:b562096246b3 | 88 | virtual ble_error_t updateConnectionParams(Handle_t handle, const ConnectionParams_t *params); |
enginerd | 0:b562096246b3 | 89 | |
enginerd | 0:b562096246b3 | 90 | virtual ble_error_t startRadioScan(const GapScanningParams &scanningParams); |
enginerd | 0:b562096246b3 | 91 | virtual ble_error_t stopScan(void); |
enginerd | 0:b562096246b3 | 92 | |
enginerd | 0:b562096246b3 | 93 | void advertisingStopped(void); |
enginerd | 0:b562096246b3 | 94 | |
enginerd | 0:b562096246b3 | 95 | private: |
enginerd | 0:b562096246b3 | 96 | uint16_t m_connectionHandle; |
enginerd | 0:b562096246b3 | 97 | addr_type_t m_type; |
enginerd | 0:b562096246b3 | 98 | MaximGap() { |
enginerd | 0:b562096246b3 | 99 | m_connectionHandle = DM_CONN_ID_NONE; |
enginerd | 0:b562096246b3 | 100 | m_type = ADDR_TYPE_RANDOM_STATIC; |
enginerd | 0:b562096246b3 | 101 | } |
enginerd | 0:b562096246b3 | 102 | |
enginerd | 0:b562096246b3 | 103 | MaximGap(MaximGap const &); |
enginerd | 0:b562096246b3 | 104 | void operator=(MaximGap const &); |
enginerd | 0:b562096246b3 | 105 | }; |
enginerd | 0:b562096246b3 | 106 | |
enginerd | 0:b562096246b3 | 107 | #endif /* _MAXIM_GAP_H_ */ |