Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
matteriot committed Mar 19, 2020
1 parent 3157949 commit 1beb183
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
3 changes: 1 addition & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
platform = espressif8266
board = d1
framework = arduino
lib_deps =
EspSoftwareSerial@6.8.0
upload_speed = 460800
15 changes: 6 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <SoftwareSerial.h>
// #include <SoftwareSerial.h>

const int httpPort = 80;
String deviceName = "家用卷帘门";
String version = "1.0";
ESP8266WebServer server(httpPort);
SoftwareSerial mySerial(D5, D6); // RX, TX
// SoftwareSerial mySerial(D5, D6); // RX, TX

const char* serverIndex = "<form method='POST' action='/update' enctype='multipart/form-data'><input type='file' name='update'><input type='submit' value='Update'></form>";

Expand All @@ -27,12 +27,10 @@ void handleLEDStatusChange(){
{
if (server.arg(i)=="up")
{
if (mySerial.available())
mySerial.write(up,7);
Serial.write(up,7);
}else if (server.arg(i)=="down")
{
if (mySerial.available())
mySerial.write(down,7);
Serial.write(down,7);
}
}
}
Expand Down Expand Up @@ -69,7 +67,7 @@ void handleNotFound(){
void setup(void){
WiFi.mode(WIFI_STA);
// 选取一种连接路由器的方式
// WiFi.begin("ap", "");
// WiFi.begin("ap","");
WiFi.beginSmartConfig();
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Expand Down Expand Up @@ -130,8 +128,7 @@ void setup(void){
});

server.begin();
// 软串口
mySerial.begin(9600);
Serial.begin(9600);

MDNS.addService("iotdevice", "tcp", httpPort);
}
Expand Down

0 comments on commit 1beb183

Please sign in to comment.