[core] Add lt_get_device_mac() function

This commit is contained in:
Kuba Szczodrzyński
2023-05-25 20:43:00 +02:00
parent 9b7d34fa65
commit 4dae304f51
7 changed files with 30 additions and 16 deletions

View File

@@ -38,6 +38,7 @@ uint32_t lt_cpu_get_unique_id();
/**
* @brief Get CPU ID based on the last three octets of MAC address.
* Note: the number is 24-bit (with the MSB being zero).
* The 3rd-to-last octet is least-significant, the last octet is most-significant.
*/
uint32_t lt_cpu_get_mac_id();

View File

@@ -20,6 +20,13 @@ const char *lt_get_board_code();
*/
const char *lt_get_device_name();
/**
* @brief Read device's *default* MAC address into 'mac' array.
* This can be used even without Wi-Fi enabled, and will ignore
* user-changed Wi-Fi MAC (if changing is possible).
*/
void lt_get_device_mac(uint8_t *mac);
/**
* @brief Reboot the CPU.
*/

View File

@@ -39,6 +39,12 @@ __attribute__((weak)) uint32_t lt_cpu_get_unique_id() {
return lt_cpu_get_mac_id();
}
__attribute__((weak)) uint32_t lt_cpu_get_mac_id() {
uint8_t mac[6];
lt_get_device_mac(mac);
return (mac[3] << 0) | (mac[4] << 8) | (mac[5] << 16);
}
__attribute__((weak)) uint8_t lt_cpu_get_core_count() {
return 1;
}