Costa / Mbed 2 deprecated MBED_SERVER

Dependencies:   mbed

Fork of MBED_SERVER_SETUP by Costa

Revision:
2:49b2668be97c
Parent:
1:b7470b5a6b23
Child:
3:8534d8489cbc
--- a/main.cpp	Thu Jun 16 14:18:44 2016 +0000
+++ b/main.cpp	Fri Jun 17 09:38:27 2016 +0000
@@ -48,6 +48,7 @@
  
 char ipAddress[20];
 char macAddress[32];
+char pedometer_channel[3];
 char *buffer;
 unsigned int bufferPnt=0;
  
@@ -128,6 +129,9 @@
     dev.attach(&dev_recv, Serial::RxIrq);
     pc.printf("Start up\n\r");
     char * resp=NULL;
+    int pedometer_channel;
+    char *dummy;
+
     pc.printf("Here \n\r");
     while(1) {
         if (ready) {
@@ -200,61 +204,57 @@
                         INFO("mac Address = %s", macAddress);
                         INFO("IP Address = %s", ipAddress);
                           dev.printf("AT+CIPMUX=1\r\n");
-                        state=20;
+                        state++;
                     }
  
                     break;
                 }
-                case 8: {
-                    resp=OKResponse(buffer,"OK");
+                case 8: { //initialize server
+                resp=OKResponse(buffer,"OK");
                     if (resp!=NULL) {
                        INFO("Ready");
                        dev.printf("AT+CIPSERVER=1,8080\r\n");
                     state++;
-
                     }
- 
                 }
-    /*            
-                case 9: {hghjgh
-                    resp=OKResponse(buffer,"OK");
+                break;
+                case 9: { //gets pedometer channel
+                resp=OKResponse(buffer,"PEDOMETER");  
+                dev.printf("PEDOMETER,1,2,3");              
                     if (resp!=NULL) {
-                       INFO("Ready");
-                         strtok(NULL,"\"");
-                         strcpy(macAddress,strtok(NULL,"\""));
+                       INFO("Finding pedometer channel2");
+                        char *strt = strtok(buffer,",");
+                        strcpy(pedometer_channel,strtok(NULL,","));
+                        strtok(NULL,",");
+                         strcpy(macAddress,strtok(NULL,","));
                         INFO("mac Address = %s", macAddress);
-                        INFO("IP Address = %s", ipAddress);
-                          dev.printf("AT+CIPMUX=1\r\n");
+                        INFO("pedometer_channel = %s", pedometer_channel);
+
+                     //    pedometer_channel = strtol(ipAddress, NULL, 10);
+                       // INFO("Pedometer Channel = %s", ipAddress);
                         state++;
+                    }                      
+                }
+                
+                case 10: {
+                    if (resp!=NULL) {
+                       INFO("Testing connection");
                        state++; 
-                       dev.printf("AT+CIPSEND=4,10\r\n");
+                       dev.printf("AT+CIPSEND=%u,6\r\n",pedometer_channel);
                     }
  
                      break;
                      }
-   //                 case 10: {
-    //                resp=OKResponse(buffer,">");
-    //                if (resp!=NULL) {
-    //                   INFO("SENDING");
-      //                 state++; 
-    //                   touch=tsi.readPercentage();
-         //              dev.printf("TSI=%1.2f\n\r",touch);
-       //                pc.printf("   ############  tsi=%1.2f\n\r",touch);
-                       //INFO("sensor=%1.2f",float)tsi.readPercentage());
-                    }
-                    case 11: {
-                    resp=OKResponse(buffer,"SEND OK");
+                case 11: {
+                    resp=OKResponse(buffer,">");
                     if (resp!=NULL) {
-                       INFO("SEND OK");
- //                      state=9; 
-                       //wait(2);
-                       }
-                       wait(1);
- //                      state=9; 
-                    }
-                    
-                    
- */
+                        INFO("SENDING");
+                        state++; 
+                        dev.printf("Hi ed!\r\n");
+                    state=9;
+                    } 
+                }
+
                      break;
                 }