From 8e122e93544a95c5a52195059853b0b63e34c3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20H=C3=BC=C3=9Fler?= Date: Fri, 31 Mar 2023 13:04:29 +0200 Subject: [PATCH] drivers/atwinc15x0: handle M2M errors of m2m_wifi_enable_mac_mcast --- drivers/atwinc15x0/atwinc15x0_netdev.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/atwinc15x0/atwinc15x0_netdev.c b/drivers/atwinc15x0/atwinc15x0_netdev.c index 152ec4b372..855136e74f 100644 --- a/drivers/atwinc15x0/atwinc15x0_netdev.c +++ b/drivers/atwinc15x0/atwinc15x0_netdev.c @@ -768,7 +768,15 @@ static int _atwinc15x0_set(netdev_t *netdev, netopt_t opt, const void *val, assert(max_len <= sizeof(netopt_state_t)); return _set_state(dev, *((const netopt_state_t *)val)); case NETOPT_L2_GROUP: - if (m2m_wifi_enable_mac_mcast((void *)val, 1)) { + /* sometimes m2m_wifi_enable_mac_mcast() fails with M2M_ERR_MEM_ALLOC */ + m2m_wifi_enable_mac_mcast((void *)val, 0); + /* sometimes it fails with M2M_ERR_BUS_FAIL */ + int tries = 5; + do { + ret = m2m_wifi_enable_mac_mcast((void *)val, 1); + DEBUG_PUTS("busy loop setting L2 multicast address on atwinc15x0"); + } while (--tries && ret == M2M_ERR_BUS_FAIL); + if (ret) { return -EINVAL; } else { return max_len;