Gateway Address EEPROM

  • Hello,
    I save the ip address of my gateway to eeprom. At reboot, I would like to read the eeprom address and assign it to define MY_IP_ADDRESS. Is it possible ?
    Thank you.

  • Mod

    @miclane could you describe your use case?

    Using dhcp means the ip address assignment is handled by a dhcp server. Most dhcp servers can be configured to hand out the same ip every time for the same mac address. This is usually called static lease or something similar.

    People who want the node itself control the ip address just define it in the sketch.

    Could you describe why these cases don't cover your needs?

  • I am not going to use a DHCP address but a static address that I define in EEPROM.
    It's easy to define in the sketch directly but it's not my need.

    With a small interface, I define the address in EEPROM and when the sketch type my gateway starts, I would like the #define MY_IP_ADDRESS to include the address in eeprom.
    Thank you.

  • I solved my need.
    I get the bytes from the EEPROM as well.
    #define MY_IP_ADDRESS_B0
    #define MY_IP_ADDRESS_B3

    Then I define the address of the gateway like this:
    #define MY_IP_ADDRESS ((uint32_t)(MY_IP_ADDRESS_B3) << 24) | ((uint32_t)(MY_IP_ADDRESS_B2) << 16) | ((uint32_t)(MY_IP_ADDRESS_B1) << 😎 | (uint32_t)(MY_IP_ADDRESS_B0)

    This applies to the other addresses required for the operation of an MQTT gateway.
    Hopefully this sharing is useful.
    Thank you

  • Mod

    That's a clever solution. Thanks for sharing.

Log in to reply

Suggested Topics

  • 4
  • 5
  • 14
  • 9
  • 2
  • 274