19static const char *
const TAG =
"helpers.host";
22 std::random_device dev;
23 std::mt19937 rng(dev());
24 std::uniform_int_distribution<uint32_t> dist(0, std::numeric_limits<uint32_t>::max());
29 FILE *fp = fopen(
"/dev/urandom",
"r");
31 ESP_LOGW(TAG,
"Could not open /dev/urandom, errno=%d", errno);
34 size_t read = fread(data, 1,
len, fp);
36 ESP_LOGW(TAG,
"Not enough data from /dev/urandom");
51 static const uint8_t esphome_host_mac_address[6] = USE_ESPHOME_HOST_MAC_ADDRESS;
52 memcpy(mac, esphome_host_mac_address,
sizeof(esphome_host_mac_address));
Providing packet encoding functions for exchanging data with a remote host.
bool random_bytes(uint8_t *data, size_t len)
Generate len number of random bytes.
uint32_t random_uint32()
Return a random 32-bit unsigned integer.
void get_mac_address_raw(uint8_t *mac)
Get the device MAC address as raw bytes, written into the provided byte array (6 bytes).