ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
helpers.cpp
Go to the documentation of this file.
2
3#ifdef USE_ESP8266
4
5#include <osapi.h>
6#include <user_interface.h>
7
8namespace esphome {
9
10uint32_t random_uint32() { return os_random(); }
11bool random_bytes(uint8_t *data, size_t len) { return os_get_random(data, len) == 0; }
12
13// ESP8266 Mutex is defined inline as a no-op in helpers.h when USE_ESP8266 (or USE_RP2) is set,
14// independent of the ESPHOME_THREAD_SINGLE thread model define.
15
16// ESP8266 LwIPLock is defined inline as a no-op in helpers.h
17
18void get_mac_address_raw(uint8_t *mac) { // NOLINT(readability-non-const-parameter)
19 wifi_get_macaddr(STATION_IF, mac);
20}
21
22} // namespace esphome
23
24#endif // USE_ESP8266
bool random_bytes(uint8_t *data, size_t len)
Generate len random bytes using the platform's secure RNG (hardware RNG or OS CSPRNG).
Definition helpers.cpp:20
const void size_t len
Definition hal.h:68
uint32_t random_uint32()
Return a random 32-bit unsigned integer.
Definition helpers.cpp:10
void get_mac_address_raw(uint8_t *mac)
Get the device MAC address as raw bytes, written into the provided byte array (6 bytes).
Definition helpers.cpp:71
static void uint32_t