Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ports/alif/alif.mk
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ endif
SHARED_SRC_C += $(addprefix shared/,\
libc/string0.c \
netutils/dhcpserver.c \
netutils/get_mac_ascii.c \
netutils/trace.c \
readline/readline.c \
runtime/gchelper_native.c \
Expand Down
9 changes: 0 additions & 9 deletions ports/alif/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,6 @@ MP_WEAK void mp_hal_get_mac(int idx, uint8_t buf[6]) {
mp_hal_generate_laa_mac(idx, buf);
}

void mp_hal_get_mac_ascii(int idx, size_t chr_off, size_t chr_len, char *dest) {
static const char hexchr[16] = "0123456789ABCDEF";
uint8_t mac[6];
mp_hal_get_mac(idx, mac);
for (; chr_len; ++chr_off, --chr_len) {
*dest++ = hexchr[mac[chr_off >> 1] >> (4 * (1 - (chr_off & 1))) & 0xf];
}
}

void mp_hal_get_random(size_t n, uint8_t *buf) {
uint64_t rnd = 0;
size_t rnd_bits = 0;
Expand Down
1 change: 1 addition & 0 deletions ports/mimxrt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ SHARED_SRC_C += \
shared/libc/printf.c \
shared/libc/string0.c \
shared/netutils/dhcpserver.c \
shared/netutils/get_mac_ascii.c \
shared/netutils/netutils.c \
shared/netutils/trace.c \
shared/readline/readline.c \
Expand Down
9 changes: 0 additions & 9 deletions ports/mimxrt/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,3 @@ void mp_hal_generate_laa_mac(int idx, uint8_t buf[6]) {
MP_WEAK void mp_hal_get_mac(int idx, uint8_t buf[6]) {
mp_hal_generate_laa_mac(idx, buf);
}

void mp_hal_get_mac_ascii(int idx, size_t chr_off, size_t chr_len, char *dest) {
static const char hexchr[16] = "0123456789ABCDEF";
uint8_t mac[6];
mp_hal_get_mac(idx, mac);
for (; chr_len; ++chr_off, --chr_len) {
*dest++ = hexchr[mac[chr_off >> 1] >> (4 * (1 - (chr_off & 1))) & 0xf];
}
}
1 change: 1 addition & 0 deletions ports/renesas-ra/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ MPY_CROSS_FLAGS += -march=armv7m
SHARED_SRC_C += $(addprefix shared/,\
libc/string0.c \
netutils/dhcpserver.c \
netutils/get_mac_ascii.c \
netutils/netutils.c \
netutils/trace.c \
readline/readline.c \
Expand Down
9 changes: 0 additions & 9 deletions ports/renesas-ra/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,6 @@ MP_WEAK void mp_hal_get_mac(int idx, uint8_t buf[6]) {
mp_hal_generate_laa_mac(idx, buf);
}

void mp_hal_get_mac_ascii(int idx, size_t chr_off, size_t chr_len, char *dest) {
static const char hexchr[16] = "0123456789ABCDEF";
uint8_t mac[6];
mp_hal_get_mac(idx, mac);
for (; chr_len; ++chr_off, --chr_len) {
*dest++ = hexchr[mac[chr_off >> 1] >> (4 * (1 - (chr_off & 1))) & 0xf];
}
}

#if MICROPY_HW_ENABLE_RNG
void mp_hal_get_random(size_t n, uint8_t *buf) {
for (int i = 0; i < n; i++) {
Expand Down
1 change: 1 addition & 0 deletions ports/rp2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ set(MICROPY_SOURCE_LIB
${MICROPY_DIR}/lib/oofatfs/ff.c
${MICROPY_DIR}/lib/oofatfs/ffunicode.c
${MICROPY_DIR}/shared/netutils/dhcpserver.c
${MICROPY_DIR}/shared/netutils/get_mac_ascii.c
${MICROPY_DIR}/shared/netutils/netutils.c
${MICROPY_DIR}/shared/netutils/trace.c
${MICROPY_DIR}/shared/readline/readline.c
Expand Down
9 changes: 0 additions & 9 deletions ports/rp2/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,6 @@ MP_WEAK void mp_hal_get_mac(int idx, uint8_t buf[6]) {
mp_hal_generate_laa_mac(idx, buf);
}

void mp_hal_get_mac_ascii(int idx, size_t chr_off, size_t chr_len, char *dest) {
static const char hexchr[16] = "0123456789ABCDEF";
uint8_t mac[6];
mp_hal_get_mac(idx, mac);
for (; chr_len; ++chr_off, --chr_len) {
*dest++ = hexchr[mac[chr_off >> 1] >> (4 * (1 - (chr_off & 1))) & 0xf];
}
}

// Shouldn't be used, needed by cyw43-driver in debug build.
uint32_t storage_read_blocks(uint8_t *dest, uint32_t block_num, uint32_t num_blocks) {
panic_unsupported();
Expand Down
1 change: 1 addition & 0 deletions ports/stm32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ MPY_CROSS_FLAGS += -march=$(MPY_CROSS_MCU_ARCH)
SHARED_SRC_C += $(addprefix shared/,\
libc/string0.c \
netutils/dhcpserver.c \
netutils/get_mac_ascii.c \
netutils/netutils.c \
netutils/trace.c \
readline/readline.c \
Expand Down
9 changes: 0 additions & 9 deletions ports/stm32/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,6 @@ MP_WEAK void mp_hal_get_mac(int idx, uint8_t buf[6]) {
mp_hal_generate_laa_mac(idx, buf);
}

void mp_hal_get_mac_ascii(int idx, size_t chr_off, size_t chr_len, char *dest) {
static const char hexchr[16] = "0123456789ABCDEF";
uint8_t mac[6];
mp_hal_get_mac(idx, mac);
for (; chr_len; ++chr_off, --chr_len) {
*dest++ = hexchr[mac[chr_off >> 1] >> (4 * (1 - (chr_off & 1))) & 0xf];
}
}

#if MICROPY_HW_ENABLE_RNG
void mp_hal_get_random(size_t n, uint8_t *buf) {
uint32_t val = 0;
Expand Down
38 changes: 38 additions & 0 deletions shared/netutils/get_mac_ascii.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

#include <assert.h>
#include "py/mphal.h"

void mp_hal_get_mac_ascii(int idx, size_t chr_off, size_t chr_len, char *dest) {
static const char hexchr[16] = "0123456789ABCDEF";
uint8_t mac[6];
mp_hal_get_mac(idx, mac);
assert(chr_off <= 12 && chr_len <= 12 - chr_off);
for (; chr_len; ++chr_off, --chr_len) {
*dest++ = hexchr[mac[chr_off >> 1] >> (4 * (1 - (chr_off & 1))) & 0xf];
}
}
Loading