a robot you can talk to when you're lonely

Dependencies:   HALLFX_ENCODER Motor RPCInterface mbed

Files at this revision

API Documentation at this revision

Comitter:
gmiles3
Date:
Tue Dec 13 16:00:55 2016 +0000
Parent:
1:61020847a0fe
Commit message:
minor changes

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 61020847a0fe -r 747b84e54088 main.cpp
--- a/main.cpp	Mon Dec 12 14:44:09 2016 +0000
+++ b/main.cpp	Tue Dec 13 16:00:55 2016 +0000
@@ -7,10 +7,10 @@
 
 Serial pc(USBTX, USBRX);
 Serial esp(p28, p27);
-char ssid[32] = "ThugMansion";
-char pwd[32] = "2paclives";
+char ssid[32] = "DelosLobbyWifi";
+char pwd[32] = "freezeallmotorfunctions";
 char port[32] = "1035"; // must be port forwarded
-char timeout[32] = "28800";
+char timeout[32] = "28800"; // 28800 is max
 volatile int tx_in=0;
 volatile int tx_out=0;
 volatile int rx_in=0;
@@ -55,16 +55,18 @@
     while (1) {
         getReply();
         memset(&rpc_in[0], 0, sizeof(rpc_in));
-        memset(&rpc_in[0], 0, sizeof(rpc_out));
-        int length = (int)rx_line[3] - 48;
+        memset(&rpc_out[0], 0, sizeof(rpc_out));
+        int length = (int)rx_line[3] - 48; // bytes 0 to 2 are trash; byte 3 is length of message
         if (length > 0 && length < 256) {
             for (int i = 0; i < length; i++) {
-                rpc_in[i] = rx_line[i+4];
+                rpc_in[i] = rx_line[i+4]; // bytes 4 to length+3 are the valid data
             }
             RPC::call(rpc_in, rpc_out);
             pc.printf("%s\n", rpc_out);
         }
-        strcpy(cmdbuff, "srv:close()\r\n");
+        // lambda function is event-triggered and non-persistent
+        // after it terminates, we need to close the existing connection and start another one
+        strcpy(cmdbuff, "srv:close()\r\n"); 
         sendCMD();
         wait(.5);
         getReply();