NゲージポイントをWi-Fiでリモート制御する(KATO/TOMIX対応)ソースコード

解説はこちら



#include <ESP8266WiFi.h>

// SSID,password of your router
const char* ssid = "your ssid";
const char* password = "your password";
// Host name or IP address, included in Javascript
const char* JSHost = "your ip address";

WiFiServer server(80);
WiFiClient client;

void setup() {
 // GPIO pin initialize
 pinMode(4, OUTPUT);
 pinMode(5, OUTPUT);

 // Connect to WiFi network
 Serial.begin(115200);
 Serial.print("Connecting to "); Serial.println(ssid);
 WiFi.begin(ssid, password);
 while (WiFi.status() != WL_CONNECTED) {
  delay(500); Serial.print(".");
 }
 Serial.println("");
 Serial.println("WiFi connected");
 Serial.print("IP address: "); Serial.println(WiFi.localIP());
 Serial.print("ESP Mac Address: "); Serial.println(WiFi.macAddress()); 
 
 // Start the server
 server.begin();
 Serial.println("Server started");
}

// main loop: HTTP Web server
void loop(){
 WiFiClient client = server.available(); // listen for incoming clients
 if (client) {              // if you get a client,
  Serial.println("New Client.");    // print a message out the serial port
  String path = "";
  String currentLine = "";       // make a String to hold incoming data from the client
  while (client.connected()) {     // loop while the client's connected
   if (client.available()) {      // if there's bytes to read from the client,
    char c = client.read();      // read a byte, then
    Serial.write(c);         // print it out the serial monitor
    if (c == '\n') {         // if the byte is a newline character

     // if the current line is blank, you got two newline characters in a row.
     // that's the end of the client HTTP request, so send a response:
     if (currentLine.length() == 0) {
      if (path.startsWith("/04")) {
       GPIOwrite(4); AJAX_Response(client);
      } else if (path.startsWith("/05")) {
       GPIOwrite(5); AJAX_Response(client);
      } else if (path.startsWith("/exe.js")) {
       HTTP_Response_JS(client);
      } else {
       HTTP_Response_default(client);
      }
      // break out of the while loop:
      break;
     } else {  // if you got a newline, then clear
      currentLine = "";
     }
    } else if (c != '\r') { // if you got anything else but a carriage return character,
     currentLine += c;   // add it to the end of the currentLine
    }

    // get the path
    if (currentLine.startsWith("GET /04")) { path = "/04"; }
    if (currentLine.startsWith("GET /05")) { path = "/05"; }
    if (currentLine.startsWith("GET /exe.js")) { path = "/exe.js"; }
   }
  }
  // close the connection:
  client.stop();
  Serial.println("Client Disconnected.");
 }
}

void GPIOwrite(int GPIONo) {
 Serial.println("--- GPIO write " + String(GPIONo) +" start ----");
 digitalWrite(GPIONo, HIGH);
 delay(100); // 100 milliseconds HIGH
 digitalWrite(GPIONo, LOW);
 Serial.println("---- GPIO " + String(GPIONo) +" end----");
}

void AJAX_Response(WiFiClient client){
 // response with empty contents
 Serial.println("---- response start AJAX ----");
 client.println("HTTP/1.1 200 OK");
 client.println("Content-type: application/json");
 client.println();
 client.println();
 Serial.println("---- response end AJAX ----");
}

