Compare commits

..

10 Commits
v1.4 ... main

6 changed files with 16 additions and 7 deletions

View File

@ -197,7 +197,7 @@ void setup()
Serial.begin(115200);
Serial.println();
myNet.begin("ZHNetwork");
myNet.setCryptKey("VERY_LONG_CRYPT_KEY");
// myNet.setCryptKey("VERY_LONG_CRYPT_KEY"); // If encryption is used, the key must be set same of all another ESP-NOW devices in network.
myNet.setOnBroadcastReceivingCallback(onBroadcastReceiving);
myNet.setOnUnicastReceivingCallback(onUnicastReceiving);
myNet.setOnConfirmReceivingCallback(onConfirmReceiving);
@ -239,6 +239,7 @@ void onBroadcastReceiving(const char *data, const uint8_t *sender)
Serial.print("Message: ");
Serial.println(data);
}
void onUnicastReceiving(const char *data, const uint8_t *sender)
{
Serial.print("Unicast message from MAC ");
@ -257,3 +258,5 @@ void onConfirmReceiving(const uint8_t *target, const uint16_t id, const bool sta
Serial.println(status ? " delivered." : " undelivered.");
}
```
Any feedback via [e-mail](mailto:github@zh.com.ru) would be appreciated. Or... [Buy me a coffee](https://paypal.me/aZholtikov).

View File

@ -10,7 +10,7 @@ void setup()
Serial.begin(115200);
Serial.println();
myNet.begin("ZHNetwork");
myNet.setCryptKey("VERY_LONG_CRYPT_KEY");
// myNet.setCryptKey("VERY_LONG_CRYPT_KEY"); // If encryption is used, the key must be set same of all another ESP-NOW devices in network.
myNet.setOnBroadcastReceivingCallback(onBroadcastReceiving);
myNet.setOnUnicastReceivingCallback(onUnicastReceiving);
Serial.print("MAC: ");
@ -33,6 +33,7 @@ void onBroadcastReceiving(const char *data, const uint8_t *sender)
Serial.print("Message: ");
Serial.println(data);
}
void onUnicastReceiving(const char *data, const uint8_t *sender)
{
Serial.print("Unicast message from MAC ");

View File

@ -13,7 +13,7 @@ void setup()
Serial.begin(115200);
Serial.println();
myNet.begin("ZHNetwork");
myNet.setCryptKey("VERY_LONG_CRYPT_KEY");
// myNet.setCryptKey("VERY_LONG_CRYPT_KEY"); // If encryption is used, the key must be set same of all another ESP-NOW devices in network.
myNet.setOnConfirmReceivingCallback(onConfirmReceiving);
Serial.print("MAC: ");
Serial.print(myNet.getNodeMac());
@ -33,7 +33,7 @@ void loop()
Serial.print(myNet.macToString(target));
Serial.println(" sended.");
myNet.sendUnicastMessage("Hello world!", target);
Serial.print("Unicast with confirm message to MAC ");
Serial.print(myNet.macToString(target));
Serial.print(" ID ");

View File

@ -1,5 +1,5 @@
name=ZHNetwork
version=1.4
version=1.41
author=Alexey Zholtikov
maintainer=Alexey Zholtikov
sentence=ESP-NOW based Mesh network for ESP8266/ESP32

View File

@ -35,7 +35,12 @@ ZHNetwork &ZHNetwork::setOnConfirmReceivingCallback(on_confirm_t onConfirmReceiv
error_code_t ZHNetwork::begin(const char *netName, const bool gateway)
{
randomSeed(analogRead(0));
#if defined(ESP8266)
randomSeed(os_random());
#endif
#if defined(ESP32)
randomSeed(esp_random());
#endif
if (strlen(netName) >= 1 && strlen(netName) <= 20)
strcpy(netName_, netName);
#ifdef PRINT_LOG

View File

@ -132,7 +132,7 @@ private:
static char netName_[20];
static char key_[20];
const char *firmware{"1.4"};
const char *firmware{"1.41"};
const uint8_t broadcastMAC[6]{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
uint8_t maxNumberOfAttempts_{3};
uint8_t maxWaitingTimeBetweenTransmissions_{50};