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 Bluetooth Low Energy

Committer:
jelord
Date:
Tue Nov 03 01:34:58 2015 +0000
Revision:
14:4fc1788b8ad2
Parent:
13:b43ec7e0cc1d
Child:
15:c9c93454dd56
bit 54 on eprom now set by app for run modes

Who changed what in which revision?

UserRevisionLine numberNew 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 12:27273e6a50b3 9 //All Characteristics shall have a read/write counterpart protocol. This should prevent corruption of data.
jelord 12:27273e6a50b3 10 const static uint16_t UPAS_SERVICE_UUID = 0xA000; //UUID of Service.
jelord 12:27273e6a50b3 11
jelord 12:27273e6a50b3 12 const static uint16_t RTC_CHARACTERISTIC_UUID = 0xA002; //UUID for characteristic to write the RTC to
jelord 12:27273e6a50b3 13 GattCharacteristic rtcCharacteristic;
jelord 12:27273e6a50b3 14
jelord 12:27273e6a50b3 15 const static uint16_t SAMPLETIME_CHARACTERISTIC_UUID = 0xA003; //UUID of variable that app will read from
jelord 12:27273e6a50b3 16 GattCharacteristic sampleTimeCharacteristic;
jelord 12:27273e6a50b3 17
jelord 12:27273e6a50b3 18 const static uint16_t SUBJECTLABEL_CHARACTERISTIC_UUID = 0xA004; //UUID of variable that app will read from
jelord 12:27273e6a50b3 19 GattCharacteristic subjectLabelCharacteristic;
jelord 13:b43ec7e0cc1d 20
jelord 13:b43ec7e0cc1d 21 const static uint16_t TWENTYFOURHOUR_CHARACTERISTIC_UUID = 0xA005; //UUID of variable that app will read from
jelord 13:b43ec7e0cc1d 22 GattCharacteristic twentyFourHourCharacteristic;
jelord 13:b43ec7e0cc1d 23
jelord 13:b43ec7e0cc1d 24 const static uint16_t DEMO_CHARACTERISTIC_UUID = 0xA006; //UUID of variable that app will read from
jelord 14:4fc1788b8ad2 25 GattCharacteristic runModeCharacteristic;
jelord 10:66549fa08986 26
jelord 10:66549fa08986 27
jelord 12:27273e6a50b3 28 UPAS_Service(BLE &_ble, bool placeholder, uint8_t *rtc, uint8_t *sampleTime, uint8_t *subjectLabel) :
jelord 13:b43ec7e0cc1d 29
jelord 13:b43ec7e0cc1d 30 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 ),
jelord 12:27273e6a50b3 31 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),
jelord 13:b43ec7e0cc1d 32 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),
jelord 13:b43ec7e0cc1d 33 twentyFourHourCharacteristic(TWENTYFOURHOUR_CHARACTERISTIC_UUID,0,0,20,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY),
jelord 14:4fc1788b8ad2 34 runModeCharacteristic(DEMO_CHARACTERISTIC_UUID,0,0,20,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY),
jelord 13:b43ec7e0cc1d 35 ble(_ble)
jelord 10:66549fa08986 36 {
jelord 10:66549fa08986 37
jelord 14:4fc1788b8ad2 38 GattCharacteristic *charTable[] = {&rtcCharacteristic, &sampleTimeCharacteristic, &subjectLabelCharacteristic, &twentyFourHourCharacteristic, &runModeCharacteristic}; //Set up characteristics to be broadcasted with the UPAS service
jelord 10:66549fa08986 39 GattService upasService(UPAS_Service::UPAS_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); //Finally, construct the service
jelord 10:66549fa08986 40 ble.gattServer().addService(upasService);
jelord 10:66549fa08986 41 }
jelord 10:66549fa08986 42
jelord 10:66549fa08986 43 private:
jelord 10:66549fa08986 44 BLE &ble;
jelord 10:66549fa08986 45
jelord 10:66549fa08986 46 // ReadOnlyGattCharacteristic<bool> placeholderState;
jelord 10:66549fa08986 47 };
jelord 10:66549fa08986 48
jelord 10:66549fa08986 49 #endif /* #ifndef __BLE_UPAS_SERVICE_H__ */