@Michael Fowler , this callback relies on the implementation of network driver. When the link status is changed, it is responsibility of network driver to notify NetX by calling _nx_ip_driver_link_status_event
. Could you search this function in your network driver and see if it is implemented?
nx_ip_link_status_change_notify_set not working
I registered a link_status_change callback, but it doesn't seem to be called. The IP interface is up, but I don't enter the callback, even when the ethernet is unplugged. I'm using the NXP iMXRT1050.
VOID link_status_change_cb (NX_IP ip_ptr, UINT interface_index, UINT link_up) {
ULONG ip_address, network_mask;
__BKPT(0);
if (NX_SUCCESS == nx_ip_interface_address_get (ip_ptr, interface_index, &ip_address, &network_mask)) {
if (NX_TRUE == link_up) {
PRINTF("IP is up!");
char ipString[17];
getIpV4String(ip_address, ipString);
PRINTF("IP is %s\r\n", ipString);
}
else if (NX_FALSE == link_up) {
PRINTF("IP is down!");
}
}
}
void initNet(void){
nx_system_initialize();
// Create a packet pool.
status = nx_packet_pool_create(&packet_pool_0, "NetX Main Packet Pool", PACKET_SIZE+64,
(ULONG ) (((int ) packet_pool_area + 15) & ~15), NX_PACKET_POOL_SIZE);
if (status) {
//DbgConsole_Printf("ERR: packet pool \r\n");
}
// Create an IP instance.
status = nx_ip_create(&ip_0, "NetX IP Instance 0", ip_addr, 0xFFFFFF00UL, &packet_pool_0,
nx_driver_imx, (UCHAR* ) ip_thread_stack, sizeof(ip_thread_stack), 5);
if (status) {
__BKPT(0);
}
status = nx_ip_link_status_change_notify_set(&ip_0, link_status_change_cb);
if (status) {
__BKPT(0);
}
}
-
Tiejun Zhou 1,126 Reputation points Microsoft Employee
2022-11-10T01:59:54.557+00:00
1 additional answer
Sort by: Most helpful
-
QuantumCache 20,266 Reputation points
2023-02-27T07:58:20.3866667+00:00 Hello,
Reference: Quickstart: Connect an NXP MIMXRT1060-EVK Evaluation kit to IoT Hub
- Try using a different Ethernet cable or a different Ethernet port to see if the issue is with the cable or the port.
- Check the logs and debug output to see if there are any error messages or other information that can help you diagnose the issue.
- Verify that the network interface is correctly registered with the IP instance. Make sure that the correct interface index is passed to the
nx_ip_link_status_change_notify_set
function. - Make sure that the link status change event is actually happening. You can test this by physically unplugging the Ethernet cable and checking if the link status change callback function is called.
- Check if there are any other tasks or threads that are blocking the execution of the callback function. This could be preventing the callback function from being called.
Please let us know if you need further help in this matter and we are happy to help you!