![](/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
UPAS_Service.h@10:66549fa08986, 2015-10-20 (annotated)
- Committer:
- jelord
- Date:
- Tue Oct 20 20:38:04 2015 +0000
- Revision:
- 10:66549fa08986
- Child:
- 11:1058647c66e8
Program to control BLE communication with UPAS
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jelord | 10:66549fa08986 | 1 | //CODE BY JAKE LORD |
jelord | 10:66549fa08986 | 2 | //ALL RIGHTS RESERVED BY VOLCKENS GROUP, FORT COLLINS CO |
jelord | 10:66549fa08986 | 3 | |
jelord | 10:66549fa08986 | 4 | #ifndef __BLE_UPAS_SERVICE_H__ |
jelord | 10:66549fa08986 | 5 | #define __BLE_UPAS_SERVICE_H__ |
jelord | 10:66549fa08986 | 6 | |
jelord | 10:66549fa08986 | 7 | class UPAS_Service { |
jelord | 10:66549fa08986 | 8 | public: |
jelord | 10:66549fa08986 | 9 | const static uint16_t UPAS_SERVICE_UUID = 0xA000; //UUID of Service. Following two are read/write characteristics of the service |
jelord | 10:66549fa08986 | 10 | const static uint16_t WRITE_STATE_CHARACTERISTIC_UUID = 0xA002; //UUID for variable that app will write to |
jelord | 10:66549fa08986 | 11 | const static uint16_t READ_STATE_CHARACTERISTIC_UUID = 0xA003; //UUID of variable that app will read from |
jelord | 10:66549fa08986 | 12 | GattCharacteristic readChar; |
jelord | 10:66549fa08986 | 13 | GattCharacteristic writeChar; |
jelord | 10:66549fa08986 | 14 | |
jelord | 10:66549fa08986 | 15 | |
jelord | 10:66549fa08986 | 16 | UPAS_Service(BLE &_ble, bool placeholder, uint8_t *tempArray) : |
jelord | 10:66549fa08986 | 17 | ble(_ble), readChar(READ_STATE_CHARACTERISTIC_UUID, tempArray,17,57,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), |
jelord | 10:66549fa08986 | 18 | writeChar(WRITE_STATE_CHARACTERISTIC_UUID, tempArray,17,57,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) |
jelord | 10:66549fa08986 | 19 | { |
jelord | 10:66549fa08986 | 20 | |
jelord | 10:66549fa08986 | 21 | GattCharacteristic *charTable[] = {&writeChar, &readChar}; //Set up characteristics to be broadcasted with the UPAS service |
jelord | 10:66549fa08986 | 22 | GattService upasService(UPAS_Service::UPAS_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); //Finally, construct the service |
jelord | 10:66549fa08986 | 23 | ble.gattServer().addService(upasService); |
jelord | 10:66549fa08986 | 24 | } |
jelord | 10:66549fa08986 | 25 | |
jelord | 10:66549fa08986 | 26 | private: |
jelord | 10:66549fa08986 | 27 | BLE &ble; |
jelord | 10:66549fa08986 | 28 | |
jelord | 10:66549fa08986 | 29 | // ReadOnlyGattCharacteristic<bool> placeholderState; |
jelord | 10:66549fa08986 | 30 | }; |
jelord | 10:66549fa08986 | 31 | |
jelord | 10:66549fa08986 | 32 | #endif /* #ifndef __BLE_UPAS_SERVICE_H__ */ |