research application on sending data to headend

Dependencies:   DataStore JobScheduler NetworkServices W5500Interface nanopb protocol

See "main.cpp" documentation on "API Documentation" tab for details about application.

Revision:
11:acaefb63fc6b
Parent:
9:d6a9210bfd41
Child:
12:ec140a26367f
--- a/source/main.cpp	Tue Aug 01 23:30:05 2017 +0000
+++ b/source/main.cpp	Wed Aug 02 00:22:06 2017 +0000
@@ -11,6 +11,7 @@
 
 #include "jobTestPrint.h"
 #include "jobFakeADC.h"
+#include "jobSchedulesUpload.h"
 
  // These are necessary only if thread safety is needed
 static Mutex TracingLock;
@@ -48,6 +49,7 @@
     printf("\n==Borsch==\n");
     
 //    if (initTime() == false) {
+//        printf("Application terminated: initTime has failed\n");
 //        exit(1);
 //    }
     
@@ -71,11 +73,30 @@
     JobScheduler::JobService js;   
     JobScheduler::Scheduler scheduler(&js);
    
+    /* Job Type ID shall match command id defined in ISOM commandTypes.go
+    While this rule is not strictly necessary it cuts down on code responsible
+    for mapping between our internal IDs to CommandIDs.
+    
+    addKV(NewCommandMetaData(1, "NO-OP"))
+    addKV(NewCommandMetaData(2, "List Schedules"))
+    addKV(NewCommandMetaData(3, "Add Schedule"))
+    addKV(NewCommandMetaData(4, "Remove Schedule"))
+    addKV(NewCommandMetaData(5, "Set STM ADC Schedule"))
+    addKV(NewCommandMetaData(31, "Close Valve"))
+    addKV(NewCommandMetaData(32, "Open Valve"))
+    
+    Use range 1000 for unique to STM jobs.
+    */
+
+    // command #2 is List Schedules in ISOM.
+    JobSchedulesUpload jSchedulesUpload(lce, scheduler);
+    js.Register(2, JobSchedulesUpload::RunAdapter, &jSchedulesUpload);
+    
     JobTestPrint jtp;
-    js.Register(1, JobTestPrint::RunAdapter, &jtp);
+    js.Register(1001, JobTestPrint::RunAdapter, &jtp);
     
     JobFakeADC jfa(lce);
-    js.Register(2, JobFakeADC::RunAdapter, &jfa);
+    js.Register(1002, JobFakeADC::RunAdapter, &jfa);
 
     scheduler.Start();
     
@@ -83,10 +104,11 @@
     time_t nowSecs = time(NULL);
     // NOTE: don't schedule run once with at 0, because 0 means never.
     JobScheduler::Response<JobScheduler::JobID> res =
-        scheduler.JobAdd(2, new JobScheduler::RunPeriodicSchedule(3, 5), NULL);
-        //scheduler.JobAdd(2, new JobScheduler::RunOnceSchedule(1), NULL);
-        //scheduler.JobAdd(1, new JobScheduler::RunOnceSchedule(nowSecs + 2), NULL);
-    //res = scheduler.JobAdd(2, new JobScheduler::RunPeriodicSchedule(2, 5), NULL);
+          scheduler.JobAdd(1002, new JobScheduler::RunPeriodicSchedule(3, 5), NULL);
+    res = scheduler.JobAdd(2, new JobScheduler::RunOnceSchedule(2), NULL);
+        //scheduler.JobAdd(1002, new JobScheduler::RunOnceSchedule(1), NULL);
+        //scheduler.JobAdd(1001, new JobScheduler::RunOnceSchedule(nowSecs + 2), NULL);
+    //res = scheduler.JobAdd(1002, new JobScheduler::RunPeriodicSchedule(2, 5), NULL);
     
     // block forever unless there is a job that calls scheduler.Stop()
     scheduler.WaitToStop();