Conformed SpanPoint to small change in ESP-NOW in Arduino-ESP32 version 3

Reflects small change to ESP-NOW data receive callback function.  Also updated examples to use Network instead of WiFi to obtain MAC address prior to WiFi being setup/used.
This commit is contained in:
Gregg 2024-07-14 16:23:46 -05:00
parent 6e9279db60
commit eaba8294b3
4 changed files with 7 additions and 6 deletions

View File

@ -57,12 +57,12 @@ void setup() {
Serial.begin(115200);
delay(1000);
Serial.printf("\n\nThis is a REMOTE Device with MAC Address = %s\n",WiFi.macAddress().c_str());
Serial.printf("\n\nThis is a REMOTE Device with MAC Address = %s\n",Network.macAddress().c_str());
Serial.printf("NOTE: This MAC Address must be entered into the corresponding SpanPoint() call of the MAIN Device.\n\n");
// In the line below, replace the MAC Address with that of your MAIN HOMESPAN DEVICE
mainDevice=new SpanPoint("84:CC:A8:11:B4:84",sizeof(float),0); // create a SpanPoint with send size=sizeof(float) and receive size=0
mainDevice=new SpanPoint("AC:67:B2:77:42:20",sizeof(float),0); // create a SpanPoint with send size=sizeof(float) and receive size=0
homeSpan.setLogLevel(1);
}

View File

@ -70,7 +70,7 @@ void setup() {
homeSpan.setLogLevel(1);
Serial.begin(115200);
delay(1000);
Serial.printf("Starting Remote Temperature Sensor. MAC Address of this device = %s\n",WiFi.macAddress().c_str());
Serial.printf("Starting Remote Temperature Sensor. MAC Address of this device = %s\n",Network.macAddress().c_str());
#endif
// In the line below, replace the MAC Address with that of your MAIN HOMESPAN DEVICE

View File

@ -2711,8 +2711,9 @@ boolean SpanPoint::send(const void *data){
///////////////////////////////
//void SpanPoint::dataReceived(const uint8_t *mac, const uint8_t *incomingData, int len){
void SpanPoint::dataReceived(const esp_now_recv_info *mac, const uint8_t *incomingData, int len){
void SpanPoint::dataReceived(const esp_now_recv_info *info, const uint8_t *incomingData, int len){
const uint8_t *mac=info->src_addr;
auto it=SpanPoints.begin();
for(;it!=SpanPoints.end() && memcmp((*it)->peerInfo.peer_addr,mac,6)!=0; it++);

View File

@ -807,7 +807,7 @@ class SpanPoint {
static QueueHandle_t statusQueue; // queue for communication between SpanPoint::dataSend and SpanPoint::send
static nvs_handle pointNVS; // NVS storage for channel number (only used for remote devices)
static void dataReceived(const esp_now_recv_info *mac, const uint8_t *incomingData, int len);
static void dataReceived(const esp_now_recv_info *info, const uint8_t *incomingData, int len);
static void init(const char *password="HomeSpan");
static void setAsHub(){isHub=true;}
static uint8_t nextChannel();