Hello, all,
Thank you for maintaining this helpful site.
For the first time I'm using WiFi ESPNow on ESP32. The usage is pretty simple, and the relevant class is brough below. I get an error message - "expected unqualified-id before ')' token"; However, I don't know which line in my code invokes the method in the library. I'm focusing on the processReceivedMessage, which is being invoked by the onReceive event' simply because I had other issues that were solved when I declared rxBufferL as a simple string rather than volatile (I assumed that the event is some kind of interrupt service routine - is it correct?).
I am using Arduino IDE 2.3.4 that is running under Windows 10.
Thank you very much
Yona Gy
#ifndef ESP_NOW_TOP_S
#define ESP_NOW_TOP_S
/**
* @file
*
* EspNowUnicast.ino demonstrates how to transmit unicast ESP-NOW messages with @c WifiEspNow .
* You need two ESP8266 or ESP32 devices to run this example.
*
* Unicast communication requires the sender to specify the MAC address of the recipient.
* Thus, you must modify this program for each device.
*
* The recommended workflow is:
* @li 1. Flash the program onto device A.
* @li 2. Run the program on device A, look at serial console for its MAC address.
* @li 3. Copy the MAC address of device A, paste it in the @c PEER variable below.
* @li 4. Flash the program that contains A's MAC address onto device B.
* @li 5. Run the program on device A, look at serial console for its MAC address.
* @li 6. Copy the MAC address of device B, paste it in the @c PEER variable below.
* @li 7. Flash the program that contains B's MAC address onto device A.
*/
#include <arduino.h>
#include "WifiEspNow.h"
#include <WiFi.h>
class WENT {
public:
// static void printReceivedMessage(const uint8_t mac[WIFIESPNOW_ALEN], const uint8_t* buf, size_t count, void* arg);
String begin();
void send(String message);
private:
uint8_t peerMAC[WIFIESPNOW_ALEN];
} went;
void processReceivedMessage(const uint8_t peerMAC[WIFIESPNOW_ALEN],
const uint8_t* buf, size_t count, void* arg) {
noInterrupts();
String rxBufferL = "";
for (byte i = 0; i < count; i++)
rxBufferL += (char)buf[i];
Serial.print("Station #" + String(stationType));
Serial.println(": " + rxBufferL);
interrupts();
}
String WENT::begin() {
// Serial.println("WENT begin TP 1");
WiFi.persistent(false);
WiFi.mode(WIFI_AP);
WiFi.disconnect();
WiFi.softAP("ESPNOW", nullptr, 3);
WiFi.softAPdisconnect(false);
uint8_t mac[6];
WiFi.softAPmacAddress(mac);
Serial.printf("static uint8_t peer[]{0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X};\n",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
if (!WifiEspNow.begin())
return ("Error - WifiEspNow begin() failed");
// Serial.println("WENT begin TP 3");
WifiEspNow.onReceive(processReceivedMessage, nullptr);
// Serial.println("WENT begin TP 4");
if (!WifiEspNow.addPeer(peerMAC))
return ("Error - WifiEspNow addPeer() failed");
return "WifiEspNow Passed init and association";
}
void WENT::send(String txMessage) {
uint8_t count = sizeof(txMessage);
char msg[count + 1]; //as 1 char space for null is also required
strcpy(msg, txMessage.c_str());
msg[count] = '\0';
WifiEspNow.send(peerMAC, reinterpret_cast<const uint8_t*>(msg), count);
delay(1000);
}
#endif // ESP_NOW_TOP_S
The error message:
In file included from C:\Users\USER\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.3-cfea4f7c-v1\esp32c3/include/esp_eth/include/esp_eth_driver.h:18,
from C:\Users\USER\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.1\libraries\WiFi\src/WiFiGeneric.h:37,
from C:\Users\USER\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.1\libraries\WiFi\src/WiFiSTA.h:30,
from C:\Users\USER\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.1.1\libraries\WiFi\src/WiFi.h:34,
from E:\Current\Tractor\SWtractorCombined_V1.0\src\wifiEspNow\WifiEspNow.h:10,
from E:\Current\Tractor\SWtractorCombined_V1.0\src\wifiEspNow\EspNowTop.h:23,
from E:\Current\Tractor\SWtractorCombined_V1.0\TractorDecV7.x.h:88,
from E:\Current\Tractor\SWtractorCombined_V1.0\SWtractorCombined_V1.0.ino:33:
C:\Users\USER\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.3-cfea4f7c-v1\esp32c3/include/esp_eth/include/esp_eth_phy.h:207:25: error: expected unqualified-id before ')' token
207 | esp_err_t (*loopback)(esp_eth_phy_t *phy, bool enable);
| ^