Eu pretendo usar o rc switch com o output gpio13-13
Agora estou tendo :
wdt reset
ets Jan 8 2013,rst cause:4, boot mode:(1,6)
wdt reset
#include <ESP8266WiFi.h>
#include <RCSwitch.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <SoftwareSerial.h>
const int switchPin = 3;
WiFiServer server(1337);
WiFiClient client;
RCSwitch mySwitch = RCSwitch();
int tipo = 2;
const char *ssid = "xxx";
const char *password = "xxx";
void setup() {
mySwitch.enableTransmit(switchPin);
delay(1000);
mySwitch.setPulseLength(360);
Serial.begin(115200);
WiFi.begin(ssid, password);
pinMode(switchPin, OUTPUT);
if (tipo == 1) {
//WiFi.config(ip, dns, gateway, subnet);
WiFi.config('192.168.4.1', '192.168.4.1', '192.168.4.1', '255.255.255.0');
}
Serial.println("HTTP server started");
if (tipo == 2) {
Serial.println("Esta em modo cliente");
// printWiFiStatus();
} else {
Serial.println("Esta em modo servidor");
Serial.println("Acess Point : 192.168.4.1 - 192.168.4.1 - 192.168.4.1 - 255.255.255.0");
}
server.begin();
}
void loop() {
if (tipo == 2) {
if (WiFi.status() != WL_CONNECTED) {
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
// Print the new IP to Serial.
printWiFiStatus();
} else {
// printWiFiStatus();
}
}
client = server.available();
if (client) {
Serial.println("Client connected.");
char command = ' ';
while (client.connected()) {
if (client.available()) {
command = client.read();
if (command == 'H') {
client.write("teste1");
Serial.println('A');
} else if (command == 'L') {
client.write("teste2");
}
}
Serial.println('C');
Serial.println(command);
}
Serial.println("Client disconnected.");
client.stop();
}
}
void printWiFiStatus() {
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}