#include <stdlib.h>
#include <string.h>
-#ifdef STM
-#else
+#ifdef LINUX
#include <stdio.h>
+#elif defined NODEMCU
+#include "ets_sys.h"
+#include "osapi.h"
+#include "gpio.h"
+#include "os_type.h"
#endif
#include "interpret.h"
#include "mTaskSymbols.h"
#include "sds.h"
+#include "spec.h"
#include "task.h"
#include "interface.h"
#define MSG_SDS_SPEC 's'
#define MSG_SDS_DEL 'a'
#define MSG_SDS_UPD 'u'
+#define MSG_SPEC 'c'
void read_message(void)
{
debug("Receiving a task");
task_register();
break;
+ case MSG_SPEC:
+ debug("Receiving a spec request");
+ spec_send();
+ break;
case '\0':
+ debug("Server closed connection");
break;
case '\n':
break;
// debug("Task %d not implemented\n", ct);
continue;
}
- //Onshot task
- if(curtask->interval == 0){
- run_task(curtask);
- curtask->used = false;
- //Interrupt task
- } else if(curtask->interval & 32768){
+ //interrupt task
+ if(is_interrupt_task(curtask) && had_interrupt(curtask)){
debug("Interrupt task %d not implemented", ct);
- //Interval task, check if interval is passed
+ run_task(curtask);
+ //Interval task, and interval passed
} else if(cyclestart-curtask->lastrun > curtask->interval){
debug("Running interval task: %d", ct);
run_task(curtask);
+
+ //Oneshot task, thus disable
+ if(curtask->interval == 0){
+ curtask->used = false;
+ }
curtask->lastrun = cyclestart;
}
}
#ifdef STM
int main(void){
-#else
+#elif defined NODEMCU
+void ICACHE_FLASH_ATTR user_init(){
+#elif defined LINUX
int main(int argc, char *argv[]){
gargc = argc;
gargv = argv;
setup();
sds_init();
task_init();
- debug("booting up");
+ debug("sending device spec");
while(true){
- //Check for newetasks
+ //Check for newtasks
loop();
- delay(50);
+ delay(100);
}
+
+#ifndef NODEMCU
return 0;
+#endif
}