chore: 更新。
This commit is contained in:
@@ -52,11 +52,9 @@ impl Manager {
|
||||
pub async fn publish_led_sub_pixels(&self, payload: Vec<u8>) -> anyhow::Result<()> {
|
||||
self.client.publish_led_sub_pixels(payload).await
|
||||
}
|
||||
pub async fn publish_desktop_cmd<T>(&self, msg: &T) -> anyhow::Result<()>
|
||||
where
|
||||
T: ?Sized + serde::Serialize,
|
||||
pub async fn publish_desktop_cmd(&self, field: &str, payload: Vec<u8>) -> anyhow::Result<()>
|
||||
{
|
||||
self.client.publish_desktop_cmd(msg).await
|
||||
self.client.publish_desktop_cmd(field, payload).await
|
||||
}
|
||||
|
||||
pub fn client(&self) -> &MqttRpc {
|
||||
|
@@ -12,7 +12,6 @@ const DISPLAY_TOPIC: &'static str = "display-ambient-light/display";
|
||||
const DESKTOP_TOPIC: &'static str = "display-ambient-light/desktop";
|
||||
const DISPLAY_BRIGHTNESS_TOPIC: &'static str = "display-ambient-light/board/brightness";
|
||||
const BOARD_SEND_CMD: &'static str = "display-ambient-light/board/cmd";
|
||||
const DESKTOP_SEND_CMD: &'static str = "display-ambient-light/desktop/cmd";
|
||||
|
||||
pub struct MqttRpc {
|
||||
client: mqtt::AsyncClient,
|
||||
@@ -227,16 +226,12 @@ impl MqttRpc {
|
||||
) -> broadcast::Receiver<display::DisplayBrightness> {
|
||||
self.change_display_brightness_tx.subscribe()
|
||||
}
|
||||
pub async fn publish_desktop_cmd<T>(&self, msg: &T) -> anyhow::Result<()>
|
||||
where
|
||||
T: ?Sized + serde::Serialize,
|
||||
pub async fn publish_desktop_cmd(&self, field: &str, payload: Vec<u8>) -> anyhow::Result<()>
|
||||
{
|
||||
let str = serde_json::to_string(msg)
|
||||
.map_err(|err| anyhow::anyhow!("can not serialize. {:?}", err))?;
|
||||
self.client
|
||||
.publish(mqtt::Message::new(
|
||||
DESKTOP_SEND_CMD,
|
||||
str.as_bytes(),
|
||||
format!("{}/{}", DESKTOP_TOPIC, field),
|
||||
payload,
|
||||
mqtt::QOS_1,
|
||||
))
|
||||
.await
|
||||
|
Reference in New Issue
Block a user