Caching the advertising data and the scan response.
Fork of MaximBLE by
MaximGattServer.h@0:b562096246b3, 2016-03-03 (annotated)
- Committer:
- enginerd
- Date:
- Thu Mar 03 14:13:21 2016 +0000
- Revision:
- 0:b562096246b3
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_GATT_SERVER_H_ |
enginerd | 0:b562096246b3 | 35 | #define _MAXIM_GATT_SERVER_H_ |
enginerd | 0:b562096246b3 | 36 | |
enginerd | 0:b562096246b3 | 37 | #include <stddef.h> |
enginerd | 0:b562096246b3 | 38 | |
enginerd | 0:b562096246b3 | 39 | #include "ble/blecommon.h" |
enginerd | 0:b562096246b3 | 40 | #include "ble/GattServer.h" |
enginerd | 0:b562096246b3 | 41 | #include "wsf_types.h" |
enginerd | 0:b562096246b3 | 42 | #include "att_api.h" |
enginerd | 0:b562096246b3 | 43 | |
enginerd | 0:b562096246b3 | 44 | class MaximGattServer : public GattServer |
enginerd | 0:b562096246b3 | 45 | { |
enginerd | 0:b562096246b3 | 46 | public: |
enginerd | 0:b562096246b3 | 47 | static MaximGattServer &getInstance(); |
enginerd | 0:b562096246b3 | 48 | |
enginerd | 0:b562096246b3 | 49 | /* Functions that must be implemented from GattServer */ |
enginerd | 0:b562096246b3 | 50 | virtual ble_error_t addService(GattService &); |
enginerd | 0:b562096246b3 | 51 | |
enginerd | 0:b562096246b3 | 52 | virtual ble_error_t read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP); |
enginerd | 0:b562096246b3 | 53 | virtual ble_error_t read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP); |
enginerd | 0:b562096246b3 | 54 | virtual ble_error_t write(GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false); |
enginerd | 0:b562096246b3 | 55 | virtual ble_error_t write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false); |
enginerd | 0:b562096246b3 | 56 | |
enginerd | 0:b562096246b3 | 57 | virtual ble_error_t areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP); |
enginerd | 0:b562096246b3 | 58 | virtual ble_error_t areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP); |
enginerd | 0:b562096246b3 | 59 | |
enginerd | 0:b562096246b3 | 60 | virtual bool isOnDataReadAvailable() const { return true; } |
enginerd | 0:b562096246b3 | 61 | |
enginerd | 0:b562096246b3 | 62 | private: |
enginerd | 0:b562096246b3 | 63 | static void cccCback(attsCccEvt_t *pEvt); |
enginerd | 0:b562096246b3 | 64 | static void attCback(attEvt_t *pEvt); |
enginerd | 0:b562096246b3 | 65 | static uint8_t attsReadCback(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, attsAttr_t *pAttr); |
enginerd | 0:b562096246b3 | 66 | static uint8_t attsWriteCback(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, uint16_t len, uint8_t *pValue, attsAttr_t *pAttr); |
enginerd | 0:b562096246b3 | 67 | |
enginerd | 0:b562096246b3 | 68 | /*! client characteristic configuration descriptors settings */ |
enginerd | 0:b562096246b3 | 69 | #define MAX_CCC_CNT 20 |
enginerd | 0:b562096246b3 | 70 | attsCccSet_t cccSet[MAX_CCC_CNT]; |
enginerd | 0:b562096246b3 | 71 | uint16_t cccValues[MAX_CCC_CNT]; |
enginerd | 0:b562096246b3 | 72 | uint16_t cccHandles[MAX_CCC_CNT]; |
enginerd | 0:b562096246b3 | 73 | uint8_t cccCnt; |
enginerd | 0:b562096246b3 | 74 | |
enginerd | 0:b562096246b3 | 75 | private: |
enginerd | 0:b562096246b3 | 76 | MaximGattServer() : GattServer(), cccSet(), cccValues(), cccHandles(), cccCnt(0) { |
enginerd | 0:b562096246b3 | 77 | /* empty */ |
enginerd | 0:b562096246b3 | 78 | } |
enginerd | 0:b562096246b3 | 79 | |
enginerd | 0:b562096246b3 | 80 | MaximGattServer(const MaximGattServer &); |
enginerd | 0:b562096246b3 | 81 | const MaximGattServer& operator=(const MaximGattServer &); |
enginerd | 0:b562096246b3 | 82 | }; |
enginerd | 0:b562096246b3 | 83 | |
enginerd | 0:b562096246b3 | 84 | #endif /* _MAXIM_GATT_SERVER_H_ */ |