From 41d3df26f25b32fdfd189c14e2362b9ea907b752 Mon Sep 17 00:00:00 2001 From: occheung Date: Wed, 30 Sep 2020 16:43:39 +0800 Subject: [PATCH] mqtt_mux: profile independent output --- src/mqtt_mux.rs | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/mqtt_mux.rs b/src/mqtt_mux.rs index 3ee4643..7f01720 100644 --- a/src/mqtt_mux.rs +++ b/src/mqtt_mux.rs @@ -246,11 +246,11 @@ impl<'s, SPI, E> MqttMux<'s, SPI> where SPI: Transfer { MqttCommand::SingletoneAmplitude(ch, pr, _) | MqttCommand::SingletonePhase(ch, pr, _) => { let (f_out, phase, ampl) = self.urukul.get_channel_single_tone_profile(ch, pr)?; - vec.push(self.get_single_tone_frequency_message(ch, pr, f_out)?) + vec.push(self.get_single_tone_frequency_message(ch, f_out)?) .map_err(|_| Error::StringOutOfSpace)?; - vec.push(self.get_single_tone_phase_message(ch, pr, phase)?) + vec.push(self.get_single_tone_phase_message(ch, phase)?) .map_err(|_| Error::StringOutOfSpace)?; - vec.push(self.get_single_tone_amplitude_message(ch, pr, ampl)?) + vec.push(self.get_single_tone_amplitude_message(ch, ampl)?) .map_err(|_| Error::StringOutOfSpace)?; Ok(vec) } @@ -556,7 +556,7 @@ impl<'s, SPI, E> MqttMux<'s, SPI> where SPI: Transfer { )) } - fn get_single_tone_frequency_message(&mut self, ch: u8, pr: u8, f_out: f64) -> Result<(String, String), Error> { + fn get_single_tone_frequency_message(&mut self, ch: u8, f_out: f64) -> Result<(String, String), Error> { Ok(( { let mut topic_string = String::from(self.name); @@ -564,10 +564,6 @@ impl<'s, SPI, E> MqttMux<'s, SPI> where SPI: Transfer { .map_err(|_| Error::StringOutOfSpace)?; topic_string.push(char::from_digit(ch.into(), 10).unwrap()) .map_err(|_| Error::StringOutOfSpace)?; - topic_string.push_str("/Profile") - .map_err(|_| Error::StringOutOfSpace)?; - topic_string.push(char::from_digit(pr.into(), 10).unwrap()) - .map_err(|_| Error::StringOutOfSpace)?; topic_string.push_str("/Singletone/Frequency") .map_err(|_| Error::StringOutOfSpace)?; topic_string @@ -583,7 +579,7 @@ impl<'s, SPI, E> MqttMux<'s, SPI> where SPI: Transfer { )) } - fn get_single_tone_amplitude_message(&mut self, ch: u8, pr: u8, ampl: f64) -> Result<(String, String), Error> { + fn get_single_tone_amplitude_message(&mut self, ch: u8, ampl: f64) -> Result<(String, String), Error> { Ok(( { let mut topic_string = String::from(self.name); @@ -591,10 +587,6 @@ impl<'s, SPI, E> MqttMux<'s, SPI> where SPI: Transfer { .map_err(|_| Error::StringOutOfSpace)?; topic_string.push(char::from_digit(ch.into(), 10).unwrap()) .map_err(|_| Error::StringOutOfSpace)?; - topic_string.push_str("/Profile") - .map_err(|_| Error::StringOutOfSpace)?; - topic_string.push(char::from_digit(pr.into(), 10).unwrap()) - .map_err(|_| Error::StringOutOfSpace)?; topic_string.push_str("/Singletone/Amplitude") .map_err(|_| Error::StringOutOfSpace)?; topic_string @@ -608,7 +600,7 @@ impl<'s, SPI, E> MqttMux<'s, SPI> where SPI: Transfer { )) } - fn get_single_tone_phase_message(&mut self, ch: u8, pr: u8, phase: f64) -> Result<(String, String), Error> { + fn get_single_tone_phase_message(&mut self, ch: u8, phase: f64) -> Result<(String, String), Error> { Ok(( { let mut topic_string = String::from(self.name); @@ -616,10 +608,6 @@ impl<'s, SPI, E> MqttMux<'s, SPI> where SPI: Transfer { .map_err(|_| Error::StringOutOfSpace)?; topic_string.push(char::from_digit(ch.into(), 10).unwrap()) .map_err(|_| Error::StringOutOfSpace)?; - topic_string.push_str("/Profile") - .map_err(|_| Error::StringOutOfSpace)?; - topic_string.push(char::from_digit(pr.into(), 10).unwrap()) - .map_err(|_| Error::StringOutOfSpace)?; topic_string.push_str("/Singletone/Phase") .map_err(|_| Error::StringOutOfSpace)?; topic_string