Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
a080869c5c | |||
9c3d35e1c3 | |||
49a4bd210d | |||
5e0822b8e9 | |||
915e2bf7b7 | |||
0812c15b85 | |||
4189c860aa | |||
7a8dbe40f0 | |||
6eab8cde49 | |||
d94bbe028c |
@ -197,7 +197,7 @@ void setup()
|
|||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println();
|
Serial.println();
|
||||||
myNet.begin("ZHNetwork");
|
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.setOnBroadcastReceivingCallback(onBroadcastReceiving);
|
||||||
myNet.setOnUnicastReceivingCallback(onUnicastReceiving);
|
myNet.setOnUnicastReceivingCallback(onUnicastReceiving);
|
||||||
myNet.setOnConfirmReceivingCallback(onConfirmReceiving);
|
myNet.setOnConfirmReceivingCallback(onConfirmReceiving);
|
||||||
@ -239,6 +239,7 @@ void onBroadcastReceiving(const char *data, const uint8_t *sender)
|
|||||||
Serial.print("Message: ");
|
Serial.print("Message: ");
|
||||||
Serial.println(data);
|
Serial.println(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onUnicastReceiving(const char *data, const uint8_t *sender)
|
void onUnicastReceiving(const char *data, const uint8_t *sender)
|
||||||
{
|
{
|
||||||
Serial.print("Unicast message from MAC ");
|
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.");
|
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).
|
||||||
|
@ -10,7 +10,7 @@ void setup()
|
|||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println();
|
Serial.println();
|
||||||
myNet.begin("ZHNetwork");
|
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.setOnBroadcastReceivingCallback(onBroadcastReceiving);
|
||||||
myNet.setOnUnicastReceivingCallback(onUnicastReceiving);
|
myNet.setOnUnicastReceivingCallback(onUnicastReceiving);
|
||||||
Serial.print("MAC: ");
|
Serial.print("MAC: ");
|
||||||
@ -33,6 +33,7 @@ void onBroadcastReceiving(const char *data, const uint8_t *sender)
|
|||||||
Serial.print("Message: ");
|
Serial.print("Message: ");
|
||||||
Serial.println(data);
|
Serial.println(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onUnicastReceiving(const char *data, const uint8_t *sender)
|
void onUnicastReceiving(const char *data, const uint8_t *sender)
|
||||||
{
|
{
|
||||||
Serial.print("Unicast message from MAC ");
|
Serial.print("Unicast message from MAC ");
|
||||||
|
@ -13,7 +13,7 @@ void setup()
|
|||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println();
|
Serial.println();
|
||||||
myNet.begin("ZHNetwork");
|
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);
|
myNet.setOnConfirmReceivingCallback(onConfirmReceiving);
|
||||||
Serial.print("MAC: ");
|
Serial.print("MAC: ");
|
||||||
Serial.print(myNet.getNodeMac());
|
Serial.print(myNet.getNodeMac());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=ZHNetwork
|
name=ZHNetwork
|
||||||
version=1.4
|
version=1.41
|
||||||
author=Alexey Zholtikov
|
author=Alexey Zholtikov
|
||||||
maintainer=Alexey Zholtikov
|
maintainer=Alexey Zholtikov
|
||||||
sentence=ESP-NOW based Mesh network for ESP8266/ESP32
|
sentence=ESP-NOW based Mesh network for ESP8266/ESP32
|
||||||
|
@ -35,7 +35,12 @@ ZHNetwork &ZHNetwork::setOnConfirmReceivingCallback(on_confirm_t onConfirmReceiv
|
|||||||
|
|
||||||
error_code_t ZHNetwork::begin(const char *netName, const bool gateway)
|
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)
|
if (strlen(netName) >= 1 && strlen(netName) <= 20)
|
||||||
strcpy(netName_, netName);
|
strcpy(netName_, netName);
|
||||||
#ifdef PRINT_LOG
|
#ifdef PRINT_LOG
|
||||||
|
@ -132,7 +132,7 @@ private:
|
|||||||
static char netName_[20];
|
static char netName_[20];
|
||||||
static char key_[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};
|
const uint8_t broadcastMAC[6]{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||||
uint8_t maxNumberOfAttempts_{3};
|
uint8_t maxNumberOfAttempts_{3};
|
||||||
uint8_t maxWaitingTimeBetweenTransmissions_{50};
|
uint8_t maxWaitingTimeBetweenTransmissions_{50};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user