Graduation Thesis, use Nucleo and X-Nucleo BLE
Dependencies: PulseSensor GSM Thermometer KalmanFilter
Revision 16:0325e647496f, committed 2018-05-23
- Comitter:
- DuyLionTran
- Date:
- Wed May 23 17:33:11 2018 +0000
- Parent:
- 15:00a1c0ea570c
- Child:
- 17:b7c2db3e7282
- Commit message:
- HTS Type and HRM Location can be changed by use through BLE
Changed in this revision
--- a/Application/ble_healthcare_service.h Fri May 18 16:51:27 2018 +0000 +++ b/Application/ble_healthcare_service.h Wed May 23 17:33:11 2018 +0000 @@ -99,6 +99,16 @@ return controlState.getValueHandle(); } + GattAttribute::Handle_t getTypeHandle() const + { + return tempLocation.getValueHandle(); + } + + GattAttribute::Handle_t getLocationHandle() const + { + return hrmLocation.getValueHandle(); + } + /** * @brief Update the temperature being broadcast. * @param[in] temperature Floating point value of the temperature. @@ -114,11 +124,19 @@ * @brief Update the temperature location. * @param loc New location value. */ - void updateLocation(uint8_t loc) { + void updateType(uint8_t loc) { ble.gattServer().write(tempLocation.getValueHandle(), reinterpret_cast<uint8_t *>(&loc), sizeof(uint8_t)); } /** + * @brief Update the temperature location. + * @param loc New location value. + */ + void updateLocation(uint8_t loc) { + ble.gattServer().write(hrmLocation.getValueHandle(), reinterpret_cast<uint8_t *>(&loc), sizeof(uint8_t)); + } + + /** * Update the heart rate that the service exposes. * The server sends a notification of the new value to clients that have * subscribed to updates of the heart rate measurement characteristic; clients
--- a/Application/main.cpp Fri May 18 16:51:27 2018 +0000 +++ b/Application/main.cpp Wed May 23 17:33:11 2018 +0000 @@ -104,7 +104,7 @@ sendCombinedTempAndHR = currentTemperature * 1000; /* Temperature float to int conversion */ sendCombinedTempAndHR = sendCombinedTempAndHR + (float)(currentHRMCounter/100.0); // printf("sendCombinedTempAndHR %d\r\n", sendCombinedTempAndHR); - printf("sendCombinedTempAndHR %.2f\r\n\r\n", (float)sendCombinedTempAndHR); +// printf("sendCombinedTempAndHR %.2f\r\n\r\n", (float)sendCombinedTempAndHR); if (BLE::Instance().gap().getState().connected) { HealthCareServicePtr->updateTemperature(sendCombinedTempAndHR); HealthCareServicePtr->updateHeartRate(currentHRMCounter); @@ -141,17 +141,19 @@ * Information about the characterisitc being updated. */ void onDataWrittenCallback(const GattWriteCallbackParams *params) { - if ((params->handle == HealthCareServicePtr->getValueHandle()) && (params->len == 1)) { -// uint8_t old_HRM_increasement = HRM_increasement; -// HRM_increasement = *(params->data); -// printf("Old data: %d\r\n, New data %d\r\n", old_HRM_increasement, HRM_increasement); +// printf("Write callback, value %d\r\n", *(params->data)); + if ((params->handle == HealthCareServicePtr->getTypeHandle()) && (params->len >= 1)) { uint8_t oldPosition = htsPosition; htsPosition = *(params->data); - printf("Old data: %d\r\n, New data %d\r\n", oldPosition, htsPosition); - if (BLE::Instance().gap().getState().connected) { - HealthCareServicePtr->updateLocation(htsPosition); - } + printf("Old type: %d, New type %d\r\n", oldPosition, htsPosition); + HealthCareServicePtr->updateType(htsPosition); } + if ((params->handle == HealthCareServicePtr->getLocationHandle()) && (params->len >= 1)) { + uint8_t oldPosition = hrmPosition; + hrmPosition = *(params->data); + printf("Old location: %d, New location %d\r\n", oldPosition, hrmPosition); + HealthCareServicePtr->updateLocation(hrmPosition); + } } /**
--- a/mbed-os.lib Fri May 18 16:51:27 2018 +0000 +++ b/mbed-os.lib Wed May 23 17:33:11 2018 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#c05d72c3c005fbb7e92c3994c32bda45218ae7fe +https://github.com/ARMmbed/mbed-os/#367dbdf5145f4d6aa3e483c147fe7bda1ce23a36