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

Add leading hex zero to addresses #227

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

Conversation

timmbogner
Copy link
Owner

@aviateur17 Hey so this is something that has stumped us both before, but your irrigation code gave me an idea. Here's the proof of concept I wrote:

  Serial.begin(115200);
  uint8_t x = 2;
  Serial.println("It's 0x" + String((x < 16) ? "0" : "") + String(x, HEX));

I applied it to the gateway's ESP-NOW functions and it seems to work. However, when I started expanding it further I realized there are a lot of spots where we'd use this, especially in LoRa. I think we can probably transform it into a reusable function to keep things neat. What do you think?

@aviateur17
Copy link
Contributor

That looks excellent. We could use a macro like the ones at the top of fdrs_lora.h

#define LZ(a) (" 0x" + String(a < 16) ? "0" : "") + String(a, HEX))

Something like that and then just insert LZ(5) or whatever in the code
Great idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants