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 * PackageLicenseDeclared: Apache-2.0
be_bryan 0:b74591d5ab33 3 * Copyright (c) 2016 ARM Limited
be_bryan 0:b74591d5ab33 4 *
be_bryan 0:b74591d5ab33 5 * Licensed under the Apache License, Version 2.0 (the "License");
be_bryan 0:b74591d5ab33 6 * you may not use this file except in compliance with the License.
be_bryan 0:b74591d5ab33 7 * You may obtain a copy of the License at
be_bryan 0:b74591d5ab33 8 *
be_bryan 0:b74591d5ab33 9 * http://www.apache.org/licenses/LICENSE-2.0
be_bryan 0:b74591d5ab33 10 *
be_bryan 0:b74591d5ab33 11 * Unless required by applicable law or agreed to in writing, software
be_bryan 0:b74591d5ab33 12 * distributed under the License is distributed on an "AS IS" BASIS,
be_bryan 0:b74591d5ab33 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
be_bryan 0:b74591d5ab33 14 * See the License for the specific language governing permissions and
be_bryan 0:b74591d5ab33 15 * limitations under the License.
be_bryan 0:b74591d5ab33 16 */
be_bryan 0:b74591d5ab33 17
be_bryan 0:b74591d5ab33 18 #ifndef _ARM_GATT_SERVER_H_
be_bryan 0:b74591d5ab33 19 #define _ARM_GATT_SERVER_H_
be_bryan 0:b74591d5ab33 20
be_bryan 0:b74591d5ab33 21 #include <stddef.h>
be_bryan 0:b74591d5ab33 22
be_bryan 0:b74591d5ab33 23 #include "blecommon.h"
be_bryan 0:b74591d5ab33 24 #include "GattServer.h"
be_bryan 0:b74591d5ab33 25 #include "generic/wsf_types.h"
be_bryan 0:b74591d5ab33 26 #include "att_api.h"
be_bryan 0:b74591d5ab33 27
be_bryan 0:b74591d5ab33 28 class ArmGattServer : public GattServer
be_bryan 0:b74591d5ab33 29 {
be_bryan 0:b74591d5ab33 30 public:
be_bryan 0:b74591d5ab33 31 static ArmGattServer &getInstance();
be_bryan 0:b74591d5ab33 32
be_bryan 0:b74591d5ab33 33 /* Functions that must be implemented from GattServer */
be_bryan 0:b74591d5ab33 34 virtual ble_error_t addService(GattService &);
be_bryan 0:b74591d5ab33 35
be_bryan 0:b74591d5ab33 36 virtual ble_error_t read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
be_bryan 0:b74591d5ab33 37 virtual ble_error_t read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP);
be_bryan 0:b74591d5ab33 38 virtual ble_error_t write(GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
be_bryan 0:b74591d5ab33 39 virtual ble_error_t write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t, const uint8_t[], uint16_t, bool localOnly = false);
be_bryan 0:b74591d5ab33 40
be_bryan 0:b74591d5ab33 41 virtual ble_error_t areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP);
be_bryan 0:b74591d5ab33 42 virtual ble_error_t areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP);
be_bryan 0:b74591d5ab33 43
be_bryan 0:b74591d5ab33 44 virtual bool isOnDataReadAvailable() const { return true; }
be_bryan 0:b74591d5ab33 45
be_bryan 0:b74591d5ab33 46 private:
be_bryan 0:b74591d5ab33 47 static void cccCback(attsCccEvt_t *pEvt);
be_bryan 0:b74591d5ab33 48 static void attCback(attEvt_t *pEvt);
be_bryan 0:b74591d5ab33 49 static uint8_t attsReadCback(dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, attsAttr_t *pAttr);
be_bryan 0:b74591d5ab33 50 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 51
be_bryan 0:b74591d5ab33 52 /*! client characteristic configuration descriptors settings */
be_bryan 0:b74591d5ab33 53 #define MAX_CCC_CNT 20
be_bryan 0:b74591d5ab33 54 attsCccSet_t cccSet[MAX_CCC_CNT];
be_bryan 0:b74591d5ab33 55 uint16_t cccValues[MAX_CCC_CNT];
be_bryan 0:b74591d5ab33 56 uint16_t cccHandles[MAX_CCC_CNT];
be_bryan 0:b74591d5ab33 57 uint8_t cccCnt;
be_bryan 0:b74591d5ab33 58
be_bryan 0:b74591d5ab33 59 private:
be_bryan 0:b74591d5ab33 60 ArmGattServer() : GattServer(), cccSet(), cccValues(), cccHandles(), cccCnt(0) {
be_bryan 0:b74591d5ab33 61 /* empty */
be_bryan 0:b74591d5ab33 62 }
be_bryan 0:b74591d5ab33 63
be_bryan 0:b74591d5ab33 64 ArmGattServer(const ArmGattServer &);
be_bryan 0:b74591d5ab33 65 const ArmGattServer& operator=(const ArmGattServer &);
be_bryan 0:b74591d5ab33 66 };
be_bryan 0:b74591d5ab33 67
be_bryan 0:b74591d5ab33 68 #endif /* _ARM_GATT_SERVER_H_ */