mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
- Replace Crypto files with CryptoInterface which uses BearSSL as a cryptographic backend.
- Move cryptographic functions from JsonTranslator to CryptoInterface. - Make AP activation separate from FloodingMesh::begin(). - Fix English bug. - Improve comments.
This commit is contained in:
@ -242,14 +242,14 @@ void setup() {
|
||||
|
||||
int32_t timeOfLastScan = -10000;
|
||||
void loop() {
|
||||
// The performEspnowMaintainance() method performs all the background operations for the EspnowMeshBackend.
|
||||
// The performEspnowMaintenance() method performs all the background operations for the EspnowMeshBackend.
|
||||
// It is recommended to place it in the beginning of the loop(), unless there is a need to put it elsewhere.
|
||||
// Among other things, the method cleans up old Espnow log entries (freeing up RAM) and sends the responses you provide to Espnow requests.
|
||||
// Note that depending on the amount of responses to send and their length, this method can take tens or even hundreds of milliseconds to complete.
|
||||
// More intense transmission activity and less frequent calls to performEspnowMaintainance will likely cause the method to take longer to complete, so plan accordingly.
|
||||
// More intense transmission activity and less frequent calls to performEspnowMaintenance will likely cause the method to take longer to complete, so plan accordingly.
|
||||
|
||||
//Should not be used inside responseHandler, requestHandler, networkFilter or broadcastFilter callbacks since performEspnowMaintainance() can alter the ESP-NOW state.
|
||||
EspnowMeshBackend::performEspnowMaintainance();
|
||||
//Should not be used inside responseHandler, requestHandler, networkFilter or broadcastFilter callbacks since performEspnowMaintenance() can alter the ESP-NOW state.
|
||||
EspnowMeshBackend::performEspnowMaintenance();
|
||||
|
||||
if (millis() - timeOfLastScan > 10000) { // Give other nodes some time to connect between data transfers.
|
||||
Serial.println("\nPerforming unencrypted ESP-NOW transmissions.");
|
||||
@ -260,8 +260,8 @@ void loop() {
|
||||
|
||||
timeOfLastScan = millis();
|
||||
|
||||
// Wait for response. espnowDelay continuously calls performEspnowMaintainance() so we will respond to ESP-NOW request while waiting.
|
||||
// Should not be used inside responseHandler, requestHandler, networkFilter or broadcastFilter callbacks since performEspnowMaintainance() can alter the ESP-NOW state.
|
||||
// Wait for response. espnowDelay continuously calls performEspnowMaintenance() so we will respond to ESP-NOW request while waiting.
|
||||
// Should not be used inside responseHandler, requestHandler, networkFilter or broadcastFilter callbacks since performEspnowMaintenance() can alter the ESP-NOW state.
|
||||
espnowDelay(100);
|
||||
|
||||
// One way to check how attemptTransmission worked out
|
||||
|
@ -1,3 +1,10 @@
|
||||
/**
|
||||
This example makes every node broadcast their AP MAC to the rest of the network during the first 28 seconds, as long as the node thinks it has the highest AP MAC in the network.
|
||||
Once 28 seconds have passed, the node that has the highest AP MAC will start broadcasting benchmark messages, which will allow you to see how many messages are lost at the other nodes.
|
||||
If you have an onboard LED on your ESP8266 it is recommended that you change the useLED variable below to true.
|
||||
That way you will get instant confirmation of the mesh communication without checking the Serial Monitor.
|
||||
*/
|
||||
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <TypeConversionFunctions.h>
|
||||
#include <assert.h>
|
||||
@ -63,7 +70,7 @@ bool meshMessageHandler(String &message, FloodingMesh &meshInstance) {
|
||||
|
||||
if (useLED && !theOne) {
|
||||
bool ledState = message.charAt(1) == '1';
|
||||
digitalWrite(LED_BUILTIN, ledState); // Turn LED on/off (LED is active low)
|
||||
digitalWrite(LED_BUILTIN, ledState); // Turn LED on/off (LED_BUILTIN is active low)
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -128,13 +135,14 @@ void setup() {
|
||||
Serial.println(F("Setting up mesh node..."));
|
||||
|
||||
floodingMesh.begin();
|
||||
floodingMesh.activateAP();
|
||||
|
||||
uint8_t apMacArray[6] {0};
|
||||
theOneMac = macToString(WiFi.softAPmacAddress(apMacArray));
|
||||
|
||||
if (useLED) {
|
||||
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
|
||||
digitalWrite(LED_BUILTIN, LOW); // Turn LED on (LED is active low)
|
||||
digitalWrite(LED_BUILTIN, LOW); // Turn LED on (LED_BUILTIN is active low)
|
||||
}
|
||||
|
||||
floodingMeshDelay(5000); // Give some time for user to start the nodes
|
||||
@ -146,12 +154,12 @@ void loop() {
|
||||
static uint32_t benchmarkCount = 0;
|
||||
static uint32_t loopStart = millis();
|
||||
|
||||
// The floodingMeshDelay() method performs all the background operations for the FloodingMesh (via FloodingMesh::performMeshMaintainance()).
|
||||
// The floodingMeshDelay() method performs all the background operations for the FloodingMesh (via FloodingMesh::performMeshMaintenance()).
|
||||
// It is recommended to place one of these methods in the beginning of the loop(), unless there is a need to put them elsewhere.
|
||||
// Among other things, the method cleans up old ESP-NOW log entries (freeing up RAM) and forwards received mesh messages.
|
||||
// Note that depending on the amount of messages to forward and their length, this method can take tens or even hundreds of milliseconds to complete.
|
||||
// More intense transmission activity and less frequent calls to performMeshMaintainance will likely cause the method to take longer to complete, so plan accordingly.
|
||||
// The maintainance methods should not be used inside the meshMessageHandler callback, since they can alter the mesh node state. The framework will alert you during runtime if you make this mistake.
|
||||
// More intense transmission activity and less frequent calls to performMeshMaintenance will likely cause the method to take longer to complete, so plan accordingly.
|
||||
// The maintenance methods should not be used inside the meshMessageHandler callback, since they can alter the mesh node state. The framework will alert you during runtime if you make this mistake.
|
||||
floodingMeshDelay(1);
|
||||
|
||||
// If you wish to transmit only to a single node, try using one of the following methods (requires the node to be within range and know the MAC of the recipient):
|
||||
|
Reference in New Issue
Block a user