wifi: check 'lx_get_mac_addr' before reporting

The MAC address device report should be published once the device is
available. Since this may happen at a later time we have to check the
call.

Issue #4813
This commit is contained in:
Josef Söntgen 2023-02-28 14:33:14 +01:00 committed by Christian Helmuth
parent 8ae5ae76fb
commit 0b08ae09c4

View File

@ -487,12 +487,23 @@ extern "C" int socketcall_task_function(void *)
static Lx::Socket inst(Lx_kit::env().env.ep());
_socket = &inst;
_wifi_report_mac_address({ (void *) lx_get_mac_addr() });
void const *mac_addr = nullptr;
wpa_blockade->wakeup();
while (true) {
/*
* Try to report the MAC address once. We have to check
* 'lx_get_mac_addr' as it might by NULL in case 'wlan0'
* is not yet available.
*/
if (!mac_addr) {
mac_addr = lx_get_mac_addr();
if (mac_addr)
_wifi_report_mac_address({ (void *) mac_addr });
}
_socket->exec_call();
lx_emul_task_schedule(true);