From 5dc9ec5a08e0e0208584fbaa337c6e628fe99de4 Mon Sep 17 00:00:00 2001 From: occheung Date: Wed, 23 Sep 2020 10:44:38 +0800 Subject: [PATCH] mqtt_client: rm debug --- examples/mqtt_client.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/mqtt_client.rs b/examples/mqtt_client.rs index e3a4995..ab2557d 100644 --- a/examples/mqtt_client.rs +++ b/examples/mqtt_client.rs @@ -129,10 +129,15 @@ fn main() -> ! { let neighbor_cache = net::iface::NeighborCache::new(&mut store.neighbor_cache[..]); + let mut routes = net::iface::Routes::new(&mut store.routes_cache[..]); + let default_v4_gw = net::wire::Ipv4Address::new(192, 168, 1, 1); + routes.add_default_ipv4_route(default_v4_gw).unwrap(); + let mut net_interface = net::iface::EthernetInterfaceBuilder::new(eth_dma) .ethernet_addr(mac_addr) .neighbor_cache(neighbor_cache) .ip_addrs(&mut store.ip_addrs[..]) + .routes(routes) .finalize(); /* @@ -173,9 +178,7 @@ fn main() -> ! { cp.SCB.invalidate_icache(); cp.SCB.enable_icache(); - // TODO: Remove this simple test let mut mqtt_mux = MqttMux::new(urukul); - info!("{:?}", mqtt_mux.handle_command("Urukul/Control/Channel0/Switch", "on".as_bytes())); // Time unit in ms let mut time: u32 = 0; @@ -220,16 +223,14 @@ fn main() -> ! { } let connection = client - .poll(|_client, topic, message, _properties| match topic { - topic => { - info!("On '{:?}', received: {:?}", topic, message); - // Why is topic a string while message is a slice? - mqtt_mux.handle_command(topic, message).unwrap(); - }, + .poll(|_client, topic, message, _properties| { + info!("On '{:?}', received: {:?}", topic, message); + // Why is topic a string while message is a slice? + mqtt_mux.process_mqtt(topic, message); }).is_ok(); if connection && !has_subscribed && tick { - match client.subscribe("Urukul/Control", &[]) { + match client.subscribe("Urukul/Control/#", &[]) { Ok(()) => has_subscribed = true, Err(minimq::Error::NotReady) => {}, e => warn!("{:?}", e),