Hello. I'm making an application that sends Mqqt data to a broker using the zephyr\samples\net\cloud\mqtt_azure example.
I am using the W5500 module for internet access. Everything works great, but I can't trace the disconnection of the cable, I don't get the NET_EVENT_L4_DISCONNECTED callback.
But the fact that there was a NET_EVENT_L4_CONNECTED connection, I see what is coming./* Network Management events */ #define L4_EVENT_MASK (NET_EVENT_L4_CONNECTED | NET_EVENT_L4_DISCONNECTED) void Ethernet::networkInit(void) { k_work_init_delayable(&m_checkNetworkConn, checkNetworkConnection); net_mgmt_init_event_callback(&m_l4mgmtCb, ethernetEventHandler, L4_EVENT_MASK); net_mgmt_add_event_callback(&m_l4mgmtCb); k_thread_suspend(app_mqtt_threadID); appDhcpInit(); } void Ethernet::ethernetEventHandler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, struct net_if *iface) { if ((mgmt_event & L4_EVENT_MASK) != mgmt_event) { return; } switch (mgmt_event) { case NET_EVENT_L4_CONNECTED: /* Wait for DHCP to be back in BOUND state */ k_work_reschedule(&m_checkNetworkConn, K_SECONDS(3)); break; case NET_EVENT_L4_DISCONNECTED: MqttClient::abortMqttConnection(); k_work_cancel_delayable(&m_checkNetworkConn); break; default: break; } }
Here is my setup config file:CONFIG_SPI=y CONFIG_BT=y CONFIG_CPLUSPLUS=y # Using networking CONFIG_NETWORKING=y CONFIG_NET_L2_ETHERNET=y CONFIG_NET_L2_ETHERNET_MGMT=y CONFIG_ETH_W5500=y # Enable IPv4 support CONFIG_NET_IPV4=y # Enable TCP support CONFIG_NET_TCP=y # Enable DHCPv4 support CONFIG_NET_DHCPV4=y # Enable MQTT Lib support CONFIG_MQTT_LIB=y # Network configuration CONFIG_NET_CONFIG_AUTO_INIT=y CONFIG_NET_CONFIG_SETTINGS=n # Network connection manager CONFIG_NET_CONNECTION_MANAGER=y CONFIG_NET_MGMT=y CONFIG_NET_MGMT_EVENT=y CONFIG_NET_MGMT_EVENT_INFO=y # Enable the DNS resolver CONFIG_DNS_RESOLVER=y # Enable additional buffers CONFIG_DNS_RESOLVER_ADDITIONAL_BUF_CTR=1 CONFIG_INIT_STACKS=y CONFIG_NEWLIB_LIBC=y CONFIG_MAIN_STACK_SIZE=4096 # Enable Logging support CONFIG_NET_LOG=y CONFIG_LOG=y
I really need your help.