mqtt_client: take out scpi

This commit is contained in:
occheung 2020-09-17 17:05:09 +08:00
parent 74f7b7ce61
commit 72770d9276
1 changed files with 7 additions and 53 deletions

View File

@ -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();