mbed-os

Dependents:   cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more

Committer:
be_bryan
Date:
Mon Dec 11 17:54:04 2017 +0000
Revision:
0:b74591d5ab33
motor ++

Who changed what in which revision?

UserRevisionLine numberNew contents of line
be_bryan 0:b74591d5ab33 1 /*******************************************************************************
be_bryan 0:b74591d5ab33 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
be_bryan 0:b74591d5ab33 3 *
be_bryan 0:b74591d5ab33 4 * Permission is hereby granted, free of charge, to any person obtaining a
be_bryan 0:b74591d5ab33 5 * copy of this software and associated documentation files (the "Software"),
be_bryan 0:b74591d5ab33 6 * to deal in the Software without restriction, including without limitation
be_bryan 0:b74591d5ab33 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
be_bryan 0:b74591d5ab33 8 * and/or sell copies of the Software, and to permit persons to whom the
be_bryan 0:b74591d5ab33 9 * Software is furnished to do so, subject to the following conditions:
be_bryan 0:b74591d5ab33 10 *
be_bryan 0:b74591d5ab33 11 * The above copyright notice and this permission notice shall be included
be_bryan 0:b74591d5ab33 12 * in all copies or substantial portions of the Software.
be_bryan 0:b74591d5ab33 13 *
be_bryan 0:b74591d5ab33 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
be_bryan 0:b74591d5ab33 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
be_bryan 0:b74591d5ab33 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
be_bryan 0:b74591d5ab33 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
be_bryan 0:b74591d5ab33 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
be_bryan 0:b74591d5ab33 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
be_bryan 0:b74591d5ab33 20 * OTHER DEALINGS IN THE SOFTWARE.
be_bryan 0:b74591d5ab33 21 *
be_bryan 0:b74591d5ab33 22 * Except as contained in this notice, the name of Maxim Integrated
be_bryan 0:b74591d5ab33 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
be_bryan 0:b74591d5ab33 24 * Products, Inc. Branding Policy.
be_bryan 0:b74591d5ab33 25 *
be_bryan 0:b74591d5ab33 26 * The mere transfer of this software does not imply any licenses
be_bryan 0:b74591d5ab33 27 * of trade secrets, proprietary technology, copyrights, patents,
be_bryan 0:b74591d5ab33 28 * trademarks, maskwork rights, or any other form of intellectual
be_bryan 0:b74591d5ab33 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
be_bryan 0:b74591d5ab33 30 * ownership rights.
be_bryan 0:b74591d5ab33 31 *******************************************************************************
be_bryan 0:b74591d5ab33 32 */
be_bryan 0:b74591d5ab33 33
be_bryan 0:b74591d5ab33 34 #ifndef _MAXIM_GATT_SERVER_H_
be_bryan 0:b74591d5ab33 35 #define _MAXIM_GATT_SERVER_H_
be_bryan 0:b74591d5ab33 36
be_bryan 0:b74591d5ab33 37 #include <stddef.h>
be_bryan 0:b74591d5ab33 38
be_bryan 0:b74591d5ab33 39 #include "ble/blecommon.h"
be_bryan 0:b74591d5ab33 40 #include "ble/GattServer.h"
be_bryan 0:b74591d5ab33 41 #include "wsf_types.h"
be_bryan 0:b74591d5ab33 42 #include "att_api.h"
be_bryan 0:b74591d5ab33 43
be_bryan 0:b74591d5ab33 44 class MaximGattServer : public GattServer
be_bryan 0:b74591d5ab33 45 {
be_bryan 0:b74591d5ab33 46 public:
be_bryan 0:b74591d5ab33 47 static MaximGattServer &getInstance();
be_bryan 0:b74591d5ab33 48
be_bryan 0:b74591d5ab33 49 /* Functions that must be implemented from GattServer */
be_bryan 0:b74591d5ab33 50 virtual ble_error_t addService(GattService &);
be_bryan 0:b74591d5ab33 51
be_bryan 0:b74591d5ab33 52 virtual ble_error_t read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
be_bryan 0:b74591d5ab33 53 virtual ble_error_t read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
be_bryan 0:b74591d5ab33 54 virtual ble_error_t write(GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
be_bryan 0:b74591d5ab33 55 virtual ble_error_t write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
be_bryan 0:b74591d5ab33 56
be_bryan 0:b74591d5ab33 57 virtual ble_error_t areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP);
be_bryan 0:b74591d5ab33 58 virtual ble_error_t areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP);
be_bryan 0:b74591d5ab33 59
be_bryan 0:b74591d5ab33 60 virtual bool isOnDataReadAvailable() const { return true; }
be_bryan 0:b74591d5ab33 61
be_bryan 0:b74591d5ab33 62 private:
be_bryan 0:b74591d5ab33 63 static void cccCback(attsCccEvt_t *pEvt);
be_bryan 0:b74591d5ab33 64 static void attCback(attEvt_t *pEvt);
be_bryan 0:b74591d5ab33 65 static uint8_t attsReadCback(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, attsAttr_t *pAttr);
be_bryan 0:b74591d5ab33 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);
be_bryan 0:b74591d5ab33 67
be_bryan 0:b74591d5ab33 68 /*! client characteristic configuration descriptors settings */
be_bryan 0:b74591d5ab33 69 #define MAX_CCC_CNT 20
be_bryan 0:b74591d5ab33 70 attsCccSet_t cccSet[MAX_CCC_CNT];
be_bryan 0:b74591d5ab33 71 uint16_t cccValues[MAX_CCC_CNT];
be_bryan 0:b74591d5ab33 72 uint16_t cccHandles[MAX_CCC_CNT];
be_bryan 0:b74591d5ab33 73 uint8_t cccCnt;
be_bryan 0:b74591d5ab33 74
be_bryan 0:b74591d5ab33 75 private:
be_bryan 0:b74591d5ab33 76 MaximGattServer() : GattServer(), cccSet(), cccValues(), cccHandles(), cccCnt(0) {
be_bryan 0:b74591d5ab33 77 /* empty */
be_bryan 0:b74591d5ab33 78 }
be_bryan 0:b74591d5ab33 79
be_bryan 0:b74591d5ab33 80 MaximGattServer(const MaximGattServer &);
be_bryan 0:b74591d5ab33 81 const MaximGattServer& operator=(const MaximGattServer &);
be_bryan 0:b74591d5ab33 82 };
be_bryan 0:b74591d5ab33 83
be_bryan 0:b74591d5ab33 84 #endif /* _MAXIM_GATT_SERVER_H_ */