Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unique topic Generation #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Mich21050
Copy link

On some generic ESP32 based boards the ESP.getChipId() function doesn't return a uniquie id. Which is a big problem when trying to use multiple esp32 blinds. I replaces the ESP.getChipId function with a custom one that uses the MAC Adress to generate an ID. Still not 100% uniquie but better then before,

@eg321
Copy link
Owner

eg321 commented Dec 2, 2022

Hi!

I was lucky with my ESPs, they have unique ID, but I know about this issue. Thanks for pointing to it again.

There are 2 comments regarding the way how you propose to resolve the issue:

  1. Your changes are not compatible with ESP8266. There are no "getEfuseMac" method at ESP8266. I would to continue support of ESP8266 while it's possible.
  2. Take a look here:
    #define ESP_getChipId() ((uint32_t)ESP.getEfuseMac())

    There is already different implementation for ESP32 and ESP8266. I', expecting your changes somewhere there.

It can be something like this:

#ifdef ESP32
    inline uint32_t generateId() {
        uint32_t id = 0;
        for(int i=0; i<17; i=i+8) {
            id |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
        }
        return id;
    }

    #define ESP_getChipId()   (generateId())
#endif

Thanks!

@eg321 eg321 added the bug Something isn't working label Dec 2, 2022
@eg321 eg321 self-requested a review December 5, 2022 10:23
Copy link
Owner

@eg321 eg321 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

waiting for changes described above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants