ESPHome 2026.5.0-dev
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// for xt_rsil()/xt_wsr_ps()
8#include <Arduino.h>
9
10namespace esphome {
11
12uint32_t random_uint32() { return os_random(); }
13bool random_bytes(uint8_t *data, size_t len) { return os_get_random(data, len) == 0; }
14
15// ESP8266 Mutex is defined inline as a no-op in helpers.h when USE_ESP8266 (or USE_RP2040) is set,
16// independent of the ESPHOME_THREAD_SINGLE thread model define.
17
18IRAM_ATTR InterruptLock::InterruptLock() { state_ = xt_rsil(15); }
19IRAM_ATTR InterruptLock::~InterruptLock() { xt_wsr_ps(state_); }
20
21// ESP8266 LwIPLock is defined inline as a no-op in helpers.h
22
23void get_mac_address_raw(uint8_t *mac) { // NOLINT(readability-non-const-parameter)
24 wifi_get_macaddr(STATION_IF, mac);
25}
26
27} // namespace esphome
28
29#endif // USE_ESP8266
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
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
std::string size_t len
Definition helpers.h:1045
uint32_t random_uint32()
Return a random 32-bit unsigned integer.
Definition helpers.cpp:12
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:74
static void uint32_t