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.
Diff: source/main.cpp
- Revision:
- 9:d6a9210bfd41
- Parent:
- 7:c4123a87abe2
- Child:
- 11:acaefb63fc6b
diff -r 51b6c5ed33f8 -r d6a9210bfd41 source/main.cpp --- a/source/main.cpp Fri Jul 14 22:36:37 2017 +0000 +++ b/source/main.cpp Mon Jul 17 18:33:51 2017 +0000 @@ -23,12 +23,34 @@ TracingLock.unlock(); } +static bool initTime() +{ + struct tm clock; + clock.tm_year = 2001 - 1900; + clock.tm_mon = 0; + clock.tm_mday = 1; + clock.tm_hour = 13; + clock.tm_min = 30; + clock.tm_sec = 0; + // time_t is in seconds + time_t time = mktime(&clock); + if (time == (time_t) - 1) { + error("Error setting clock."); + return false; + } + set_time(time); + printf("Time is set to: %s\n", ctime(&time)); + return true; +} + int main() { printf("\n==Borsch==\n"); - - uint8_t mac_addr[6] = {0x00, 0x08, 0xdc, 0x45, 0x56, 0x67}; - + +// if (initTime() == false) { +// exit(1); +// } + /* Setup tracing */ mbed_trace_mutex_wait_function_set( tracingWait ); // only if thread safety is needed mbed_trace_mutex_release_function_set( tracingRelease ); // only if thread safety is needed @@ -36,6 +58,7 @@ tr_info("**Started**"); //-> "[INFO][main]: this is an info msg" + uint8_t mac_addr[6] = {0x00, 0x08, 0xdc, 0x45, 0x56, 0x67}; NetworkInterface* nif = initNetworkStack(mac_addr); if (nif == NULL) { tr_error("**Terminated**"); @@ -60,7 +83,8 @@ 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::RunOnceSchedule(1), NULL); + 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);