X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=client%2Fclient.c;h=b501e0fc1b15f6fc528b6a7a02130aad3e644c61;hb=2ebe31dbe4aeaae68d63ccdcb9072dec8c4180f6;hp=59c611fd87f0a11d747549ab573771e2038923c5;hpb=dcd48012f6e95d649b8fe3d0cd050ac1bdeafaf6;p=mTask.git diff --git a/client/client.c b/client/client.c index 59c611f..b501e0f 100644 --- a/client/client.c +++ b/client/client.c @@ -37,15 +37,25 @@ void read_message(void) case MSG_SDS_UPD: debug("Receiving an sds update"); //TODO do something with the return value - sds_update(); + c = read16(); + sds_update(c); break; case MSG_SDS_DEL: debug("Receiving a delete SDS request"); - sds_delete(); + c = read16(); + sds_delete(c); + write_byte('a'); + write16(c); + write_byte('\n'); break; case MSG_DEL_TASK: debug("Receiving a delete task request"); - task_delete(); + c = read16(); + task_delete(c); + //Write acknowledgement + write_byte('d'); + write16(c); + write_byte('\n'); break; case MSG_GET_TASK: debug("Receiving a task"); @@ -77,15 +87,10 @@ void loop(void) } loopmillis = getmillis(); #endif - debug("Loop"); - - struct task *t; - long cyclestart; - read_message(); //Run tasks - cyclestart = getmillis(); + unsigned long cyclestart = getmillis(); for(struct task *t = task_head(); t != NULL; t = task_next(t)){ //interrupt task if(is_interrupt_task(t) && had_interrupt(t)){ @@ -97,9 +102,9 @@ void loop(void) run_task(t); //Oneshot task, thus disable -// if(t->interval == 0){ -// curtask->used = false; -// } + if(t->interval == 0){ + task_delete(t->taskid); + } t->lastrun = cyclestart; } } @@ -115,11 +120,8 @@ int main(int argc, char *argv[]){ gargv = argv; #endif - //Initialize systems + //Initialize device independant functionality real_setup(); - sds_init(); - task_init(); - debug("sending device spec"); #ifndef ARDUINO_ESP8266_NODEMCU while(true){