Test
Embed:
(wiki syntax)
Show/hide line numbers
TOFService.h
00001 #ifndef __BLE_TOF_SERVICE_H__ 00002 #define __BLE_TOF_SERVICE_H__ 00003 00004 #include "ble/BLE.h" 00005 00006 class TOFService { 00007 public: 00008 const static uint16_t TOF_CHAR_ARRAY_SIZE = 100; 00009 const static uint16_t CUSTOM_TOF_SERVICE_UUID = 0xA000; 00010 const static uint16_t TOF_CHAR_WRITE_CHARACTERISTIC_UUID = 0xA001; 00011 00012 TOFService(BLE& _ble) : 00013 ble(_ble), 00014 writeCharArrayCharacteristic(TOF_CHAR_WRITE_CHARACTERISTIC_UUID, writeBuffer) 00015 { 00016 static bool serviceAdded = false; 00017 if (serviceAdded) { 00018 return; 00019 } 00020 00021 GattCharacteristic *charTable[] = {&writeCharArrayCharacteristic}; 00022 00023 GattService TOFService(CUSTOM_TOF_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); 00024 00025 ble.gattServer().addService(TOFService); 00026 serviceAdded = true; 00027 } 00028 00029 GattAttribute::Handle_t getValueHandle() const { 00030 return writeCharArrayCharacteristic.getValueHandle(); 00031 } 00032 00033 private: 00034 BLE& ble; 00035 00036 uint8_t writeBuffer[TOF_CHAR_ARRAY_SIZE]; 00037 00038 WriteOnlyArrayGattCharacteristic<uint8_t, sizeof(writeBuffer)> writeCharArrayCharacteristic; 00039 }; 00040 00041 #endif /* #ifndef __BLE_TOF_SERVICE_H__*/
Generated on Sun Jul 17 2022 16:37:42 by
1.7.2