Skip to content

Commit

Permalink
lwIP_Ethernet: rename copied cyw43 mac function
Browse files Browse the repository at this point in the history
Prevent symbol conflicts when including both Wifi.h and cyw43.h

Fixes #2602
  • Loading branch information
afflux committed Nov 13, 2024
1 parent db4b167 commit b98f53b
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions libraries/lwIP_Ethernet/src/LwipIntfDev.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,13 @@

// Dup'd to avoid CYW43 dependency
// Generate a mac address if one is not set in otp
extern "C" {
static void cyw43_hal_generate_laa_mac(__unused int idx, uint8_t buf[6]) {
pico_unique_board_id_t board_id;
pico_get_unique_board_id(&board_id);
memcpy(buf, &board_id.id[2], 6);
buf[0] &= (uint8_t)~0x1; // unicast
buf[0] |= 0x2; // locally administered
}
};
static void _cyw43_hal_generate_laa_mac(__unused int idx, uint8_t buf[6]) {
pico_unique_board_id_t board_id;
pico_get_unique_board_id(&board_id);
memcpy(buf, &board_id.id[2], 6);
buf[0] &= (uint8_t)~0x1; // unicast
buf[0] |= 0x2; // locally administered
}



Expand All @@ -71,8 +69,6 @@ enum EthernetLinkStatus {
LinkOFF
};

extern "C" void cyw43_hal_generate_laa_mac(__unused int idx, uint8_t buf[6]);

template<class RawDev>
class LwipIntfDev: public LwipIntf, public RawDev {
public:
Expand Down Expand Up @@ -356,7 +352,7 @@ bool LwipIntfDev<RawDev>::begin(const uint8_t* macAddress, const uint16_t mtu) {
#if 1
// forge a new mac-address from the esp's wifi sta one
// I understand this is cheating with an official mac-address
cyw43_hal_generate_laa_mac(0, _macAddress);
_cyw43_hal_generate_laa_mac(0, _macAddress);
#else
// https://serverfault.com/questions/40712/what-range-of-mac-addresses-can-i-safely-use-for-my-virtual-machines
memset(_macAddress, 0, 6);
Expand Down

0 comments on commit b98f53b

Please sign in to comment.