-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error compiling example #9
Comments
Hello, I would highly recommend this fork https://github.com/leodesigner/espNowFloodingMeshLibrary2 because unfortunately this library is no longer maintained. |
Thanks Marco |
This is a slave demo with https://github.com/arttupii/espNowFloodingMeshLibrary/issues/url: #include <Arduino.h>
#include "espNowFloodingMeshLibrary2/EspNowFloodingMesh.h"
struct MeshProbe_struct
{
char name[15]; // name of the mesh slave
uint64_t TimeStamp;
float MPU_Temperature;
};
MeshProbe_struct MeshProbe;
unsigned char secredKey[] = {0xB8, 0xF0, 0xF4, 0xB7, 0x4B, 0x1E, 0xD7, 0x1E, 0x8E, 0x4B, 0x7C, 0x8A, 0x09, 0xE0, 0x5A, 0xF1}; // AES 128bit
unsigned char iv[16] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
int ESP_NOW_CHANNEL = 1;
int bsid = 0x010101;
const int ttl = 3;
void espNowFloodingMeshRecv(const uint8_t *data, int len, uint32_t replyPrt)
{
static bool blink = false;
if ((blink = !blink))
{
digitalWrite(D9, HIGH);
}
else
{
digitalWrite(D9, LOW);
}
Serial.print("<=== received Data :");
Serial.println((const char *)data);
}
void setup()
{
Serial.begin(115200);
uint64_t chipid;
char chipname[256];
chipid = ESP.getEfuseMac();
sprintf(chipname, "TempHum%04X", (uint16_t)(chipid >> 32));
pinMode(D9, OUTPUT); // onboard LED
espNowFloodingMesh_secredkey(secredKey);
espNowFloodingMesh_setAesInitializationVector(iv);
espNowFloodingMesh_disableTimeDifferenceCheck();
espNowFloodingMesh_setToMasterRole(false, ttl);
espNowFloodingMesh_setToBatteryNode(false);
espNowFloodingMesh_RecvCB(espNowFloodingMeshRecv);
espNowFloodingMesh_begin(ESP_NOW_CHANNEL, bsid, true); // disconnect wifi true!
espNowFloodingMesh_ErrorDebugCB([](int level, const char *str)
{
if (level == 0) {
Serial.printf("ERROR %s", str);
}
if (level == 1) {
Serial.printf("WRN %s", str);
}
if (level == 2) {
Serial.printf("INFO %s", str);
} });
}
void loop()
{
espNowFloodingMesh_loop();
static uint64_t iCount = 0;
static unsigned long MeshLoopPM = 0;
unsigned long MeshLoopCM = millis();
if (MeshLoopCM - MeshLoopPM >= 2000) // sending mesh values every 2 seconds
{
strlcpy(MeshProbe.name, "TempHum", sizeof(MeshProbe.name));
MeshProbe.MPU_Temperature = (millis() * 0.001);
MeshProbe.TimeStamp = iCount++;
espNowFloodingMesh_send((uint8_t *)&MeshProbe, sizeof(MeshProbe), ttl); // set ttl to 3
Serial.printf("(%llu) from %s: temp: %f\n",
MeshProbe.TimeStamp,
MeshProbe.name,
MeshProbe.MPU_Temperature);
// -------- MeshLoop end --------
MeshLoopPM = MeshLoopCM;
}
} |
This is a master demo with https://github.com/arttupii/espNowFloodingMeshLibrary/issues/url: #include <Arduino.h>
#include "esp_wifi.h"
#include "espNowFloodingMeshLibrary2/EspNowFloodingMesh.h"
struct MeshProbe_struct
{
char name[15]; // name of the mesh slave
uint64_t TimeStamp;
float MPU_Temperature;
};
MeshProbe_struct MeshProbe;
unsigned char secredKey[] = {0xB8, 0xF0, 0xF4, 0xB7, 0x4B, 0x1E, 0xD7, 0x1E, 0x8E, 0x4B, 0x7C, 0x8A, 0x09, 0xE0, 0x5A, 0xF1}; // AES 128bit
unsigned char iv[16] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
int ESP_NOW_CHANNEL = 1;
int bsid = 0x010101;
const int ttl = 3;
void espNowFloodingMeshRecv(const uint8_t *data, int len, uint32_t replyPrt)
{
if (len > 0)
{
MeshProbe_struct *MeshProbe = (MeshProbe_struct *)data;
Serial.printf("from: %s %llu\n", MeshProbe->name, MeshProbe->TimeStamp);
}
}
void setup()
{
Serial.begin(115200);
int8_t power;
// esp_wifi_set_max_tx_power(20);
esp_wifi_get_max_tx_power(&power);
Serial.printf("wifi power: %d \n", power);
uint64_t chipid;
char chipname[256];
chipid = ESP.getEfuseMac();
sprintf(chipname, "Master%04X", (uint16_t)(chipid >> 32));
// Set device in AP mode to begin with
espNowFloodingMesh_RecvCB(espNowFloodingMeshRecv);
espNowFloodingMesh_secredkey(secredKey);
espNowFloodingMesh_disableTimeDifferenceCheck();
espNowFloodingMesh_setAesInitializationVector(iv);
espNowFloodingMesh_setToMasterRole(true); // Set ttl to 3.
espNowFloodingMesh_ErrorDebugCB([](int level, const char *str)
{
if (level == 0) {
Serial.printf("ERROR %s", str);
}
if (level == 1) {
Serial.printf("WRN %s", str);
}
if (level == 2) {
Serial.printf("INFO %s", str);
} });
espNowFloodingMesh_begin(ESP_NOW_CHANNEL, bsid, true);
}
void loop()
{
static unsigned long counter = 0;
static unsigned long m = millis();
if (m + 2000 < millis())
{
char Message[35]{};
snprintf(Message, sizeof(Message), "Master: %lu", counter);
espNowFloodingMesh_sendAndHandleReply((uint8_t *)&Message, sizeof(Message), 3, [](const uint8_t *data, int len)
{
if(len>0) {
Serial.print(">");
Serial.println((const char*)data);
} });
m = millis();
counter++;
}
M5.update();
espNowFloodingMesh_loop();
// delay(10);
} |
Many thanks, tomorrow i will test it. Marco |
Dear Armin, your sample works fine, many thanks I would like to ask you another information, if you can: //popolate array in setup //and send in delayed loop but over the 229 bytes size array generate error did you know why? the function "espNowFloodingMesh_send" has defined with uint8_t, I thinks that could work until 255 bytes |
Hi Marco, You can split your message into two different packets and send them one after the other. (Make sure, that the 1st packet is received properly, before send the 2nd one...) |
Yes, many thanks, i have founded tha table of byted used. another little help, i have tryed to change channel ESP_NOW_CHANNEL from 1 to 2 or 5 on both master/slave code, but works only with 1. i will pay you a pizza, for help! Marco |
Depends on... Otherwise my code should work with different channels... BR, Armin |
Of course, on the master i think to have a web server for ota update.
Tomorrow i will check.
Many many thanks
Marco Piai
…-------- Messaggio originale --------
Da: Armin ***@***.***>
Data: 27/02/23 18:29 (GMT+01:00)
A: arttupii/espNowFloodingMeshLibrary ***@***.***>
Cc: Marco Piai ***@***.***>, Author ***@***.***>
Oggetto: Re: [arttupii/espNowFloodingMeshLibrary] error compiling example (Issue #9)
Depends on...
Are you using WiFi at the same Time?
Than WiFi and ESP-Now must have both the same channel.
Otherwise my code should work with different channels...
BR, Armin
—
Reply to this email directly, view it on GitHub<#9 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AV4SRTDGNFJ5TKM64JJDINTWZTP5VANCNFSM6AAAAAAVEVLD2Q>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Dear, i don't understand where i'm wrong Thanks |
You're right, I forgot something... This you have to remove if you do not use a M5Atom device: |
Master#include <M5Atom.h>
#include <Arduino.h>
#include <WiFi.h>
#include "esp_wifi.h"
#include "espNowFloodingMeshLibrary2/EspNowFloodingMesh.h"
struct MeshProbe_struct
{
char name[15]; // name of the mesh master
uint64_t TimeStamp;
float MPU_Temperature;
};
MeshProbe_struct MeshProbe;
unsigned char secredKey[] = {0xB8, 0xF0, 0xF4, 0xB7, 0x4B, 0x1E, 0xD7, 0x1E, 0x8E, 0x4B, 0x7C, 0x8A, 0x09, 0xE0, 0x5A, 0xF1}; // AES 128bit
unsigned char iv[16] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
int ESP_NOW_CHANNEL = 11;
int bsid = 0x010101;
const int ttl = 3;
void espNowFloodingMeshRecv(const uint8_t *data, int len, uint32_t replyPrt)
{
if (len > 0)
{
MeshProbe_struct *MeshProbe = (MeshProbe_struct *)data;
Serial.printf(" >=== received Data from: %s %llu %6.2f\n", MeshProbe->name, MeshProbe->TimeStamp, MeshProbe->MPU_Temperature);
}
}
void setup()
{
Serial.begin(115200);
Serial.println(F("Welcome to ESP-NOW Master"));
int8_t power;
// esp_wifi_set_max_tx_power(20);
esp_wifi_get_max_tx_power(&power);
Serial.printf("wifi power: %d \n", power);
uint64_t chipid;
char chipname[256];
chipid = ESP.getEfuseMac();
sprintf(chipname, "Master%04X", (uint16_t)(chipid >> 32));
espNowFloodingMesh_RecvCB(espNowFloodingMeshRecv);
espNowFloodingMesh_secredkey(secredKey);
espNowFloodingMesh_disableTimeDifferenceCheck();
espNowFloodingMesh_setAesInitializationVector(iv);
espNowFloodingMesh_setToMasterRole(true); // Set ttl to 3.
espNowFloodingMesh_ErrorDebugCB([](int level, const char *str)
{
if (level == 0) {
Serial.printf("ERROR %s", str);
}
if (level == 1) {
Serial.printf("WRN %s", str);
}
if (level == 2) {
Serial.printf("INFO %s", str);
} });
espNowFloodingMesh_begin(ESP_NOW_CHANNEL, bsid, true);
Serial.println(F("WiFi Settings before setting new channel"));
WiFi.printDiag(Serial); // shows default channel
ESP_ERROR_CHECK(esp_wifi_set_channel(ESP_NOW_CHANNEL, WIFI_SECOND_CHAN_NONE));
Serial.println(F("WiFi Settings after setting new channel"));
WiFi.printDiag(Serial); // shows chosen EspNow channel
}
void loop()
{
espNowFloodingMesh_loop();
static uint64_t iCount = 0;
static unsigned long MeshLoopPM = 0;
unsigned long MeshLoopCM = millis();
if (MeshLoopCM - MeshLoopPM >= 2000) // sending mesh values every 2 seconds
{
strlcpy(MeshProbe.name, "Master", sizeof(MeshProbe.name));
MeshProbe.MPU_Temperature = (millis() * 0.001);
MeshProbe.TimeStamp = iCount++;
espNowFloodingMesh_send((uint8_t *)&MeshProbe, sizeof(MeshProbe), ttl); // set ttl to 3
Serial.printf("Send to Slave (%llu) from %s: Temp: %6.2f\n",
MeshProbe.TimeStamp,
MeshProbe.name,
MeshProbe.MPU_Temperature);
// -------- MeshLoop end --------
MeshLoopPM = MeshLoopCM;
}
} |
Slave#include <M5Atom.h>
#include <Arduino.h>
#include <WiFi.h>
#include "esp_wifi.h"
#include "espNowFloodingMeshLibrary2/EspNowFloodingMesh.h"
struct MeshProbe_struct
{
char name[15]; // name of the mesh slave
uint64_t TimeStamp;
float MPU_Temperature;
};
MeshProbe_struct MeshProbe;
unsigned char secredKey[] = {0xB8, 0xF0, 0xF4, 0xB7, 0x4B, 0x1E, 0xD7, 0x1E, 0x8E, 0x4B, 0x7C, 0x8A, 0x09, 0xE0, 0x5A, 0xF1}; // AES 128bit
unsigned char iv[16] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
int ESP_NOW_CHANNEL = 11;
int bsid = 0x010101;
const int ttl = 3;
void espNowFloodingMeshRecv(const uint8_t *data, int len, uint32_t replyPrt)
{
MeshProbe_struct *MeshProbe = (MeshProbe_struct *)data;
Serial.printf(" >=== received Data from: %s %llu %6.2f\n", MeshProbe->name, MeshProbe->TimeStamp, MeshProbe->MPU_Temperature);
}
void setup()
{
Serial.begin(115200);
Serial.println(F("Welcome to ESP-NOW Slave"));
int8_t power;
// esp_wifi_set_max_tx_power(20);
esp_wifi_get_max_tx_power(&power);
Serial.printf("wifi power: %d \n", power);
uint64_t chipid;
char chipname[256];
chipid = ESP.getEfuseMac();
sprintf(chipname, "TempHum%04X", (uint16_t)(chipid >> 32));
espNowFloodingMesh_secredkey(secredKey);
espNowFloodingMesh_setAesInitializationVector(iv);
espNowFloodingMesh_disableTimeDifferenceCheck();
espNowFloodingMesh_setToMasterRole(false, ttl);
espNowFloodingMesh_setToBatteryNode(false);
espNowFloodingMesh_RecvCB(espNowFloodingMeshRecv);
espNowFloodingMesh_ErrorDebugCB([](int level, const char *str)
{
if (level == 0) {
Serial.printf("ERROR %s", str);
}
if (level == 1) {
Serial.printf("WRN %s", str);
}
if (level == 2) {
Serial.printf("INFO %s", str);
} });
espNowFloodingMesh_begin(ESP_NOW_CHANNEL, bsid, true); // disconnect wifi true!
Serial.println(F("WiFi Settings before setting new channel"));
WiFi.printDiag(Serial); // shows default channel
ESP_ERROR_CHECK(esp_wifi_set_channel(ESP_NOW_CHANNEL, WIFI_SECOND_CHAN_NONE));
Serial.println(F("WiFi Settings after setting new channel"));
WiFi.printDiag(Serial); // shows chosen EspNow channel
}
void loop()
{
espNowFloodingMesh_loop();
static uint64_t iCount = 0;
static unsigned long MeshLoopPM = 0;
unsigned long MeshLoopCM = millis();
if (MeshLoopCM - MeshLoopPM >= 2000) // sending mesh values every 2 seconds
{
strlcpy(MeshProbe.name, "TempHum", sizeof(MeshProbe.name));
MeshProbe.MPU_Temperature = (millis() * 0.001);
MeshProbe.TimeStamp = iCount++;
espNowFloodingMesh_send((uint8_t *)&MeshProbe, sizeof(MeshProbe), ttl); // set ttl to 3
Serial.printf("Send to Master (%llu) from %s: temp: %6.2f\n",
MeshProbe.TimeStamp,
MeshProbe.name,
MeshProbe.MPU_Temperature);
// -------- MeshLoop end --------
MeshLoopPM = MeshLoopCM;
}
} |
YYYYEEEESSS Many thanks |
The second error in the opening post:
is due to a bug in The enumerator |
i'm trying to compile example in platformio
i get this errors:
src/main.cpp: In function 'void setup()':
src/main.cpp:20:43: error: too few arguments to function 'void espNowFloodingMesh_begin(int, int)'
espNowFloodingMesh_begin(ESP_NOW_CHANNEL);
^
In file included from src/main.cpp:3:
.pio/libdeps/esp32doit-devkit-v1_COM4/EspNowFloodingMesh/EspNowFloodingMesh.h:19:10: note: declared here
void espNowFloodingMesh_begin(int channel, int bsid);
and:
.pio/libdeps/esp32doit-devkit-v1_COM4/EspNowFloodingMesh/wifi802_11.cpp: In function 'void wifi_802_11_send(const uint8_t*, int)':
.pio/libdeps/esp32doit-devkit-v1_COM4/EspNowFloodingMesh/wifi802_11.cpp:125:78: error: cannot convert 'esp_interface_t' to 'wifi_interface_t'
esp_wifi_80211_tx(ESP_IF_WIFI_STA, buf, sizeof(raw_HEADER) + len+ 2, true);
^
In file included from .pio/libdeps/esp32doit-devkit-v1_COM4/EspNowFloodingMesh/wifi802_11.cpp:4:
C:/Users/marco/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/esp_wifi/include/esp_wifi.h:984:46: note: initializing argument 1 of 'esp_err_t esp_wifi_80211_tx(wifi_interface_t, const void*, int, bool)'
esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, bool en_sys_seq);
can anyone help me?
thanks
The text was updated successfully, but these errors were encountered: