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:
Mon Oct 26 21:27:48 2015 +0000
Revision:
12:27273e6a50b3
Parent:
11:1058647c66e8
Child:
13:b43ec7e0cc1d
Added characteristic to UPAS_SERVICE.h that advertises the subject label from the EEPROM

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 10:66549fa08986 20
jelord 10:66549fa08986 21
jelord 12:27273e6a50b3 22 UPAS_Service(BLE &_ble, bool placeholder, uint8_t *rtc, uint8_t *sampleTime, uint8_t *subjectLabel) :
jelord 12:27273e6a50b3 23 ble(_ble),
jelord 12:27273e6a50b3 24 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 25 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 12:27273e6a50b3 26 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 10:66549fa08986 27 {
jelord 10:66549fa08986 28
jelord 12:27273e6a50b3 29 GattCharacteristic *charTable[] = {&rtcCharacteristic, &sampleTimeCharacteristic}; //Set up characteristics to be broadcasted with the UPAS service
jelord 10:66549fa08986 30 GattService upasService(UPAS_Service::UPAS_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); //Finally, construct the service
jelord 10:66549fa08986 31 ble.gattServer().addService(upasService);
jelord 10:66549fa08986 32 }
jelord 10:66549fa08986 33
jelord 10:66549fa08986 34 private:
jelord 10:66549fa08986 35 BLE &ble;
jelord 10:66549fa08986 36
jelord 10:66549fa08986 37 // ReadOnlyGattCharacteristic<bool> placeholderState;
jelord 10:66549fa08986 38 };
jelord 10:66549fa08986 39
jelord 10:66549fa08986 40 #endif /* #ifndef __BLE_UPAS_SERVICE_H__ */