Additional documentation for RFX “Virtual RTC” methods and Watchdog Timer functions

26 May

Additional documentation in the form of two addenda have been added to the “Docs” section, under the “Sketch-level API documentation” sub-section, entitled “Addendum: Using RFX Virtual RTC methods” and “Addendum: Using RFX WDT functions” respectively.

RFX Virtual RTC

The “Virtual RTC” methods provide an extension of the RFX API that allows for the function of hardware real-time clock, but without the hardware. The time on the Arduino client is set from the RFX gateway’s system time, which is synced via Internet time servers (NTP). The virtual RTC is seeded when the Arduino client joins the RFX gateway, and is automatically resynced with gateway time at midnight every night to compensate for clock drift due to crystal or resonator imprecision.  The clock can be kept as UTC (a.k.a. GMT), or in a local time using a #define in Rfx_config.h. For example, by including the lines

#define VIRT_RTC 1

#define TZ_LOCALE "America/Denver"

in Rfx_config.h, the virtual RTC will keep local time for Denver, CO (including correcting for daylight saving time, when applicable.) If TZ_LOCALE is not defined, UTC (GMT) is assumed.

Not bad for a zero hardware cost! A natural continuation of the Internet of Things (IoT) “minimal price per deployment” philosophy.

RFX Watchdog Timer (WDT) functions

The RFX watchdog timer (WDT) functions

void wdt_start();
void wdt_pat();
void wdt_stop();

provide convenient and portable wrappers around the architecture specific WDT functions for a particular chip. They are activated by including the line

#define RFX_WDT 1

in the Rfx_config.h file for a sketch. If The RFX_WDT macro is defined to be 0, or is not defined at all, then calling the wdt_* functions willl have no effect — they will be simply defined as empty functions. So WDT support can be turned on and off by simply changing the value of RFX_WDT macro and recompiling… very convenient for debugging.

The other advantage of providing the wrappers is that it has enabled embedding the necessary wdt_pat() class throughout the RFX library code to make it only required to consider the WDT timing requirements for the sketch code. This means you don’t have to worry about your watchdog timer expiring during a RFX method or function call that might have a timeout associated with it. An example sketch is shown.

A list of Arduino and derivative board models at the end of  the addendum details some considerations regarding specific boards and their bootloaders, and how to upgrade a WDT incompatible bootloader to a WDT compatible one if necessary.

The above, of course, is an overview. For full details, refer to the addenda. As usual, comments/feedback welcome — please drop us a line using the Contact page.

No comments yet.

Leave a Reply