Giter Club home page Giter Club logo

Comments (4)

gioblu avatar gioblu commented on August 12, 2024

Ciao @toi-go thank you very much, this is bad. I will fix it ASAP.
Could you provide with testing? I am now far from my electronics stash.

from pjon.

gioblu avatar gioblu commented on August 12, 2024

Here is the fix: 5f790b3
If you can give it a try.

from pjon.

toi-go avatar toi-go commented on August 12, 2024

Hi @gioblu ,

thank you for providing the patch. Unfortunately, with it, my two ESP32 cannot communicate with each other - no matter if I call bus.strategy.set_pmk or not. So, there must be another problem.

To test, I've used the ping example at examples/ESP32/ESPNOW/PlatformIO.
My setup() functions looks like this:

void setup()
{
  Serial.begin(115200);
  Serial.println("Receiver started.");

  // Note PMK is 16 bytes, to store it in a char use char[17] or add an extra byte for the null terminator
  char pmk[17] = "\x2b\xb2\x1e\x7a\x83\x13\x76\x9f\xf8\xa9\x3b\x1b\x5b\x52\xd0\x70";

  bus.strategy.set_channel(6);
  bus.strategy.set_pmk(pmk);

  bus.set_receiver(receiver_function);
  bus.begin();
};
void setup()
{
  Serial.begin(115200);
  Serial.println("Transmitter started.");

  // Note PMK is 16 bytes, to store it in a char use char[17] or add an extra byte for the null terminator
  char pmk[17] = "\x2b\xb2\x1e\x7a\x83\x13\x76\x9f\xf8\xa9\x3b\x1b\x5b\x52\xd0\x70";

  bus.strategy.set_channel(6);
  bus.strategy.set_pmk(pmk);

  bus.set_receiver(receiver_function);
  bus.begin();
  bus.send_repeatedly(44, "P", 1, 100000); // Send P to device 44 10 times per second
};

from pjon.

toi-go avatar toi-go commented on August 12, 2024

@gioblu

It seems that the remaining problem is somehow related to autoregistration mode, as it works if it is disabled.

  // Note PMK is 16 bytes, to store it in a char use char[17] or add an extra byte for the null terminator
  char pmk[17] = "\x2b\xb2\x1e\x7a\x83\x13\x76\x9f\xf8\xa9\x3b\x1b\x5b\x52\xd0\x70";

  bus.strategy.set_autoregistration(false);
  bus.strategy.set_channel(6);
  bus.strategy.set_pmk(pmk);

  bus.set_receiver(receiver_function);
  bus.begin();

  uint8_t dev_mac[6] = { 0x10, 0x10, 0x10, 0x10, 0x10, 0x11 };  // MAC address of the remote node.
  bus.strategy.add_node(44, dev_mac);

  bus.send_repeatedly(44, "P", 1, 100000); // Send P to device 44 10 times per second

If you register remote nodes manually, you have to use the MAC address of the interface (AP or Station) which is actually in use (depending on CONFIG_STATION_MODE):

From ESPNOWHelper.h

/* ESPNOW can work in both station and softap mode.
   It is configured in menuconfig. */
#if CONFIG_STATION_MODE
  #define ESPNOW_WIFI_MODE WIFI_MODE_STA
  #define ESPNOW_WIFI_IF ESP_IF_WIFI_STA
#else
  #define ESPNOW_WIFI_MODE WIFI_MODE_AP
  #define ESPNOW_WIFI_IF ESP_IF_WIFI_AP
#endif

In my case, CONFIG_STATION_MODE was not defined, so I had to use the MAC address of the AP interface.

To determine the MAC address, I used the following code:

  Serial.println("ESP Board MAC Address:  ");
  #if CONFIG_STATION_MODE
  WiFi.mode(WIFI_MODE_STA);
  Serial.print(" Station interface: ");
  Serial.println(WiFi.macAddress());
  #else
  WiFi.mode(WIFI_MODE_AP);
  Serial.print(" AP interface: ");
  Serial.println(WiFi.softAPmacAddress());
  #endif

from pjon.

Related Issues (20)

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.