File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,14 @@ WEAK int mbed_uid(char *uid) {
81
81
}
82
82
#endif
83
83
84
+ static uint8_t manual_mac_address_set = 0 ;
85
+ static char manual_mac_address [6 ];
86
+
87
+ void mbed_set_mac_address (const char * mac ) {
88
+ memcpy (manual_mac_address , mac , 6 );
89
+ manual_mac_address_set = 1 ;
90
+ }
91
+
84
92
WEAK void mbed_mac_address (char * mac ) {
85
93
#if DEVICE_SEMIHOST
86
94
char uid [DEVICE_ID_LENGTH + 1 ];
@@ -101,12 +109,16 @@ WEAK void mbed_mac_address(char *mac) {
101
109
mac [0 ] &= ~0x01 ; // reset the IG bit in the address; see IEE 802.3-2002, Section 3.2.3(b)
102
110
} else { // else return a default MAC
103
111
#endif
112
+ if (manual_mac_address_set ) {
113
+ memcpy (mac , manual_mac_address , 6 );
114
+ } else {
104
115
mac [0 ] = 0x00 ;
105
116
mac [1 ] = 0x02 ;
106
117
mac [2 ] = 0xF7 ;
107
118
mac [3 ] = 0xF0 ;
108
119
mac [4 ] = 0x00 ;
109
120
mac [5 ] = 0x00 ;
121
+ }
110
122
#if DEVICE_SEMIHOST
111
123
}
112
124
#endif
Original file line number Diff line number Diff line change @@ -98,6 +98,15 @@ int mbed_interface_uid(char *uid);
98
98
99
99
#endif
100
100
101
+ /** This provides a generic function to set a unique 6-byte MAC address based on the passed
102
+ * parameter character array. Provides no MAC address validity checking
103
+ *
104
+ * mbed_mac_address() will readback this configured value
105
+ *
106
+ * @param mac A 6-byte array containing the desired MAC address to be set
107
+ */
108
+ void mbed_set_mac_address (const char * mac );
109
+
101
110
/** This returns a unique 6-byte MAC address, based on the interface UID
102
111
* If the interface is not present, it returns a default fixed MAC address (00:02:F7:F0:00:00)
103
112
*
You can’t perform that action at this time.
0 commit comments