mbed code for UberVest health monitoring
Dependencies: BLE_API mbed nRF51822
UberVestService.h@0:b6fae6eb2bfe, 2015-10-19 (annotated)
- Committer:
- haydenball
- Date:
- Mon Oct 19 16:03:58 2015 +0000
- Revision:
- 0:b6fae6eb2bfe
- Child:
- 1:7d2c09f56b33
Basic UberVest BLE Service
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 | 0:b6fae6eb2bfe | 5 | const static uint16_t ECG_CHARACTERISTIC_UID = 0xB002; |
haydenball | 0:b6fae6eb2bfe | 6 | |
haydenball | 0:b6fae6eb2bfe | 7 | UberVestService(BLE &_ble, bool buttonPressedInitial, int8_t ecgInitial) : |
haydenball | 0:b6fae6eb2bfe | 8 | ble(_ble), buttonState(BUTTON_CHARACTERISTIC_UUID, &buttonPressedInitial, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY), |
haydenball | 0:b6fae6eb2bfe | 9 | ecgState(ECG_CHARACTERISTIC_UID, &ecgInitial, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY) |
haydenball | 0:b6fae6eb2bfe | 10 | { |
haydenball | 0:b6fae6eb2bfe | 11 | GattCharacteristic *charTable[] = {&buttonState, &ecgState}; |
haydenball | 0:b6fae6eb2bfe | 12 | GattService uberVestService(UberVestService::UBER_VEST_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *)); |
haydenball | 0:b6fae6eb2bfe | 13 | |
haydenball | 0:b6fae6eb2bfe | 14 | ble.gattServer().addService(uberVestService); |
haydenball | 0:b6fae6eb2bfe | 15 | } |
haydenball | 0:b6fae6eb2bfe | 16 | |
haydenball | 0:b6fae6eb2bfe | 17 | void updateButtonState(bool newState) { |
haydenball | 0:b6fae6eb2bfe | 18 | ble.gattServer().write(buttonState.getValueHandle(), (uint8_t *)&newState, sizeof(bool)); |
haydenball | 0:b6fae6eb2bfe | 19 | } |
haydenball | 0:b6fae6eb2bfe | 20 | |
haydenball | 0:b6fae6eb2bfe | 21 | void updateEcg(int8_t value) { |
haydenball | 0:b6fae6eb2bfe | 22 | ble.gattServer().write(ecgState.getValueHandle(), (uint8_t *)&value, sizeof(int8_t)); |
haydenball | 0:b6fae6eb2bfe | 23 | } |
haydenball | 0:b6fae6eb2bfe | 24 | |
haydenball | 0:b6fae6eb2bfe | 25 | private: |
haydenball | 0:b6fae6eb2bfe | 26 | BLE &ble; |
haydenball | 0:b6fae6eb2bfe | 27 | ReadOnlyGattCharacteristic<bool> buttonState; |
haydenball | 0:b6fae6eb2bfe | 28 | ReadOnlyGattCharacteristic<int8_t> ecgState; |
haydenball | 0:b6fae6eb2bfe | 29 | }; |