From 72770d927686b0e441e845848eb76d8402490100 Mon Sep 17 00:00:00 2001 From: occheung Date: Thu, 17 Sep 2020 17:05:09 +0800 Subject: [PATCH] mqtt_client: take out scpi --- examples/mqtt_client.rs | 60 +++++------------------------------------ 1 file changed, 7 insertions(+), 53 deletions(-) diff --git a/examples/mqtt_client.rs b/examples/mqtt_client.rs index 527300e..3c6a1da 100644 --- a/examples/mqtt_client.rs +++ b/examples/mqtt_client.rs @@ -1,8 +1,7 @@ #![no_std] #![no_main] -#[macro_use] -extern crate log; +use log::{info, warn}; use smoltcp as net; use stm32h7xx_hal::ethernet; @@ -31,44 +30,9 @@ use firmware::{ cpld::{ CPLD, }, - scpi::{ - HelloWorldCommand, - Channel0SwitchCommand, - Channel1SwitchCommand, - Channel2SwitchCommand, - Channel3SwitchCommand, - Channel0AttenuationCommand, - Channel1AttenuationCommand, - Channel2AttenuationCommand, - Channel3AttenuationCommand, - ClockSourceCommand, - ClockDivisionCommand, - ProfileCommand, - Channel0Profile0Singletone - }, - Urukul, scpi_root, recursive_scpi_tree, scpi_tree }; -use firmware::translation::MqttScpiTranslator; - -use scpi::prelude::*; -use scpi::ieee488::commands::*; -use scpi::scpi::commands::*; -use scpi::{ - ieee488_cls, - ieee488_ese, - ieee488_esr, - ieee488_idn, - ieee488_opc, - ieee488_rst, - ieee488_sre, - ieee488_stb, - ieee488_tst, - ieee488_wai, - scpi_crate_version, - scpi_status, - scpi_system, -}; -use scpi::Context; +use firmware::Urukul; +use firmware::mqtt_mux::{MqttCommandType, MqttMux}; #[path = "util/logger.rs"] mod logger; @@ -216,16 +180,9 @@ fn main() -> ! { cp.SCB.invalidate_icache(); cp.SCB.enable_icache(); - // Define SCPI tree - let tree = scpi_tree!(); - - // Device was declared in prior - let mut errors = ArrayErrorQueue::<[Error; 10]>::new(); - let mut context = Context::new(&mut urukul, &mut errors, tree); - - //Response bytebuffer - let mut buf = ArrayVecFormatter::<[u8; 256]>::new(); - // SCPI configs END + // 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; @@ -274,10 +231,7 @@ fn main() -> ! { topic => { info!("On '{:?}', received: {:?}", topic, message); // Why is topic a string while message is a slice? - context.run_with_mqtt(topic, - core::str::from_utf8(message).unwrap(), - &mut buf) - .unwrap(); + mqtt_mux.handle_command(topic, message).unwrap(); }, }).is_ok();