void HTTP_Response_default(WiFiClient client) {

 Serial.println("---- response default start ----");
 // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
 // and a content-type so the client knows what's coming, then a blank line:
 client.println("HTTP/1.1 200 OK");
 client.println("Content-type: text/html");
 client.println();
 
 // the content of the HTTP response follows the header:
 String s = "";
 s = s + "<!DOCTYPE html><html lang=\"ja\">"
    + "<head>"
    + "<meta charset=\"utf-8\">"
    + "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0 \">"
    + "<meta name=\"apple-mobile-web-app-capable\" content=\"yes\">"
    + "<meta name=\"mobile-web-app-capable\" content=\"yes\">"
    + "<link rel=\"apple-touch-icon\" href=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADkAAAA5CAYAAACMGIOFAAAFO0lEQVRo3u2aZ1NbVxCGn70qSAIMCNQQTQhhmnHcknHGmfz4FCaxccM2phcDQqIYUUXR3Xw4ApLJZChqyNF+4o7Qvee5e87uvruSxz+8UL5xs/gfWA2yBlmDrEHWIEthzuv8kzpdaE8cCUVQrxdBKrZgBcgeQWodWZpDTo4Lh1SvF33yHEkMI05HBfGMnT9f+4ehvQMdH0P29wr05MAD5P4IYpmdrbZd8e0nloU4HGjfAHp4gLz8rTBI6Y5DHtD+soik10HtShJitwWwuuPmxXfFoFBIrfMggGazMPEaWV2ufCQJh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Gp5EVxIF29RprVNxoH5lsp1e1JVUgn0Vw+yYuFfN0CfwD2d83nVe9JMLXoeZ/U7QKPD228Z5pTZbDyDGH3MnBeGDhdaDAIbjdcMXKrLsiTEzSzk9+tFoQ6TPA5Pfl2IEUV2d2+6BxIKIycnpblPJbPkwCZDGAg1e1GD/bK9uibQRZSeh0dwFnuQo7J4WHZln316O68He/xQiyBOp1wG83X1HL5PTsHzX70NhNrsdBoJ+Lz5TWbFg6p6ytIi980p0afQCEDHpeZRInXh37/4vZn3OW6/A1DOnnlWPjq3wxMf0SbWpD2TqMU6uqKE4yKcB9NJ2HqY+GelHQK/eMX7P5BJNIBTjeVNj07g9QqMjuJtZ4swpkEZDONbKa5KyYlDVNVajXIGmQNsgZZgyyF/QW/KA/Bs8MF0AAAAABJRU5ErkJggg==\" />"
    + "<style type=\"text/css\">"
    + "body { position: fixed; overflow: hidden; width:100%; font-family: sans-serif; font-weight: bold; color: #329cac; background-color: #32373c; }"
    + "html, body { height: 90vmin; overflow: hidden; }"
    + "div#outer { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }"
    + "div#inner { width: 200px; height: 225px; }"
    + "table#title { text-align: center; }"
    + "</style>"
    + "<script type=\"text/javascript\" src=\"/exe.js\"></script>"
    + "</head>"
    + "<body>"
    + "<div id=\"outer\">"
    + "<div id=\"inner\">"
    + "<table id=\"title\"><tr><td>ポイントコントロール</td></tr>"
    + "<tr><td><img id=\"button1\" width=\"180\" height=\"180\" onclick=\"Button_Click();\" src=\"";
 client.println(s);
 s = "";
 s = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgdmVyc2lvbj0iMS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V1UmZmIiBvcGFjaXR5PSIxIiBmaWxsLW9wYWNpdHk9IjAiIHN0cm9rZT0iIzMyOWNhYyIgc3Ryb2tlLXdpZHRoPSI0IiBzdHJva2Utb3BhY2l0eT0iMSI+PC91c2U+PC9nPjwvZz48Zz48dXNlIHhsaW5rOmhyZWY9IiNjODRTbnhGdSIgb3BhY2l0eT0iMSIgZmlsbD0iI2Y5ZmJmYiIgZmlsbC1vcGFjaXR5PSIwIj48L3VzZT48Zz48dXNlIHhsaW5rOmhyZWY9IiNjODRTbnhGdSIgb3BhY2l0eT0iMSIgZmlsbC1vcGFjaXR5PSIwIiBzdHJva2U9IiMzMjljYWMiIHN0cm9rZS13aWR0aD0iNCIgc3Ryb2tlLW9wYWNpdHk9IjEiPjwvdXNlPjwvZz48L2c+PC9nPjwvZz48L3N2Zz4=";
 client.println(s);
 s = "";
 s = s + "\"></td></tr></table>"
    + "</div>"
    + "</div>"
    + "</body>"
    + "</html>";
 client.println(s);
 
 // The HTTP response ends with another blank line:
 client.println();
 Serial.println("---- response default end ----");
}

void HTTP_Response_JS(WiFiClient client) {
 Serial.println("---- response Javascript start ----");
 client.println("HTTP/1.1 200 OK");
 client.println("Content-type: text/javascript");
 client.println();
 String s = "";
 s = s + "var Host = \"" + JSHost + "\";"
    + "var status = 'R';"
    + "function Button_Click() {"
    + " var elem = document.getElementById(\"button1\");"
    + " switch (status) {"
    + "  case 'R':"
    + "   elem.src = \"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOn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PSIwIiBzdHJva2U9IiMzMjljYWMiIHN0cm9rZS13aWR0aD0iNCIgc3Ryb2tlLW9wYWNpdHk9IjEiPjwvdXNlPjwvZz48L2c+PC9nPjwvZz48L3N2Zz4=\";"    + "   runAJAX('/05');"
    + "   status = 'R';"
    + "   break;"
    + " }"
    + "}"
    + "function runAJAX(path) {"
    + " var xhr = new XMLHttpRequest();"
    + " xhr.onreadystatechange = function() {"
    + "  if(xhr.readyState == 4 && xhr.status == 200){"
    + "   /*alert(req.responseText);*/"
    + "  }"
    + " };"
    + " xhr.open(\"GET\", \"http://\" + Host + path, false);"
    + " xhr.setRequestHeader('Pragma', 'no-cache');"
    + " xhr.setRequestHeader('Cache-Control', 'no-cache');"
    + " xhr.setRequestHeader('If-Modified-Since', 'Thu, 01 Jun 1970 00:00:00 GMT');"
    + " xhr.send(null);"
    + " return;"
    + "}";
 client.println(s);
 client.println();
 Serial.println("---- response Javascript end ----");
}

ブログ気持玉

クリックして気持ちを伝えよう!

ログインしてクリックすれば、自分のブログへのリンクが付きます。

→ログインへ

なるほど(納得、参考になった、ヘー)
驚いた
面白い
ナイス
ガッツ(がんばれ!)
かわいい

気持玉数 : 0

この記事へのコメント

この記事へのトラックバック