Merge branch 'master' of gitlab.science.ru.nl:mlubbers/mTask
[mTask.git] / client / main.c
index 9de18bc..4919d9d 100644 (file)
@@ -3,9 +3,13 @@
 #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"
@@ -20,6 +24,7 @@
 #define MSG_SDS_SPEC 's'
 #define MSG_SDS_DEL 'a'
 #define MSG_SDS_UPD 'u'
+#define MSG_SPEC 'c'
 
 void read_message(void)
 {
@@ -49,7 +54,12 @@ 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;
@@ -95,7 +105,9 @@ void loop(void)
 
 #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;
@@ -106,11 +118,13 @@ int main(int argc, char *argv[]){
        sds_init();
        task_init();
        debug("sending device spec");
-       spec_send();
        while(true){
-               //Check for newetasks
+               //Check for newtasks
                loop();
                delay(100);
        }
+
+#ifndef NODEMCU
        return 0;
+#endif
 }