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: CM3592
Fork of MtConnect04S_MtSense05 by
Diff: source/EnvironmentalUVService.h
- Revision:
- 0:6d6708b58601
diff -r 000000000000 -r 6d6708b58601 source/EnvironmentalUVService.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/source/EnvironmentalUVService.h Tue Jun 06 02:02:38 2017 +0000 @@ -0,0 +1,40 @@ +#ifndef ENVIRONMENTALUVSERVICE_H +#define ENVIRONMENTALUVSERVICE_H + +#include "ble/BLE.h" + +class EnvironmentUVService { + public: + + typedef int UVType_t; + EnvironmentUVService(BLE& _ble) : + ble(_ble), + uvCharacteristic(0x2A76, &uv ) { + + static bool serviceAdded = false; /* We should only ever need to add the information service once. */ + if (serviceAdded) { + return; + } + + GattCharacteristic *charTable[] = { &uvCharacteristic }; + + GattService environmentalService(GattService::UUID_ENVIRONMENTAL_SERVICE, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); + + ble.gattServer().addService(environmentalService); + serviceAdded = true; + } + + void updateTemperature(int uvIndex) { + uv = (UVType_t) uvIndex; + ble.gattServer().write(uvCharacteristic.getValueHandle(), (uint8_t *) &uv, sizeof(UVType_t)); + } + + private: + + BLE& ble; + UVType_t uv; + ReadOnlyGattCharacteristic<UVType_t> uvCharacteristic; +}; + + +#endif \ No newline at end of file