EPS8266-Serial.printf()有效,但Serial.print()不起作用?

时间:2019-05-10 11:46:38

标签: printf esp8266 arduino-esp8266

我正在使用EPS8266和Arduino Mega。我将字符串通过WiFi传递到EPS8266,然后通过串行链接将它们传递到Mega。如果我使用j,下面的代码可以工作,但是如果我使用Serial.printf(),则会出现以下错误。

  

错误:重载“ print(uint8_t *&)”的调用不明确

代码...

Serial.print()

非常非常非常奇怪的是#include <ESP8266WiFi.h> #include <WebSocketsServer.h> const char* ssid = "SKYNET"; const char* password = "yourdogsmaidenname"; WebSocketsServer webSocket = WebSocketsServer(81); void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght) { //Serial.printf("[%u] get Message: %s\r\n", num, payload); switch(type) { case WStype_DISCONNECTED: break; case WStype_CONNECTED: { IPAddress ip = webSocket.remoteIP(num); // Serial.printf("[%u] Connected from %d.%d.%d.%d url: %s\r\n", num, ip[0], ip[1], ip[2], ip[3], payload); } break; case WStype_TEXT: { Serial.printf("[%u] get Text: %s\r\n", num, payload); //Serial.print(payload); } break; case WStype_BIN: { hexdump(payload, lenght); } // echo data back to browser webSocket.sendBIN(num, payload, lenght); break; } } void setup() { // Set up serial comms Serial.begin(115200); // Set up WiFi WiFi.begin(ssid, password); while(WiFi.status() != WL_CONNECTED) { delay(200); } Serial.println(WiFi.localIP()); delay(500); // Set up web socket webSocket.begin(); webSocket.onEvent(webSocketEvent); } void loop() { webSocket.loop(); } 今天早上工作正常。那么为什么这是个问题呢?

0 个答案:

没有答案