Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DataStore JobScheduler NetworkServices W5500Interface nanopb protocol
Diff: source/main.cpp
- Revision:
- 1:eebe442fc126
- Parent:
- 0:2c57ed6943f7
- Child:
- 2:661c545d718e
diff -r 2c57ed6943f7 -r eebe442fc126 source/main.cpp
--- a/source/main.cpp	Thu Jul 13 17:22:32 2017 +0000
+++ b/source/main.cpp	Thu Jul 13 20:01:25 2017 +0000
@@ -3,6 +3,11 @@
 #include "mbed-trace/mbed_trace.h"
 #define TRACE_GROUP  "main"
 
+#include "scheduler.h"
+#include "schedules.h"
+#include "jobService.h"
+#include "jobTestPrint.h"
+
  // These are necessary only if thread safety is needed
 static Mutex TracingLock;
 static void tracingWait()
@@ -25,9 +30,23 @@
     
     tr_info("**Started**");    //-> "[INFO][main]: this is an info msg"    
     
-    
+    JobScheduler::JobService js;   
+    JobScheduler::Scheduler scheduler(&js);
+   
+    JobTestPrint jtp;
+    js.Register(1, JobTestPrint::RunAdapter, &jtp);
 
-    tr_debug("this is debug msg");  //-> "[DBG ][main]: this is a debug msg"
+    scheduler.Start();
+    
+    // inject test case
+    time_t nowSecs = time(NULL);
+    JobScheduler::Response<JobScheduler::JobID> res =
+        scheduler.JobAdd(1, new JobScheduler::RunOnceSchedule(nowSecs + 2), NULL);
+    
+    // block forever unless there is a job that calls scheduler.Stop()
+    scheduler.WaitToStop();   
+    
+    // indicate clean app termination
     tr_info("**Finished**");    //-> "[INFO][main]: this is an info msg"    
     exit(0);
 }