10 #include "interpret.h"
11 #include "mTaskSymbols.h"
15 #include "interface.h"
17 #define MSG_GET_TASK 't'
18 #define MSG_DEL_TASK 'd'
19 #define MSG_SDS_SPEC 's'
20 #define MSG_SDS_DEL 'a'
21 #define MSG_SDS_UPD 'u'
26 void read_message(void)
29 if(input_available()){
30 uint8_t c
= read_byte();
31 debug("Receiving input: %c %02x\n", c
, c
);
34 debug("Receiving an sds");
38 debug("Receiving an sds update");
39 //TODO do something with the return value
43 debug("Receiving a delete SDS request");
47 debug("Receiving a delete task request");
50 //Write acknowledgement
56 debug("Receiving a task");
60 debug("Receiving a spec request");
64 debug("Server closed connection");
69 debug("Unknown message: %X", c
);
76 unsigned long loopmillis
= 0;
79 #ifdef ARDUINO_ESP8266_NODEMCU
80 if(getmillis()-loopmillis
< LOOPDELAY
){
83 loopmillis
= getmillis();
90 unsigned long cyclestart
= getmillis();
91 for(struct task
*t
= task_head(); t
!= NULL
; t
= task_next(t
)){
93 if(is_interrupt_task(t
) && had_interrupt(t
)){
94 debug("Interrupt task %d not implemented", t
->taskid
);
96 //Interval task, and interval passed
97 } else if(cyclestart
-t
->lastrun
> t
->interval
){
98 debug("Running interval task: %d", t
->taskid
);
101 //Oneshot task, thus disable
102 if(t
->interval
== 0){
103 task_delete(t
->taskid
);
105 t
->lastrun
= cyclestart
;
112 #elif defined ARDUINO_ESP8266_NODEMCU
115 int main(int argc
, char *argv
[]){
124 debug("sending device spec");
126 #ifndef ARDUINO_ESP8266_NODEMCU