Skip to content

Commit b8355c2

Browse files
author
andreas.larsson
committed
Fixed the emac_interface_t struct so that the struct constructor is not used.
We can not rely on the struct constructor to be run since wifi_emac_get_interface can be run from the OdinWiFiInterface constructor before that.
1 parent 7bcc63b commit b8355c2

File tree

1 file changed

+7
-2
lines changed
  • targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac

1 file changed

+7
-2
lines changed

targets/TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_EVK_ODIN_W2/sdk/wifi_emac/wifi_emac_api.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const emac_interface_ops_t wifi_emac_interface = {
6969
.set_link_state_cb = wifi_set_link_state_cb
7070
};
7171

72-
static emac_interface_t _intf = { wifi_emac_interface, NULL };
72+
static emac_interface_t* _intf = NULL;
7373

7474
static const cbWLANTARGET_Callback _wlanTargetCallback =
7575
{
@@ -318,7 +318,12 @@ static void wifi_set_link_state_cb(emac_interface_t *emac, emac_link_state_chang
318318

319319
emac_interface_t* wifi_emac_get_interface()
320320
{
321-
return &_intf;
321+
if (_intf == NULL) {
322+
_intf = new emac_interface_t();
323+
_intf->hw = NULL;
324+
memcpy((void*)&_intf->ops, &wifi_emac_interface, sizeof(wifi_emac_interface));
325+
}
326+
return _intf;
322327
}
323328

324329
void wifi_emac_init_mem(void)

0 commit comments

Comments
 (0)