summaryrefslogtreecommitdiff
path: root/src/Components
diff options
context:
space:
mode:
authorAdam Pigg <adam@piggz.co.uk>2020-05-05 20:53:31 +0100
committerAdam Pigg <adam@piggz.co.uk>2020-05-05 20:58:15 +0100
commitb4e82dd11f11611911d371ce41c01c69ca8f3de3 (patch)
tree6a64bff6c9cd6aad6a43e1fcb0f6bce1e5c9468f /src/Components
parent206bdbf5eb94ac967284862b5d7a270ed50195db (diff)
Add support for reading the current time
Diffstat (limited to 'src/Components')
-rw-r--r--src/Components/Ble/CurrentTimeService.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Components/Ble/CurrentTimeService.cpp b/src/Components/Ble/CurrentTimeService.cpp
index 0af20dd3..a44a18a5 100644
--- a/src/Components/Ble/CurrentTimeService.cpp
+++ b/src/Components/Ble/CurrentTimeService.cpp
@@ -34,7 +34,22 @@ int CurrentTimeService::OnTimeAccessed(uint16_t conn_handle, uint16_t attr_handl
m_dateTimeController.SetTime(result.year, result.month, result.dayofmonth,
0, result.hour, result.minute, result.second, nrf_rtc_counter_get(portNRF_RTC_REG));
+ } else if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR) {
+ CtsData currentDateTime;
+ currentDateTime.year = m_dateTimeController.Year();
+ currentDateTime.month = static_cast<u_int8_t>(m_dateTimeController.Month());
+ currentDateTime.dayofmonth = m_dateTimeController.Day();
+ currentDateTime.hour = m_dateTimeController.Hours();
+ currentDateTime.minute = m_dateTimeController.Minutes();
+ currentDateTime.second = m_dateTimeController.Seconds();
+ currentDateTime.millis = 0;
+
+
+ int res = os_mbuf_append(ctxt->om, &currentDateTime, sizeof(CtsData));
+ return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
+
}
+
//!TODO need to support reading the time.
return 0;
}