#pragma once #include #include #include namespace roro::identity { // Node number as Meshtastic derives it: the last four bytes of the chip's MAC address. inline uint32_t nodeNum() { uint64_t mac = ESP.getEfuseMac(); // byte 0 of the MAC is the lowest byte auto byte = [mac](int i) { return static_cast((mac >> (8 * i)) & 0xFF); }; return (byte(2) << 24) | (byte(3) << 16) | (byte(4) << 8) | byte(5); } // "!2f762fa4" inline std::string nodeId() { char buf[12]; std::snprintf(buf, sizeof(buf), "!%08lx", static_cast(nodeNum())); return buf; } // Suggested names for the setup wizard: "roro9stack 2fa4" and "2fa4". inline std::string defaultShortName() { char buf[8]; std::snprintf(buf, sizeof(buf), "%04lx", static_cast(nodeNum() & 0xFFFF)); return buf; } inline std::string defaultLongName() { return "roro9stack " + defaultShortName(); } } // namespace roro::identity