prova invio BLE

Dependents:   BLE_HeartRate_IDB04A1

Fork of BLE_API by Bluetooth Low Energy

Committer:
vcoubard
Date:
Wed Apr 06 19:14:27 2016 +0100
Revision:
1152:1c10f851f4f9
Parent:
1151:575efbdcc905
Child:
1155:e28c7aac64ab
Synchronized with git rev c8c30b27
Author: Andres Amaya Garcia
Fix doxygen warnings in DeviceInformationService.h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vcoubard 1151:575efbdcc905 1 /* mbed Microcontroller Library
vcoubard 1151:575efbdcc905 2 * Copyright (c) 2006-2013 ARM Limited
vcoubard 1151:575efbdcc905 3 *
vcoubard 1151:575efbdcc905 4 * Licensed under the Apache License, Version 2.0 (the "License");
vcoubard 1151:575efbdcc905 5 * you may not use this file except in compliance with the License.
vcoubard 1151:575efbdcc905 6 * You may obtain a copy of the License at
vcoubard 1151:575efbdcc905 7 *
vcoubard 1151:575efbdcc905 8 * http://www.apache.org/licenses/LICENSE-2.0
vcoubard 1151:575efbdcc905 9 *
vcoubard 1151:575efbdcc905 10 * Unless required by applicable law or agreed to in writing, software
vcoubard 1151:575efbdcc905 11 * distributed under the License is distributed on an "AS IS" BASIS,
vcoubard 1151:575efbdcc905 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
vcoubard 1151:575efbdcc905 13 * See the License for the specific language governing permissions and
vcoubard 1151:575efbdcc905 14 * limitations under the License.
vcoubard 1151:575efbdcc905 15 */
vcoubard 1151:575efbdcc905 16
vcoubard 1151:575efbdcc905 17 #ifndef __BLE_DEVICE_INFORMATION_SERVICE_H__
vcoubard 1151:575efbdcc905 18 #define __BLE_DEVICE_INFORMATION_SERVICE_H__
vcoubard 1151:575efbdcc905 19
vcoubard 1151:575efbdcc905 20 #include "ble/BLE.h"
vcoubard 1151:575efbdcc905 21
vcoubard 1151:575efbdcc905 22 /**
vcoubard 1151:575efbdcc905 23 * @class DeviceInformationService
vcoubard 1151:575efbdcc905 24 * @brief BLE Device Information Service
vcoubard 1151:575efbdcc905 25 * Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.device_information.xml
vcoubard 1151:575efbdcc905 26 * Manufacturer Name String Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.manufacturer_name_string.xml
vcoubard 1151:575efbdcc905 27 */
vcoubard 1151:575efbdcc905 28 class DeviceInformationService {
vcoubard 1151:575efbdcc905 29 public:
vcoubard 1151:575efbdcc905 30 /**
vcoubard 1151:575efbdcc905 31 * @brief Device Information Service Constructor: copies device-specific information
vcoubard 1151:575efbdcc905 32 * into the BLE stack.
vcoubard 1151:575efbdcc905 33 *
vcoubard 1152:1c10f851f4f9 34 * @param[in] _ble
vcoubard 1152:1c10f851f4f9 35 * A reference to a BLE object for the underlying controller.
vcoubard 1151:575efbdcc905 36 * @param[in] manufacturersName
vcoubard 1151:575efbdcc905 37 * The name of the manufacturer of the device.
vcoubard 1151:575efbdcc905 38 * @param[in] modelNumber
vcoubard 1151:575efbdcc905 39 * The model number that is assigned by the device vendor.
vcoubard 1151:575efbdcc905 40 * @param[in] serialNumber
vcoubard 1151:575efbdcc905 41 * The serial number for a particular instance of the device.
vcoubard 1151:575efbdcc905 42 * @param[in] hardwareRevision
vcoubard 1151:575efbdcc905 43 * The hardware revision for the hardware within the device.
vcoubard 1151:575efbdcc905 44 * @param[in] firmwareRevision
vcoubard 1151:575efbdcc905 45 * The device's firmware version.
vcoubard 1151:575efbdcc905 46 * @param[in] softwareRevision
vcoubard 1151:575efbdcc905 47 * The device's software version.
vcoubard 1151:575efbdcc905 48 */
vcoubard 1151:575efbdcc905 49 DeviceInformationService(BLE &_ble,
vcoubard 1151:575efbdcc905 50 const char *manufacturersName = NULL,
vcoubard 1151:575efbdcc905 51 const char *modelNumber = NULL,
vcoubard 1151:575efbdcc905 52 const char *serialNumber = NULL,
vcoubard 1151:575efbdcc905 53 const char *hardwareRevision = NULL,
vcoubard 1151:575efbdcc905 54 const char *firmwareRevision = NULL,
vcoubard 1151:575efbdcc905 55 const char *softwareRevision = NULL) :
vcoubard 1151:575efbdcc905 56 ble(_ble),
vcoubard 1151:575efbdcc905 57 manufacturersNameStringCharacteristic(GattCharacteristic::UUID_MANUFACTURER_NAME_STRING_CHAR,
vcoubard 1151:575efbdcc905 58 (uint8_t *)manufacturersName,
vcoubard 1151:575efbdcc905 59 (manufacturersName != NULL) ? strlen(manufacturersName) : 0, /* Min length */
vcoubard 1151:575efbdcc905 60 (manufacturersName != NULL) ? strlen(manufacturersName) : 0, /* Max length */
vcoubard 1151:575efbdcc905 61 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
vcoubard 1151:575efbdcc905 62 modelNumberStringCharacteristic(GattCharacteristic::UUID_MODEL_NUMBER_STRING_CHAR,
vcoubard 1151:575efbdcc905 63 (uint8_t *)modelNumber,
vcoubard 1151:575efbdcc905 64 (modelNumber != NULL) ? strlen(modelNumber) : 0, /* Min length */
vcoubard 1151:575efbdcc905 65 (modelNumber != NULL) ? strlen(modelNumber) : 0, /* Max length */
vcoubard 1151:575efbdcc905 66 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
vcoubard 1151:575efbdcc905 67 serialNumberStringCharacteristic(GattCharacteristic::UUID_SERIAL_NUMBER_STRING_CHAR,
vcoubard 1151:575efbdcc905 68 (uint8_t *)serialNumber,
vcoubard 1151:575efbdcc905 69 (serialNumber != NULL) ? strlen(serialNumber) : 0, /* Min length */
vcoubard 1151:575efbdcc905 70 (serialNumber != NULL) ? strlen(serialNumber) : 0, /* Max length */
vcoubard 1151:575efbdcc905 71 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
vcoubard 1151:575efbdcc905 72 hardwareRevisionStringCharacteristic(GattCharacteristic::UUID_HARDWARE_REVISION_STRING_CHAR,
vcoubard 1151:575efbdcc905 73 (uint8_t *)hardwareRevision,
vcoubard 1151:575efbdcc905 74 (hardwareRevision != NULL) ? strlen(hardwareRevision) : 0, /* Min length */
vcoubard 1151:575efbdcc905 75 (hardwareRevision != NULL) ? strlen(hardwareRevision) : 0, /* Max length */
vcoubard 1151:575efbdcc905 76 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
vcoubard 1151:575efbdcc905 77 firmwareRevisionStringCharacteristic(GattCharacteristic::UUID_FIRMWARE_REVISION_STRING_CHAR,
vcoubard 1151:575efbdcc905 78 (uint8_t *)firmwareRevision,
vcoubard 1151:575efbdcc905 79 (firmwareRevision != NULL) ? strlen(firmwareRevision) : 0, /* Min length */
vcoubard 1151:575efbdcc905 80 (firmwareRevision != NULL) ? strlen(firmwareRevision) : 0, /* Max length */
vcoubard 1151:575efbdcc905 81 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ),
vcoubard 1151:575efbdcc905 82 softwareRevisionStringCharacteristic(GattCharacteristic::UUID_SOFTWARE_REVISION_STRING_CHAR,
vcoubard 1151:575efbdcc905 83 (uint8_t *)softwareRevision,
vcoubard 1151:575efbdcc905 84 (softwareRevision != NULL) ? strlen(softwareRevision) : 0, /* Min length */
vcoubard 1151:575efbdcc905 85 (softwareRevision != NULL) ? strlen(softwareRevision) : 0, /* Max length */
vcoubard 1151:575efbdcc905 86 GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ)
vcoubard 1151:575efbdcc905 87 {
vcoubard 1151:575efbdcc905 88 static bool serviceAdded = false; /* We only add the information service once. */
vcoubard 1151:575efbdcc905 89 if (serviceAdded) {
vcoubard 1151:575efbdcc905 90 return;
vcoubard 1151:575efbdcc905 91 }
vcoubard 1151:575efbdcc905 92
vcoubard 1151:575efbdcc905 93 GattCharacteristic *charTable[] = {&manufacturersNameStringCharacteristic,
vcoubard 1151:575efbdcc905 94 &modelNumberStringCharacteristic,
vcoubard 1151:575efbdcc905 95 &serialNumberStringCharacteristic,
vcoubard 1151:575efbdcc905 96 &hardwareRevisionStringCharacteristic,
vcoubard 1151:575efbdcc905 97 &firmwareRevisionStringCharacteristic,
vcoubard 1151:575efbdcc905 98 &softwareRevisionStringCharacteristic};
vcoubard 1151:575efbdcc905 99 GattService deviceInformationService(GattService::UUID_DEVICE_INFORMATION_SERVICE, charTable,
vcoubard 1151:575efbdcc905 100 sizeof(charTable) / sizeof(GattCharacteristic *));
vcoubard 1151:575efbdcc905 101
vcoubard 1151:575efbdcc905 102 ble.addService(deviceInformationService);
vcoubard 1151:575efbdcc905 103 serviceAdded = true;
vcoubard 1151:575efbdcc905 104 }
vcoubard 1151:575efbdcc905 105
vcoubard 1151:575efbdcc905 106 protected:
vcoubard 1152:1c10f851f4f9 107 /**
vcoubard 1152:1c10f851f4f9 108 * A reference to the BLE instance object to which the services and
vcoubard 1152:1c10f851f4f9 109 * characteristics will be added.
vcoubard 1152:1c10f851f4f9 110 */
vcoubard 1151:575efbdcc905 111 BLE &ble;
vcoubard 1152:1c10f851f4f9 112 /**
vcoubard 1152:1c10f851f4f9 113 * BLE characterising to allow BLE peers access to the manufacturer's name.
vcoubard 1152:1c10f851f4f9 114 */
vcoubard 1151:575efbdcc905 115 GattCharacteristic manufacturersNameStringCharacteristic;
vcoubard 1152:1c10f851f4f9 116 /**
vcoubard 1152:1c10f851f4f9 117 * BLE characterising to allow BLE peers access to the model number.
vcoubard 1152:1c10f851f4f9 118 */
vcoubard 1151:575efbdcc905 119 GattCharacteristic modelNumberStringCharacteristic;
vcoubard 1152:1c10f851f4f9 120 /**
vcoubard 1152:1c10f851f4f9 121 * BLE characterising to allow BLE peers access to the serial number.
vcoubard 1152:1c10f851f4f9 122 */
vcoubard 1151:575efbdcc905 123 GattCharacteristic serialNumberStringCharacteristic;
vcoubard 1152:1c10f851f4f9 124 /**
vcoubard 1152:1c10f851f4f9 125 * BLE characterising to allow BLE peers access to the hardware revision string.
vcoubard 1152:1c10f851f4f9 126 */
vcoubard 1151:575efbdcc905 127 GattCharacteristic hardwareRevisionStringCharacteristic;
vcoubard 1152:1c10f851f4f9 128 /**
vcoubard 1152:1c10f851f4f9 129 * BLE characterising to allow BLE peers access to the firmware revision string.
vcoubard 1152:1c10f851f4f9 130 */
vcoubard 1151:575efbdcc905 131 GattCharacteristic firmwareRevisionStringCharacteristic;
vcoubard 1152:1c10f851f4f9 132 /**
vcoubard 1152:1c10f851f4f9 133 * BLE characterising to allow BLE peers access to the software revision string.
vcoubard 1152:1c10f851f4f9 134 */
vcoubard 1151:575efbdcc905 135 GattCharacteristic softwareRevisionStringCharacteristic;
vcoubard 1151:575efbdcc905 136 };
vcoubard 1151:575efbdcc905 137
rgrover1 712:b04b5db36865 138 #endif /* #ifndef __BLE_DEVICE_INFORMATION_SERVICE_H__*/