• Arduino内部网页代理,网页穿透,公网访问Arduino内部网页


    Arduino内部网页代理,网页穿透,公网访问Arduino内部网页
    项目地址:https://github.com/IoTServ/esp8266-Arduino-web-proxy/tree/master
    看下效果: <ignore_js_op> <ignore_js_op>

    Arduino (2).png (24.01 KB, 下载次数: 2)

    下载附件

    2017-4-24 17:32 上传

     



    好了上代码:

    #include <ESP8266WiFi.h>
    const char* id     = "id";  //http://www.mcunode.com/proxy/id/LED  if id==4567  then url:http://www.mcunode.com/proxy/4567/LED
    const char* ssid     = "ssid";
    const char* password = "password";
    int ledPin = 13;
    const char* host = "www.mcunode.com";
    
    void setup() {
      Serial.begin(115200);
      delay(10);
    
      Serial.println();
      Serial.println();
      Serial.print("Connecting to ");
      Serial.println(ssid);
      
      WiFi.mode(WIFI_STA);
      WiFi.begin(ssid, password);
      
      while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
      }
    
      Serial.println("");
      Serial.println("WiFi connected");  
      Serial.println("IP address: ");
      Serial.println(WiFi.localIP());
    }
    
    int value = 0;
    
    void loop() {
      delay(5000);
      ++value;
    
      Serial.print("connecting to ");
      Serial.println(host);
      
      WiFiClient client;
      const int httpPort = 8001;
      if (!client.connect(host, httpPort)) {
        Serial.println("connection failed");
        return;
      }
    
    
    if (client.connected())
    {
      client.write(id);
      delay(1000);
      while (1)
      {
    
      String request = client.readStringUntil('
    ');
      Serial.print(request);
      client.flush();
    
      int value = LOW;
      if (request.indexOf("/LED=ON") != -1)  {
        digitalWrite(ledPin, HIGH);
        value = HIGH;
      }
      if (request.indexOf("/LED=OFF") != -1)  {
        digitalWrite(ledPin, LOW);
        value = LOW;
      }
    Serial.println(value);
    
    
      if(value == HIGH) {
        client.print("<h1> ESP8266 Arduino Web Server</h1>Led pin is now:on <br><br><a href="LED=ON""><button>Turn On </button></a><a href="LED=OFF""><button>Turn Off </button></a><br />");
      } else {
        client.print("<h1> ESP8266 Arduino Web Server</h1>Led pin is now:off  <br><br><a href="LED=ON""><button>Turn On </button></a><a href="LED=OFF""><button>Turn Off </button></a><br />");
      }
      
      }
    }
    }
    复制代码
    

      完全实现mcunode.com的服务端:https://github.com/IoTServ/McuNode-server 运行之后访问服务器的ip就行,也有安卓版服务器(没错,网站跑在安卓手机上),git大小限制,没传,而且是初始版本

  • 相关阅读:
    Spring AOP前置通知实例说明AOP相关概念
    什么是面向切面编程AOP
    关于IOC容器的一些个人理解
    在.Net Core WebAPI下给Swagger增加导出离线文档功能
    .Net Core ORM选择之路,哪个才适合你
    真香.小程序云开发(时光邮局小程序)
    Cordova的安装与配置
    JS三座大山再学习(三、异步和单线程)
    JS三座大山再学习(二、作用域和闭包)
    JS三座大山再学习(一、原型和原型链)
  • 原文地址:https://www.cnblogs.com/kekeoutlook/p/9722714.html
Copyright © 2020-2023  润新知