This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

questions on how to implement the current time service

I'm working on an implementation of the Current Time Service specified by the Bluetooth SIG (I'm happy to share it).

where I am so far:

  • The service and the caracteristics are set up and working correctly.
  • I can initialise the value attribute with a static date_time
  • I can increment the time using a timer created with the timer lib and update the value in the softdevice

My questions:

  • where do I get the time from? The timer lib uses the RTC but can I still set and read the absolute value of the RTC and read the time-value from there? Or will it interfere? I later want to be able to go into a power saving mode where the device doesn't do anything until the user wakes it up by the press of a button. Of course the RTC should continue to run during that time. Or will I anyway not save a significant amount of energy compared to waking up every secound to run the timer lib?

  • the time gets read from the device very seldomly. Do I really need to update the time value in the softdevice every secound even though it is almost never read? Is there a possibility to get an event from the softdevice when the time is read, so the application can than read the RTC value, write it to the softdevice and tell the softdevice that the value is now ready to be delivered to the peer device?

P.S. Im using your ble_date_time.h file for the date_time format definition. Could it be that there is the include #include "app_util.h" missing? the definitions for __INLINE and the datatypes are missing. I was unable to compile without adding it.

Parents
  • Are you implementing the Time Server or the Time Client? I suppose the most common application would be to have the nRF51822 be a Time Client to a smart phone's Time Server, that can get the current time from GPS and/or the phone network. In this case, the nRF51822 would be a GATT Client, and reading the current time from the phone's GATT Server, to be used locally.

    However, if you for some reason are implementing a Time Server on the nRF51, I'd suppose you have some external time keeping device, that you can read to get a proper time for your server. If you want to know when a characteristic is read, you can enable authorization for it, which will give you the events as shown here. Authorization can be enabled by setting the rd_auth flag in the ble_gatts_attr_md_t struct when initializing the characteristic.

Reply
  • Are you implementing the Time Server or the Time Client? I suppose the most common application would be to have the nRF51822 be a Time Client to a smart phone's Time Server, that can get the current time from GPS and/or the phone network. In this case, the nRF51822 would be a GATT Client, and reading the current time from the phone's GATT Server, to be used locally.

    However, if you for some reason are implementing a Time Server on the nRF51, I'd suppose you have some external time keeping device, that you can read to get a proper time for your server. If you want to know when a characteristic is read, you can enable authorization for it, which will give you the events as shown here. Authorization can be enabled by setting the rd_auth flag in the ble_gatts_attr_md_t struct when initializing the characteristic.

Children
No Data
Related