2 Commits
v1.3 ... v1.31

Author SHA1 Message Date
62acd2a386 Version 1.31
Added gateway mode support.
2023-01-03 17:55:08 +03:00
506acf1fc0 Minor changes 2022-12-24 13:48:16 +03:00
4 changed files with 11 additions and 10 deletions

View File

@ -5,10 +5,10 @@ A simple library for creating ESP-NOW based Mesh network for ESP8266/ESP32.
## Features
1. The maximum size of transmitted data is 200 bytes. Currently only unencrypted messages.
2. All nodes are not visible to the network scanner (for the ESP_NOW mode only).
2. All nodes are not visible to the network scanner.
3. Not required a pre-pairings for data transfer.
4. Broadcast or unicast data transmission.
5. There are no periodic/synchronous messages on the network. All devices are in "silent mode" and do not "hum" into the air (for the ESP_NOW mode only).
5. There are no periodic/synchronous messages on the network. All devices are in "silent mode" and do not "hum" into the air.
6. Each node has its own independent routing table, updated only as needed.
7. Each node will receive/send a message if it "sees" at least one device on the network.
8. The number of devices on the network and the area of use is not limited (hypothetically). :-)
@ -25,7 +25,7 @@ A simple library for creating ESP-NOW based Mesh network for ESP8266/ESP32.
## Notes
1. Possibility uses WiFi AP or STA modes at the same time with ESP-NOW using the standard libraries.
2. For correct work at ESP-NOW + STA mode your WiFi router must be set on channel 1.
2. For correct work at ESP-NOW + STA mode your WiFi router must be set on channel 1 and set gateway mode.
## Function descriptions
@ -73,6 +73,7 @@ Note. If network name not set node will work with all ESP-NOW networks. If set n
```cpp
myNet.begin("ZHNetwork");
myNet.begin("ZHNetwork", true); // Gateway mode.
```
### Sends broadcast message to all nodes

View File

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

View File

@ -31,7 +31,7 @@ ZHNetwork &ZHNetwork::setOnConfirmReceivingCallback(on_confirm_t onConfirmReceiv
return *this;
}
error_code_t ZHNetwork::begin(const char *netName)
error_code_t ZHNetwork::begin(const char *netName, const bool gateway)
{
randomSeed(analogRead(0));
if (strlen(netName) > 1 && strlen(netName) < 20)
@ -39,14 +39,14 @@ error_code_t ZHNetwork::begin(const char *netName)
#ifdef PRINT_LOG
Serial.begin(115200);
#endif
WiFi.mode(WIFI_STA);
WiFi.mode(gateway ? WIFI_AP_STA : WIFI_STA);
esp_now_init();
#if defined(ESP8266)
wifi_get_macaddr(STATION_IF, localMAC);
wifi_get_macaddr(gateway ? SOFTAP_IF : STATION_IF, localMAC);
esp_now_set_self_role(ESP_NOW_ROLE_COMBO);
#endif
#if defined(ESP32)
esp_wifi_get_mac((wifi_interface_t)ESP_IF_WIFI_STA, localMAC);
esp_wifi_get_mac(gateway ? (wifi_interface_t)ESP_IF_WIFI_AP : (wifi_interface_t)ESP_IF_WIFI_STA, localMAC);
#endif
esp_now_register_send_cb(onDataSent);
esp_now_register_recv_cb(onDataReceive);

View File

@ -80,7 +80,7 @@ public:
ZHNetwork &setOnUnicastReceivingCallback(on_message_t onUnicastReceivingCallback);
ZHNetwork &setOnConfirmReceivingCallback(on_confirm_t onConfirmReceivingCallback);
error_code_t begin(const char *netName = "");
error_code_t begin(const char *netName = "", const bool gateway = false);
void sendBroadcastMessage(const char *data);
void sendUnicastMessage(const char *data, const uint8_t *target, const bool confirm = false);
@ -115,7 +115,7 @@ private:
static uint16_t lastMessageID[10];
static char netName_[20];
const char *firmware{"1.3"};
const char *firmware{"1.31"};
const uint8_t broadcastMAC[6]{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
uint8_t maxNumberOfAttempts_{3};
uint8_t maxWaitingTimeBetweenTransmissions_{50};