![](/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:
- 10:66549fa08986
- Child:
- 11:1058647c66e8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UPAS_Service.h Tue Oct 20 20:38:04 2015 +0000 @@ -0,0 +1,32 @@ +//CODE BY JAKE LORD +//ALL RIGHTS RESERVED BY VOLCKENS GROUP, FORT COLLINS CO + +#ifndef __BLE_UPAS_SERVICE_H__ +#define __BLE_UPAS_SERVICE_H__ + +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; + + + UPAS_Service(BLE &_ble, bool placeholder, uint8_t *tempArray) : + ble(_ble), readChar(READ_STATE_CHARACTERISTIC_UUID, tempArray,17,57,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), + writeChar(WRITE_STATE_CHARACTERISTIC_UUID, tempArray,17,57,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 + GattService upasService(UPAS_Service::UPAS_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); //Finally, construct the service + ble.gattServer().addService(upasService); + } + +private: + BLE &ble; + + // ReadOnlyGattCharacteristic<bool> placeholderState; +}; + +#endif /* #ifndef __BLE_UPAS_SERVICE_H__ */