Skip to main content

ssh_stamp_esp32/
lib.rs

1// SPDX-FileCopyrightText: 2026 Roman Valls Guimera <brainstorm@nopcode.org>
2// SPDX-FileCopyrightText: 2026 Julio Beltran Ortega <jubeormk1@gmail.com>
3// SPDX-FileCopyrightText: 2026 Angus Gratton <gus@projectgus.com>
4// SPDX-FileCopyrightText: 2026 Sergio Gasquez <sergio.gasquez@gmail.com>
5// SPDX-FileCopyrightText: 2026 pancake <pancake@nopcode.org>
6// SPDX-FileCopyrightText: 2026 Gabriel Ku Wei Bin <gabriel.ku@fsfe.org>
7// SPDX-FileCopyrightText: 2026 Anthony Tambasco <anthony.tambasco@fastmail.com>
8// SPDX-FileCopyrightText: 2026 Marko Malenic <mmalenic1@gmail.com>
9//
10// SPDX-License-Identifier: GPL-3.0-or-later
11
12#![no_std]
13#![forbid(unsafe_code)]
14#![deny(clippy::mem_forget)]
15#![deny(unused_imports)]
16#![deny(unused_variables)]
17
18extern crate alloc;
19
20pub mod bench;
21mod boot;
22#[cfg(feature = "can")]
23mod can;
24pub mod flash;
25mod hash;
26mod network;
27mod platform;
28mod rng;
29mod timer;
30mod uart;
31
32pub use boot::start_interrupt_executor;
33#[cfg(feature = "can")]
34pub use can::{BufferedCan, CAN_BUF, EspCanPins, can_task};
35pub use flash::{EspOtaWriter, FlashBuffer, get_flash_n_buffer, init as flash_init};
36pub use hash::EspHmac;
37pub use network::{EspWifi, accept_requests, dhcp_server, net_up, wifi_up};
38pub use platform::EspPlatform;
39pub use rng::{
40    EntropySource, EspRng, entropy_source_active, fill_bytes as rng_fill_bytes, init_entropy,
41    register_custom_rng,
42};
43pub use timer::EspTimer;
44pub use uart::{BufferedUart, EspUartPins, UART_BUF, UART_SIGNAL, spawn_uart, uart_task};
45
46// These re-exports are nice to have for macro expansions, including `getrandom_backend!`,
47// `init_heap!`, `start_rtos!` and `boot!, as they mean the calling crate doesn't have to
48// have these as direct dependencies.
49pub use esp_alloc;
50pub use esp_bootloader_esp_idf;
51pub use esp_hal;
52pub use esp_println;
53pub use esp_rtos;
54pub use getrandom;
55pub use log;
56pub use ssh_stamp;
57
58/// Read the device's hardware MAC address from eFuse.
59#[must_use]
60pub fn mac_address() -> [u8; 6] {
61    let mac = esp_hal::efuse::base_mac_address();
62    let bytes = mac.as_bytes();
63    debug_assert_eq!(bytes.len(), 6, "eFuse MAC address must be 6 bytes");
64    let mut arr = [0u8; 6];
65    arr.copy_from_slice(bytes);
66    arr
67}