Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed nRF51822
Fork of BLE_GATT_test1 by
TestGattService.h
- Committer:
- alexanderlea
- Date:
- 2015-02-17
- Revision:
- 3:f3d20b36b7ea
- Parent:
- 1:ebdf445c4bcc
File content as of revision 3:f3d20b36b7ea:
#ifndef __BLE_TEST_SERVICE_H__
#define __BLE_TEST_SERVICE_H__
#include "BLEDevice.h"
/**
* @class BatteryService
* @brief BLE Battery Service. This service displays the battery level from 0%->100% represented as a 8bit number.<br>
* Service: https://developer.bluetooth.org/gatt/services/Pages/ServiceViewer.aspx?u=org.bluetooth.service.battery_service.xml <br>
* Battery Level Char: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.battery_level.xml
*/
class TestGattService {
public:
/**
* @param[ref] _ble
*
* @param[in]
*/
TestGattService(BLEDevice &_ble, uint8_t _command) :
ble(_ble),
command(_command),
testCharacteristic(0x2A67, &command, sizeof(command), sizeof(command),
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ |
// GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE |
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) {
static bool serviceAdded = false; /* We should only ever need to add the service once. */
if (serviceAdded) {
return;
}
GattCharacteristic *charTable[] = {&testCharacteristic};
GattService testService(0x1817, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
ble.addService(testService);
serviceAdded = true;
}
/**
* @brief
*
* @param
*/
void sendCommand(uint8_t _newCommand) {
command = _newCommand;
ble.updateCharacteristicValue(testCharacteristic.getValueAttribute().getHandle(), &command, 1);
}
private:
BLEDevice &ble;
uint8_t command;
GattCharacteristic testCharacteristic;
};
#endif /* #ifndef __BLE_TEST_SERVICE_H__*/
