Time
This section refers to the following sample application(s):
03-time
Because of the time-synchronized nature of a
SmartMesh
network, your application can retrieve accurate time stamps. Your application can, for example, write a time stamp in an application payload field.Your application has two ways for retrieving the current time:
- by calling functions
- by receiving a time pin notification
Time pin notifications allow your application to accurately timestamp external events. The time pin is a single, dedicated pin. When the time pin is asserted, the
SmartMesh library
accurately captures the current time and generates a notification, which contains the time at which the time pin was asserted.The "network time" contains the current Absolute Slot Number (ASN), as well as a time offset inside the current slot. The combination of those two values forms an accurate timestamp.
The 03-time
Sample Application
The 03-time
sample application creates a task which periodically reads the current time, and prints it over CLI. It also registers for time pin notifications, which it prints over CLI. Finally, it starts a network join procedures.
The figure below shows a annotated output of the 03-time
sample application:
time app, ver 1.0.0.2 SmartMeshIP stack, ver 1.2.1.3 > minfo Net stack v1.2.1.3 state: Search <<< The mote is searching. mac: 00:17:0d:00:00:38:0f:47 moteid: 0 netid: 423 blSwVer: 13 ldrSwVer: 1.0.3.12 UTC time: 0:0 reset st: 200 > current time: - ASN: 0x0000000000 <<< ASN is 0 when not joined. - offset: 0 us - sysTime: 181289 ticks 8271 : Joining 9429 : Connected 17797 : Active <<< The mote has joined. current time: - ASN: 0x000032e6d5 <<< ASN is now set to the network's ASN. - offset: 3034 us - sysTime: 673008 ticks minfo Net stack v1.2.1.3 state: Oper <<< minfo shows mote is operational. mac: 00:17:0d:00:00:38:0f:47 moteid: 2 netid: 423 blSwVer: 13 ldrSwVer: 1.0.3.12 UTC time: 1025689387:102113 reset st: 200 > current time: - ASN: 0x000032e987 - offset: 2550 us - sysTime: 836915 ticks time notification: <<< A time pin notification - upTime: 27 s - ASN: 0x000032ead6 - offset: 30734 us current time: - ASN: 0x000032ec39 - offset: 2050 us - sysTime: 1000822 ticks
To trigger a time pin notification, you need to pull the time pin low, then high. The default state of the time pin should be high.
While the time pin is low, the device consumes more energy in order to return a highly accurate timestamp when the pin transitions to high. Your application should therefore keep the pin high by default, and lower it only for a small amount of time, but not less than the tstrobe
value listed in the LTC5800-IPM datasheet.