       Serial.print("ESIP");
       Serial.println(WiFi.localIP());
     } else if (buf[0] == 'R' && buf[1] == 'E' && buf[2] == 'S') {
-       Serial.println("ESRESTART");
+      Serial.println("ESRESTART");
       ESP.restart();
+    } else if (buf[0] == 'S' && buf[1] == 'E' && buf[2] == 'N') {
+      if (udpUp) {
+        udp.beginPacket(remIP, remPort);
+        udp.write(buf + 3);
+        udp.write('\n');
+        udp.endPacket();
+
+        Serial.print("ESSENT");
+        Serial.print(remIP);
+        Serial.print(":");
+        Serial.println(remPort);
+      } else {
+        Serial.println("ESUDPDOWN");
+      }
     }
 
     bufLen = 0;
     bufDone = false; 
   }
-  
+
   int packetSize = udp.parsePacket();
-  if (packetSize)
-  {
+  if (packetSize) {
     int len = udp.read(incomingPacket, 255);
     if (len > 0)
     {
       incomingPacket[len] = 0;
     }
     Serial.write(incomingPacket);
+
+    // Update remote IP to whoever just pinged us
+    remIP = udp.remoteIP();
   }
 }
 

void setup() {
    Serial.begin(57600);
    delay(10);

    buf = (char *)malloc(1024 * sizeof(char));

    delay(10);
    Serial.println("ESSTART");

    WiFi.setAutoReconnect(true);

    WiFi.onEvent(WiFiEvent);
    WiFi.begin(ssid, password);

    lastTime = 0;
}


