![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
This is a basic program that provides the necessary BLE service to allow communications with the UPAS
Dependencies: BLE_API mbed nRF51822 CronoDot EEPROM NCP5623BMUTBG ADS1115 BME280 Calibration_one MCP40D17 SDFileSystem LSM303 SI1145 STC3100
Fork of BLE_Button by
Diff: UPAS_Service.h
- Revision:
- 12:27273e6a50b3
- Parent:
- 11:1058647c66e8
- Child:
- 13:b43ec7e0cc1d
diff -r 1058647c66e8 -r 27273e6a50b3 UPAS_Service.h --- a/UPAS_Service.h Fri Oct 23 02:44:23 2015 +0000 +++ b/UPAS_Service.h Mon Oct 26 21:27:48 2015 +0000 @@ -6,19 +6,27 @@ class UPAS_Service { public: - const static uint16_t UPAS_SERVICE_UUID = 0xA000; //UUID of Service. Following two are read/write characteristics of the service - const static uint16_t WRITE_STATE_CHARACTERISTIC_UUID = 0xA002; //UUID for variable that app will write to - const static uint16_t READ_STATE_CHARACTERISTIC_UUID = 0xA003; //UUID of variable that app will read from - GattCharacteristic readChar; - GattCharacteristic writeChar; + //All Characteristics shall have a read/write counterpart protocol. This should prevent corruption of data. + const static uint16_t UPAS_SERVICE_UUID = 0xA000; //UUID of Service. + + const static uint16_t RTC_CHARACTERISTIC_UUID = 0xA002; //UUID for characteristic to write the RTC to + GattCharacteristic rtcCharacteristic; + + const static uint16_t SAMPLETIME_CHARACTERISTIC_UUID = 0xA003; //UUID of variable that app will read from + GattCharacteristic sampleTimeCharacteristic; + + const static uint16_t SUBJECTLABEL_CHARACTERISTIC_UUID = 0xA004; //UUID of variable that app will read from + GattCharacteristic subjectLabelCharacteristic; - UPAS_Service(BLE &_ble, bool placeholder, uint8_t *tempArray) : - ble(_ble), readChar(READ_STATE_CHARACTERISTIC_UUID, tempArray,18,20,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), - writeChar(WRITE_STATE_CHARACTERISTIC_UUID, tempArray,18,20,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) + UPAS_Service(BLE &_ble, bool placeholder, uint8_t *rtc, uint8_t *sampleTime, uint8_t *subjectLabel) : + ble(_ble), + rtcCharacteristic(RTC_CHARACTERISTIC_UUID, rtc,6,20, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), + sampleTimeCharacteristic(SAMPLETIME_CHARACTERISTIC_UUID, sampleTime,12,20,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), + subjectLabelCharacteristic(SUBJECTLABEL_CHARACTERISTIC_UUID, subjectLabel,15,20,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) { - GattCharacteristic *charTable[] = {&writeChar, &readChar}; //Set up characteristics to be broadcasted with the UPAS service + GattCharacteristic *charTable[] = {&rtcCharacteristic, &sampleTimeCharacteristic}; //Set up characteristics to be broadcasted with the UPAS service GattService upasService(UPAS_Service::UPAS_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); //Finally, construct the service ble.gattServer().addService(upasService); }