Open LongZoz opened 1 year ago
What do the logs show?
I tried to print error,when i use tcp/ip connect another address(for example 192.168.0.1) ,mqtt connect target address(41.147.212.200) ,the result A 4,then disconnect the tcp/ip(192.168.0.1),finally return A 3
Err(e) => { match e{ w5500_mqtt::Error::StateTimeout(_c) => { defmt::info!("A "); match _c{ w5500_mqtt::State::Init => defmt::info!("2"), w5500_mqtt::State::WaitConInt => defmt::info!("3"), w5500_mqtt::State::WaitConAck => defmt::info!("4"), w5500_mqtt::State::Ready => defmt::info!("5"), } }, w5500_mqtt::Error::Disconnect => defmt::info!("A2"), w5500_mqtt::Error::TcpTimeout => defmt::info!("A3"), w5500_mqtt::Error::Decode => defmt::info!("A4"), w5500_mqtt::Error::Protocol => defmt::info!("A5"), w5500_mqtt::Error::ConnAck(_) => defmt::info!("A6"), w5500_mqtt::Error::OutOfMemory => defmt::info!("A7"), w5500_mqtt::Error::NotConnected => defmt::info!("A8"), w5500_mqtt::Error::Other(_) => defmt::info!("A9"), }
There are logs being printed out over UART, they contain a lot of information for debugging such as the status of the DHCP client. You can also look at a wireshark packet capture and your MQTT broker logs for more debug information.
it can send message to 192.168.0.1,as a client can receive from 192.168.0.1,but do mqtt_sn,the tcp connection(192.168.0.1) is disconnected,Perhaps it is trying to connect to mqtt's server using tcp,so (192.168.0.1) it disconnected
You'll definitely want to be looking at wireshark and your MQTT broker logs in that case. The UART logs would still be helpful because they'll inform you of the internal state.
I may have found the cause of the failure, if the mqtt server does not support users and passwords,i find this message in lib.rs
//! MQTT v5 client for the [Wiznet W5500] SPI internet offload chip.
//! # Limitations //! This is very basic at the moment, and will be expanded in the future. //! Does not support password protected MQTT servers. //! Only supports QoS 0: At most once delivery.`
when i start function->mqtt_sn,the program doesn't crash,but it's not connected to the target cloud,the program can execute to the first ok,then ... it break..... So what's the solution
`pub fn mqtt_sn(cx: mqtt_sn::Context){ defmt::info!("[TASK] mqtt_sn");
}`