我正在尝试使用 fauxmo 控制 ESP8266。程序编译正确,但是当我运行 Alexa 应用程序来查找设备时,ESP 没有出现。
ESP 肯定连接到我的家庭网络,并且程序正在运行(我已经检查了串行输出)。其他联网设备,比如我的 Nest 恒温器也出现了。
任何关于为什么它可能不会出现的想法,非常感谢。
这是我的 wemos d1 mini 上的代码
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include "fauxmoESP.h"
#define WIFI_SSID "..."
#define WIFI_PASS "..."
#define SERIAL_BAUDRATE 115200
fauxmoESP fauxmo;
// -----------------------------------------------------------------------------
// Wifi
// -----------------------------------------------------------------------------
void wifiSetup() {
// Set WIFI module to STA mode
WiFi.mode(WIFI_STA);
// Connect
Serial.printf("[WIFI] Connecting to %s ", WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASS);
// Wait
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(100);
}
Serial.println();
// Connected!
Serial.printf("[WIFI] STATION Mode, SSID: %s, IP address: %s\n", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str());
}
void callback(uint8_t device_id, const char * device_name, bool state) {
Serial.print("Device "); Serial.print(device_name);
Serial.print(" state: ");
if (state) {
Serial.println("ON");
} else {
Serial.println("OFF");
}
}
void setup() {
// Init serial port and clean garbage
Serial.begin(SERIAL_BAUDRATE);
Serial.println("FauxMo demo sketch");
Serial.println("After connection, ask Alexa/Echo to 'turn <devicename> on' or 'off'");
// Wifi
wifiSetup();
// Fauxmo
fauxmo.addDevice("relay");
fauxmo.addDevice("pixels");
fauxmo.onMessage(callback);
}
void loop() {
fauxmo.handle();
}