Coder Social home page Coder Social logo

Comments (1)

Darekg1 avatar Darekg1 commented on August 19, 2024

my code:
#include <Arduino.h>
#include <EspNowFloodingMesh.h>
#include <WiFi.h>
#include <time.h>

#define LED 2

#define ESP_NOW_CHANNEL 1
#define B_SSID 14
//AES 128bit
unsigned char secredKey[] = {0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE, 0xFF};

void espNowFloodingMeshRecv(const uint8_t data, int len, uint32_t replyPrt){
if(len>0) {
Serial.println((const char
)data);
}
}
//----------------------------------------

//####################################################################
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_MODE_STA);
Serial.println(WiFi.macAddress());
//Set device in AP mode to begin with
espNowFloodingMesh_RecvCB(espNowFloodingMeshRecv);
espNowFloodingMesh_begin(ESP_NOW_CHANNEL, B_SSID);
espNowFloodingMesh_secredkey(secredKey);
espNowFloodingMesh_setToBatteryNode();

//Ask instant sync from master.
espNowFloodingMesh_requestInstantTimeSyncFromMaster();
while(espNowFloodingMesh_isSyncedWithMaster()==false);

pinMode(LED, OUTPUT);
digitalWrite(LED, HIGH);
}
//####################################################################

//####################################################################
void loop() {
static unsigned long m = millis();

//Ask instant sync from master.
if(m+5000<millis()) {
char message[] = "SLAVE HELLO MESSAGE";
espNowFloodingMesh_send((uint8_t*)message, sizeof(message), 3); //set ttl to 3
m = millis();
}
espNowFloodingMesh_loop();
delay(10);
}
//####################################################################

from espnowfloodingmeshlibrary2.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.