Add support for reading the current time
This commit is contained in:
parent
206bdbf5eb
commit
b4e82dd11f
|
@ -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, ¤tDateTime, sizeof(CtsData));
|
||||
return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
|
||||
|
||||
}
|
||||
|
||||
//!TODO need to support reading the time.
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user