Program that uses the QuickStart Library to interface a SmartMesh IP mote: Connects to the default network and starts publishing a random walk value every 5 seconds.

Dependencies:   mbed millis

Fork of QSL_SimplePublish by Jon-Håkon Bøe Røli

QSL SimplePublish

SmartMesh IP QuickStart Library

Revision:
8:8eb144b9ada3
Parent:
4:0285bcbbc855
--- a/dn_time.cpp	Thu Oct 27 08:29:01 2016 +0000
+++ b/dn_time.cpp	Thu Nov 03 09:35:50 2016 +0000
@@ -8,6 +8,7 @@
 
 #include "dn_time.h"
 #include "mbed.h"
+#include "millis.h"
 #include "dn_debug.h"
 
 //=========================== defines =========================================
@@ -15,7 +16,6 @@
 
 //=========================== variables =======================================
 
-static Timer myTimer;
 
 //=========================== prototypes ======================================
 
@@ -24,29 +24,12 @@
 
 uint32_t dn_time_ms(void)
 {
-	static bool started = FALSE;
-	time_t seconds;
-	uint32_t ms;
-	
-	if (!started)
-	{
-		myTimer.start();
-		/*
-		Uncomment the command below to set RTC time to 1th Jan 2016 00:00:00.
-		Otherwise, time() will just return seconds since boot
-		*/
-		//set_time(1451606400);
-		started = TRUE;
-	}
 	/*
-	mbed timers are based on 32-bit int microsecond counters, resulting in
-	read_ms() to wrap around long before the max value of a uint32_t.
-	Therefore, the seconds from time() is used to fully extend the range, and
-	we cast read_ms() to an uint32_t and only use the millisecond part.
-	 */
-	seconds = time(NULL);
-	ms = (uint32_t)seconds*1000 + (uint32_t)(myTimer.read_ms()) % 1000;
-	
+	A simple library that utilize SysTick is used instead of the mbed Timer
+	class, as the latter is based on 32-bit microsecond counter and thus
+	overflows long before 32-bits of milliseconds are used.
+	*/
+	uint32_t ms = millis();
 	return ms;
 }