A LINK_UP event was recently introduced. As a result, the driver will call NETDEV_EVENT_LINK_UP
on init
.
However, the event_callback
function pointer must be set before calling init
, otherwise it will try to call a NULL pointer function.
I noticed that tests/driver_sx126x
actually sets the event_callback
after calling init
, which used to be not a problem. But we should change that now.
@Ingmar_M @HoCoK could you please try the following patch?
diff --git a/tests/driver_sx126x/main.c b/tests/driver_sx126x/main.c
index 104905e480..038aa86fff 100644
--- a/tests/driver_sx126x/main.c
+++ b/tests/driver_sx126x/main.c
@@ -325,13 +325,13 @@ int main(void)
netdev->driver = &sx126x_driver;
+ netdev->event_callback = _event_cb;
+
if (netdev->driver->init(netdev) < 0) {
puts("Failed to initialize SX126X device, exiting");
return 1;
}
- netdev->event_callback = _event_cb;
-
_recv_pid = thread_create(stack, sizeof(stack), THREAD_PRIORITY_MAIN - 1,
THREAD_CREATE_STACKTEST, _recv_thread, netdev,
"recv_thread");