困っていること
Arduino IDE (Windows10 PC)にて,ESP32に書き込むプログラムのコンパイルをしています.
このプログラムをコンパイルするとエラーが出てきてしまいます。
原因が分からず困っています。
Arduino:1.8.13 (Windows 10), ボード:"ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"
エラーメッセージ
C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp: In member function 'unsigned char fauxmoESP::addDevice(const char*)': C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:345:80: error: format '%X' expects argument of type 'unsigned int', but argument 5 has type 'long unsigned int' [-Werror=format=] snprintf_P(uuid, sizeof(uuid), PSTR("%02X%06X46584D\0"), device_id, chip_id); // DEV_ID + CHIPID + "FXM" ^ C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:345:80: error: embedded '\0' in format [-Werror=format-contains-nul] C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:345:80: error: format '%X' expects argument of type 'unsigned int', but argument 5 has type 'long unsigned int' [-Werror=format=] C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:345:80: error: embedded '\0' in format [-Werror=format-contains-nul] C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:350:46: error: format '%X' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Werror=format=] sprintf(serial, "221703K0%06X\0", chip_id); // "221703K0" + CHIPID ^ C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:350:46: error: embedded '\0' in format [-Werror=format-contains-nul] C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:350:46: error: format '%X' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Werror=format=] C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:350:46: error: embedded '\0' in format [-Werror=format-contains-nul] C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp: In member function 'bool fauxmoESP::renameDevice(unsigned char, const char*)': C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:370:11: warning: comparison is always true due to limited range of data type [-Wtype-limits] if (0 <= id && id <= _devices.size()) { ^ C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp: In member function 'char* fauxmoESP::getDeviceName(unsigned char, char*, size_t)': C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:380:11: warning: comparison is always true due to limited range of data type [-Wtype-limits] if (0 <= id && id <= _devices.size()) { ^ C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp: In member function 'void fauxmoESP::setState(unsigned char, bool)': C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a\src\fauxmoESP.cpp:387:11: warning: comparison is always true due to limited range of data type [-Wtype-limits] if (0 <= id && id <= _devices.size()) { ^ cc1plus.exe: some warnings being treated as errors 「WiFi.h」に対して複数のライブラリが見つかりました 使用済:C:\Users\kaika\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\WiFi 未使用:D:\Program Files (x86)\Arduino\libraries\WiFi 次のフォルダのライブラリWiFiバージョン1.0を使用中:C:\Users\kaika\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\libraries\WiFi 次のフォルダのライブラリxoseperez-fauxmoesp-985880034f3aバージョン2.4.4を使用中:C:\Arduino sketch\Arduino\libraries\xoseperez-fauxmoesp-985880034f3a 次のフォルダのライブラリAsyncTCP-masterバージョン1.1.1を使用中:C:\Arduino sketch\Arduino\libraries\AsyncTCP-master exit status 1 ボードESP32 Dev Moduleに対するコンパイル時にエラーが発生しました。
プログラム
C++
1#include <Arduino.h> 2#include <WiFi.h> 3#include "fauxmoESP.h" 4#define SERIAL_BAUDRATE 115200 5#define LED 2 6 7fauxmoESP fauxmo; 8 9char ssid[] = ""; 10char password[] = ""; 11 12// ----------------------------------------------------------------------------- 13// Wifi 14// ----------------------------------------------------------------------------- 15 16void wifiSetup() { 17 18 // Set WIFI module to STA mode 19 WiFi.mode(WIFI_STA); 20 21 // Connect 22 Serial.printf("[WIFI] Connecting to %s ",ssid); 23 WiFi.begin(ssid, password); 24 25 // Wait 26 while (WiFi.status() != WL_CONNECTED) { 27 Serial.print("."); 28 delay(100); 29 } 30 Serial.println(); 31 32 // Connected! 33 Serial.printf("[WIFI] STATION Mode, SSID: %s, IP address: %s\n", WiFi.SSID().c_str(), WiFi.localIP().toString().c_str()); 34 35} 36 37void setup() { 38 39 // Init serial port and clean garbage 40 Serial.begin(SERIAL_BAUDRATE); 41 Serial.println(); 42 Serial.println(); 43 44 // Wifi 45 wifiSetup(); 46 47 // LED 48 pinMode(LED, OUTPUT); 49 digitalWrite(LED, HIGH); 50 51 // You have to call enable(true) once you have a WiFi connection 52 // You can enable or disable the library at any moment 53 // Disabling it will prevent the devices from being discovered and switched 54 fauxmo.enable(true); 55 56 // Add virtual devices 57 fauxmo.addDevice("照明"); 58 59 // fauxmoESP 2.0.0 has changed the callback signature to add the device_id, 60 // this way it's easier to match devices to action without having to compare strings. 61 fauxmo.onSetState([](unsigned char device_id, const char * device_name, bool state) { 62 Serial.printf("[MAIN] Device #%d (%s) state: %s\n", device_id, device_name, state ? "ON" : "OFF"); 63 digitalWrite(LED, state); 64 }); 65 66 // Callback to retrieve current state (for GetBinaryState queries) 67 fauxmo.onGetState([](unsigned char device_id, const char * device_name) { 68 return digitalRead(LED); 69 }); 70 71} 72 73void loop() { 74 75 // Since fauxmoESP 2.0 the library uses the "compatibility" mode by 76 // default, this means that it uses WiFiUdp class instead of AsyncUDP. 77 // The later requires the Arduino Core for ESP8266 staging version 78 // whilst the former works fine with current stable 2.3.0 version. 79 // But, since it's not "async" anymore we have to manually poll for UDP 80 // packets 81 fauxmo.handle(); 82 83 static unsigned long last = millis(); 84 if (millis() - last > 5000) { 85 last = millis(); 86 Serial.printf("[MAIN] Free heap: %d bytes\n", ESP.getFreeHeap()); 87 } 88 89}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。