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 20:33:27 2015 +0000
Revision:
16:e066ab7e8fb3
Parent:
15:c9c93454dd56
Up-to-date backup...Revert here for testing

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 16:e066ab7e8fb3 21 const static uint16_t RUNREADY_CHARACTERISTIC_UUID = 0xA005; //UUID of variable that app will read from
jelord 15:c9c93454dd56 22 GattCharacteristic runReadyCharacteristic;
jelord 13:b43ec7e0cc1d 23
jelord 16:e066ab7e8fb3 24 const static uint16_t RUNMODE_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 16:e066ab7e8fb3 33 runReadyCharacteristic(RUNREADY_CHARACTERISTIC_UUID,0,0,20,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY),
jelord 16:e066ab7e8fb3 34 runModeCharacteristic(RUNMODE_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 15:c9c93454dd56 38 GattCharacteristic *charTable[] = {&rtcCharacteristic, &sampleTimeCharacteristic, &subjectLabelCharacteristic, &runReadyCharacteristic, &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__ */