Skip to content

Commit f070302

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 2f61034 commit f070302

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

connectivity/netsocket/include/netsocket/NetworkInterface.h

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

connectivity/netsocket/source/EMACInterface.cpp

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

1818
#include "netsocket/EMACInterface.h"
19+
#include "mbed_trace.h"
1920

2021
using namespace mbed;
2122

23+
#define TRACE_GROUP "EMACi"
24+
2225
/* Interface implementation */
2326
EMACInterface::EMACInterface(EMAC &emac, OnboardNetworkStack &stack) :
2427
_emac(emac),
@@ -49,10 +52,17 @@ nsapi_error_t EMACInterface::set_dhcp(bool dhcp)
4952
nsapi_error_t EMACInterface::connect()
5053
{
5154
if (!_interface) {
52-
nsapi_error_t err;
55+
nsapi_error_t err = NSAPI_ERROR_UNSUPPORTED;
56+
5357
if (_hw_mac_addr_set) {
5458
err = _stack.add_ethernet_interface(_emac, true, &_interface, _hw_mac_addr);
55-
} else {
59+
if (err == NSAPI_ERROR_UNSUPPORTED) {
60+
tr_error("Failed to set user MAC address");
61+
}
62+
}
63+
64+
if (err == NSAPI_ERROR_UNSUPPORTED)
65+
{
5666
err = _stack.add_ethernet_interface(_emac, true, &_interface);
5767
}
5868

0 commit comments

Comments
 (0)