Skip to content

Commit 08b6bea

Browse files
author
Arto Kinnunen
committed
Update EMAC connect logic with MAC address change
Do not fail EMAC interface during connect if MAC address change is not supported in the selected interface.
1 parent 028c846 commit 08b6bea

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

features/netsocket/EMACInterface.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
*/
1616

1717
#include "EMACInterface.h"
18+
#include "mbed_trace.h"
1819

1920
using namespace mbed;
2021

22+
#define TRACE_GROUP "EMACi"
23+
2124
/* Interface implementation */
2225
EMACInterface::EMACInterface(EMAC &emac, OnboardNetworkStack &stack) :
2326
_emac(emac),
@@ -69,10 +72,17 @@ nsapi_error_t EMACInterface::set_dhcp(bool dhcp)
6972
nsapi_error_t EMACInterface::connect()
7073
{
7174
if (!_interface) {
72-
nsapi_error_t err;
75+
nsapi_error_t err = NSAPI_ERROR_UNSUPPORTED;
76+
7377
if (_hw_mac_addr_set) {
7478
err = _stack.add_ethernet_interface(_emac, true, &_interface, _hw_mac_addr);
75-
} else {
79+
if (err == NSAPI_ERROR_UNSUPPORTED) {
80+
tr_error("Failed to set user MAC address");
81+
}
82+
}
83+
84+
if (err == NSAPI_ERROR_UNSUPPORTED)
85+
{
7686
err = _stack.add_ethernet_interface(_emac, true, &_interface);
7787
}
7888

features/netsocket/NetworkInterface.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ class NetworkInterface: public DNS {
106106
* be unique globally. The address must be set before calling the interface
107107
* connect() method.
108108
*
109-
* Not all interfaces are supporting MAC address set. A call to connect()
110-
* method will fail if MAC address is provided but not possible to use.
109+
* Not all interfaces are supporting MAC address set and an error is not returned
110+
* for this method call. Verify the changed MAC address by analysing packet
111+
* captures from the used network interface.
111112
*
112113
* 6-byte EUI-48 MAC addresses are used for Ethernet while Mesh interface is
113114
* using 8-byte EUI-64 address.

0 commit comments

Comments
 (0)