Code supports writing to the SD card as well as working with the Volckens group smartphone apps for the mbed HRM1017

Dependencies:   ADS1115 BLE_API BME280 Calibration CronoDot EEPROM LSM303 MCP40D17 NCP5623BMUTBG SDFileSystem SI1145 STC3100 mbed nRF51822

Fork of UPAS_BLE_and_USB by Volckens Group Sensors

Committer:
jelord
Date:
Mon Jan 11 20:42:03 2016 +0000
Revision:
99:229435dd4cfb
Parent:
96:03106adb45c9
Child:
100:da71436aa52a
Name of multiple UPAS can now be distinguished by app

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jelord 94:c57720890e76 1 //CODE BY JAKE LORD
jelord 94:c57720890e76 2 //ALL RIGHTS RESERVED BY VOLCKENS GROUP, FORT COLLINS CO
jelord 94:c57720890e76 3
jelord 94:c57720890e76 4 #ifndef __BLE_UPAS_SERVICE_H__
jelord 94:c57720890e76 5 #define __BLE_UPAS_SERVICE_H__
jelord 94:c57720890e76 6
jelord 94:c57720890e76 7 class UPAS_Service {
jelord 94:c57720890e76 8 public:
jelord 94:c57720890e76 9 //All Characteristics shall have a read/write counterpart protocol. This should prevent corruption of data.
jelord 94:c57720890e76 10 const static uint16_t UPAS_SERVICE_UUID = 0xA000; //UUID of Service.
jelord 94:c57720890e76 11
jelord 94:c57720890e76 12 const static uint16_t RTC_CHARACTERISTIC_UUID = 0xA002; //UUID for characteristic to write the RTC to
jelord 94:c57720890e76 13 GattCharacteristic rtcCharacteristic;
jelord 94:c57720890e76 14
jelord 94:c57720890e76 15 const static uint16_t SAMPLETIME_CHARACTERISTIC_UUID = 0xA003; //UUID of variable that app will read from
jelord 94:c57720890e76 16 GattCharacteristic sampleTimeCharacteristic;
jelord 94:c57720890e76 17
jelord 94:c57720890e76 18 const static uint16_t SUBJECTLABEL_CHARACTERISTIC_UUID = 0xA004; //UUID of variable that app will read from
jelord 94:c57720890e76 19 GattCharacteristic subjectLabelCharacteristic;
jelord 94:c57720890e76 20
jelord 94:c57720890e76 21 const static uint16_t RUNREADY_CHARACTERISTIC_UUID = 0xA005; //UUID of variable that app will read from
jelord 94:c57720890e76 22 GattCharacteristic runReadyCharacteristic;
jelord 94:c57720890e76 23
jelord 96:03106adb45c9 24 const static uint16_t LOGINTERVAL_CHARACTERISTIC_UUID = 0xA006; //UUID of variable that app will read from
jelord 96:03106adb45c9 25 GattCharacteristic logIntevalCharacteristic;
jelord 96:03106adb45c9 26
jelord 96:03106adb45c9 27 const static uint16_t FLOWRATE_CHARACTERISTIC_UUID = 0xA007; //UUID of variable that app will read from
jelord 96:03106adb45c9 28 GattCharacteristic flowRateCharacteristic;
jelord 99:229435dd4cfb 29
jelord 99:229435dd4cfb 30 //const static uint16_t BLOWER_CHARACTERISTIC_UUID = 0xA008; //UUID of variable that app will read from
jelord 99:229435dd4cfb 31 // GattCharacteristic blowerCharacteristic;
jelord 94:c57720890e76 32
jelord 94:c57720890e76 33
jelord 96:03106adb45c9 34 UPAS_Service(BLEDevice &_ble, bool placeholder, uint8_t *rtc, uint8_t *sampleTime, uint8_t *subjectLabel, uint8_t *logInterval, uint8_t *flowRate) :
jelord 94:c57720890e76 35
jelord 94:c57720890e76 36 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 94:c57720890e76 37 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 94:c57720890e76 38 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 96:03106adb45c9 39 runReadyCharacteristic(RUNREADY_CHARACTERISTIC_UUID,0,0,20,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ |GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY),
jelord 96:03106adb45c9 40 logIntevalCharacteristic(LOGINTERVAL_CHARACTERISTIC_UUID,logInterval,1,20,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ |GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY),
jelord 96:03106adb45c9 41 flowRateCharacteristic(FLOWRATE_CHARACTERISTIC_UUID,flowRate,4,20,GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ |GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY),
jelord 94:c57720890e76 42 ble(_ble)
jelord 94:c57720890e76 43 {
jelord 94:c57720890e76 44
jelord 96:03106adb45c9 45 GattCharacteristic *charTable[] = {&rtcCharacteristic, &sampleTimeCharacteristic, &subjectLabelCharacteristic, &runReadyCharacteristic, &logIntevalCharacteristic, &flowRateCharacteristic}; //Set up characteristics to be broadcasted with the UPAS service
jelord 94:c57720890e76 46 GattService upasService(UPAS_Service::UPAS_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); //Finally, construct the service
jelord 94:c57720890e76 47 ble.addService(upasService);
jelord 94:c57720890e76 48 }
jelord 94:c57720890e76 49
jelord 94:c57720890e76 50 private:
jelord 94:c57720890e76 51 BLEDevice &ble;
jelord 94:c57720890e76 52
jelord 94:c57720890e76 53 };
jelord 94:c57720890e76 54
jelord 94:c57720890e76 55 #endif /* #ifndef __BLE_UPAS_SERVICE_H__ */