Skip to content

Commit 984af4b

Browse files
kegilbertgeky
authored andcommitted
Added in flag to allow optional coercion of provided MAC address to set device as Locally Administrated and Unicast
1 parent 6862912 commit 984af4b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

platform/mbed_interface.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,13 @@ WEAK int mbed_uid(char *uid) {
8484
static uint8_t manual_mac_address_set = 0;
8585
static char manual_mac_address[6];
8686

87-
void mbed_set_mac_address(const char *mac) {
87+
void mbed_set_mac_address(const char *mac, uint8_t coerce_mac_control_bits) {
8888
memcpy(manual_mac_address, mac, 6);
8989
manual_mac_address_set = 1;
90+
if(coerce_mac_control_bits) {
91+
manual_mac_address[0] |= 0x02; // force bit 1 to a "1" = "Locally Administered"
92+
manual_mac_address[0] &= 0xFE; // force bit 0 to a "0" = Unicast
93+
}
9094
}
9195

9296
WEAK void mbed_mac_address(char *mac) {

platform/mbed_interface.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,11 @@ int mbed_interface_uid(char *uid);
104104
* mbed_mac_address() will readback this configured value
105105
*
106106
* @param mac A 6-byte array containing the desired MAC address to be set
107+
* @param coerce_mac_control_bits An 8-bit int that is used as a boolean flag to either coerce
108+
* the provided MAC address to be Locally Administered and Unicast or to use the
109+
* provided MAC address unmodified
107110
*/
108-
void mbed_set_mac_address(const char *mac);
111+
void mbed_set_mac_address(const char *mac, uint8_t coerce_mac_control_bits);
109112

110113
/** This returns a unique 6-byte MAC address, based on the interface UID
111114
* If the interface is not present, it returns a default fixed MAC address (00:02:F7:F0:00:00)

0 commit comments

Comments
 (0)