chore: 更新。
This commit is contained in:
870
src-tauri/Cargo.lock
generated
870
src-tauri/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -158,16 +158,10 @@ impl Manager {
|
||||
|
||||
let rpc = rpc::Manager::global().await;
|
||||
|
||||
rpc.publish_desktop_cmd(&models::CmdRespMqMessage::Brightness(
|
||||
models::ConfigDisplayCmd {
|
||||
display_index: config.id,
|
||||
value: models::CmdRespWithRange {
|
||||
value: config.brightness,
|
||||
min: config.min_brightness,
|
||||
max: config.max_brightness,
|
||||
},
|
||||
},
|
||||
))
|
||||
rpc.publish_desktop_cmd(
|
||||
format!("display{}/brightness", display_brightness.display_index).as_str(),
|
||||
target.to_be_bytes().to_vec(),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
Err(err) => {
|
||||
|
@ -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