Fx0 hackathon team4

Dependencies:   NySNICInterface mbed-rtos mbed

Fork of RESTServerSample by KDDI Fx0 hackathon

Revision:
5:70c9f6045f2d
Parent:
4:99a67256b765
Child:
7:bdd579baaa91
--- a/control_motors.cpp	Sun Feb 15 02:55:36 2015 +0000
+++ b/control_motors.cpp	Sun Feb 15 03:38:17 2015 +0000
@@ -1,8 +1,8 @@
 #include "control_motors.h"
 
-void parse_request(char *request){
+bool parse_request(char *request){
     
-    bool errorFlag = false;
+    bool okFlag = false;
     
     char* str = strtok(request+1,"/");
     
@@ -21,6 +21,7 @@
 
                 // motor right
                 move(MOTOR_RIGHT, speed);
+                okFlag = true;
 
             }else if(strcmp(str, "left") == 0){
                 
@@ -31,9 +32,8 @@
 
                 // motor left
                 move(MOTOR_LEFT, speed);
-                
-            }else{
-                errorFlag = true;                
+                okFlag = true;
+
             }
             
         }else if(strcmp(str, "tail") == 0){
@@ -45,23 +45,26 @@
                     // tail start
                     start_shaking_tail();
                     
+                    okFlag = true;
+                    
                 }else if(strcmp(str, "end") == 0){
 
                     // tail end
                     stop_shaking_tail();
                     
-                }else{
-                    errorFlag = true;                
+                    okFlag = true;
+                    
                 }
-            }else{
-                errorFlag = true;                
             }
         }
     }
     
-    if(errorFlag){
+    if(!okFlag){
         printf("error: request=%s\n", request);
+        return false;
     }
+    
+    return true;
 }