Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit 8db548b

Browse files
MrSurlydpgeorge
authored andcommitted
esp32/modmachine: Add unique_id() function to machine module.
Returns bytes(6) which is MAC address.
1 parent 48b5f4f commit 8db548b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

esp32/modmachine.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ STATIC mp_obj_t machine_reset(void) {
7070
}
7171
STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_reset_obj, machine_reset);
7272

73+
STATIC mp_obj_t machine_unique_id(void) {
74+
uint8_t chipid[6];
75+
esp_efuse_mac_get_default(chipid);
76+
return mp_obj_new_bytes(chipid, 6);
77+
}
78+
STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_unique_id_obj, machine_unique_id);
79+
7380
STATIC mp_obj_t machine_idle(void) {
7481
taskYIELD();
7582
return mp_const_none;
@@ -98,6 +105,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
98105

99106
{ MP_ROM_QSTR(MP_QSTR_freq), MP_ROM_PTR(&machine_freq_obj) },
100107
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&machine_reset_obj) },
108+
{ MP_ROM_QSTR(MP_QSTR_unique_id), MP_ROM_PTR(&machine_unique_id_obj) },
101109
{ MP_ROM_QSTR(MP_QSTR_idle), MP_ROM_PTR(&machine_idle_obj) },
102110

103111
{ MP_ROM_QSTR(MP_QSTR_disable_irq), MP_ROM_PTR(&machine_disable_irq_obj) },

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy