BLE Library with custom services for the tortuga bike
Fork of BLE_API by
BikeDeviceInformationService.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef __BLE_DEVICE_INFORMATION_SERVICE_H__ 00018 #define __BLE_DEVICE_INFORMATION_SERVICE_H__ 00019 00020 #include "ble/BLE.h" 00021 00022 /** 00023 * @class DeviceInformationService 00024 * @brief BLE Device Information Service 00025 * Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.device_information.xml 00026 * Manufacturer Name String Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.manufacturer_name_string.xml 00027 */ 00028 class DeviceInformationService { 00029 public: 00030 /** 00031 * @brief Device Information Service Constructor: copies device-specific information 00032 * into the BLE stack. 00033 * 00034 * @param[ref] _ble 00035 * BLE object for the underlying controller. 00036 * @param[in] manufacturersName 00037 * The name of the manufacturer of the device. 00038 * @param[in] modelNumber 00039 * The model number that is assigned by the device vendor. 00040 * @param[in] serialNumber 00041 * The serial number for a particular instance of the device. 00042 * @param[in] hardwareRevision 00043 * The hardware revision for the hardware within the device. 00044 * @param[in] firmwareRevision 00045 * The device's firmware version. 00046 * @param[in] softwareRevision 00047 * The device's software version. 00048 */ 00049 DeviceInformationService(BLE &_ble, 00050 const char *manufacturersName = "unknown", 00051 const char *modelNumber = "unknown", 00052 const char *serialNumber = "unknown", 00053 const char *hardwareRevision = "unknown", 00054 const char *firmwareRevision = "unknown", 00055 const char *softwareRevision = "unknown") : 00056 ble(_ble), 00057 manufacturersNameStringCharacteristic(/*GattCharacteristic::UUID_MANUFACTURER_NAME_STRING_CHAR*/0x3101, 00058 (uint8_t *)manufacturersName, 00059 strlen(manufacturersName), /* Min length */ 00060 strlen(manufacturersName), /* Max length */ 00061 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), 00062 modelNumberStringCharacteristic(/*GattCharacteristic::UUID_MODEL_NUMBER_STRING_CHAR*/0x3102, 00063 (uint8_t *)modelNumber, 00064 strlen(modelNumber), /* Min length */ 00065 strlen(modelNumber), /* Max length */ 00066 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), 00067 serialNumberStringCharacteristic(/*GattCharacteristic::UUID_SERIAL_NUMBER_STRING_CHAR*/0x3103, 00068 (uint8_t *)serialNumber, 00069 strlen(serialNumber), /* Min length */ 00070 strlen(serialNumber), /* Max length */ 00071 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), 00072 hardwareRevisionStringCharacteristic(/*GattCharacteristic::UUID_HARDWARE_REVISION_STRING_CHAR*/0x3104, 00073 (uint8_t *)hardwareRevision, 00074 strlen(hardwareRevision), /* Min length */ 00075 strlen(hardwareRevision), /* Max length */ 00076 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), 00077 firmwareRevisionStringCharacteristic(/*GattCharacteristic::UUID_FIRMWARE_REVISION_STRING_CHAR*/0x3105, 00078 (uint8_t *)firmwareRevision, 00079 strlen(firmwareRevision), /* Min length */ 00080 strlen(firmwareRevision), /* Max length */ 00081 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ), 00082 softwareRevisionStringCharacteristic(/*GattCharacteristic::UUID_SOFTWARE_REVISION_STRING_CHAR*/0x3106, 00083 (uint8_t *)softwareRevision, 00084 strlen(softwareRevision), /* Min length */ 00085 strlen(softwareRevision), /* Max length */ 00086 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ) 00087 { 00088 00089 GattCharacteristic *charTable[] = {&manufacturersNameStringCharacteristic, 00090 &modelNumberStringCharacteristic, 00091 &serialNumberStringCharacteristic, 00092 &hardwareRevisionStringCharacteristic, 00093 &firmwareRevisionStringCharacteristic, 00094 &softwareRevisionStringCharacteristic}; 00095 GattService deviceInformationService(/*GattService::UUID_DEVICE_INFORMATION_SERVICE*/0x3100, charTable, 00096 sizeof(charTable) / sizeof(GattCharacteristic *)); 00097 00098 ble.addService(deviceInformationService); 00099 } 00100 00101 protected: 00102 BLE &ble; 00103 00104 //ReadOnlyGattCharacteristic manufacturersNameStringCharacteristic; 00105 00106 GattCharacteristic manufacturersNameStringCharacteristic; 00107 GattCharacteristic modelNumberStringCharacteristic; 00108 GattCharacteristic serialNumberStringCharacteristic; 00109 GattCharacteristic hardwareRevisionStringCharacteristic; 00110 GattCharacteristic firmwareRevisionStringCharacteristic; 00111 GattCharacteristic softwareRevisionStringCharacteristic; 00112 }; 00113 00114 #endif /* #ifndef __BLE_DEVICE_INFORMATION_SERVICE_H__*/
Generated on Tue Jul 12 2022 21:14:55 by
1.7.2
