mbed code for UberVest health monitoring
Dependencies: BLE_API mbed nRF51822
UberVestService.h@1:7d2c09f56b33, 2015-10-19 (annotated)
- Committer:
- haydenball
- Date:
- Mon Oct 19 19:25:06 2015 +0000
- Revision:
- 1:7d2c09f56b33
- Parent:
- 0:b6fae6eb2bfe
- Child:
- 6:808cfc0b9480
Correct UUID (was UID)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
haydenball | 0:b6fae6eb2bfe | 1 | class UberVestService { |
haydenball | 0:b6fae6eb2bfe | 2 | public: |
haydenball | 0:b6fae6eb2bfe | 3 | const static uint16_t UBER_VEST_SERVICE_UUID = 0xB000; |
haydenball | 0:b6fae6eb2bfe | 4 | const static uint16_t BUTTON_CHARACTERISTIC_UUID = 0xB001; |
haydenball | 1:7d2c09f56b33 | 5 | const static uint16_t ECG_CHARACTERISTIC_UUID = 0xB002; |
haydenball | 0:b6fae6eb2bfe | 6 | |
haydenball | 0:b6fae6eb2bfe | 7 | UberVestService(BLE &_ble, bool buttonPressedInitial, int8_t ecgInitial) : |
haydenball | 1:7d2c09f56b33 | 8 | ble(_ble), |
haydenball | 1:7d2c09f56b33 | 9 | buttonState(BUTTON_CHARACTERISTIC_UUID, &buttonPressedInitial, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), |
haydenball | 1:7d2c09f56b33 | 10 | ecgState(ECG_CHARACTERISTIC_UUID, &ecgInitial, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) |
haydenball | 0:b6fae6eb2bfe | 11 | { |
haydenball | 0:b6fae6eb2bfe | 12 | GattCharacteristic *charTable[] = {&buttonState, &ecgState}; |
haydenball | 0:b6fae6eb2bfe | 13 | GattService uberVestService(UberVestService::UBER_VEST_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); |
haydenball | 0:b6fae6eb2bfe | 14 | |
haydenball | 0:b6fae6eb2bfe | 15 | ble.gattServer().addService(uberVestService); |
haydenball | 0:b6fae6eb2bfe | 16 | } |
haydenball | 0:b6fae6eb2bfe | 17 | |
haydenball | 0:b6fae6eb2bfe | 18 | void updateButtonState(bool newState) { |
haydenball | 0:b6fae6eb2bfe | 19 | ble.gattServer().write(buttonState.getValueHandle(), (uint8_t *)&newState, sizeof(bool)); |
haydenball | 0:b6fae6eb2bfe | 20 | } |
haydenball | 0:b6fae6eb2bfe | 21 | |
haydenball | 0:b6fae6eb2bfe | 22 | void updateEcg(int8_t value) { |
haydenball | 0:b6fae6eb2bfe | 23 | ble.gattServer().write(ecgState.getValueHandle(), (uint8_t *)&value, sizeof(int8_t)); |
haydenball | 0:b6fae6eb2bfe | 24 | } |
haydenball | 0:b6fae6eb2bfe | 25 | |
haydenball | 0:b6fae6eb2bfe | 26 | private: |
haydenball | 0:b6fae6eb2bfe | 27 | BLE &ble; |
haydenball | 0:b6fae6eb2bfe | 28 | ReadOnlyGattCharacteristic<bool> buttonState; |
haydenball | 0:b6fae6eb2bfe | 29 | ReadOnlyGattCharacteristic<int8_t> ecgState; |
haydenball | 0:b6fae6eb2bfe | 30 | }; |