use super::base::*;
use crate::alink::{AlinkRequest, AlinkResponse, SysAck};
use crate::{Error, Result, ThreeTuple};
use regex::Regex;
use rumqttc::{AsyncClient, QoS};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::fs;
use std::sync::Arc;
use tokio::sync::mpsc;
use tokio::sync::mpsc::{Receiver, Sender};
impl super::Module {
pub async fn get(&self, config_scope: &str, get_type: &str) -> crate::Result<()> {
let payload: LogConfigGetRequest = AlinkRequest::new(
"thing.config.log.get",
LogConfigGet {
config_scope: config_scope.to_string(),
get_type: get_type.to_string(),
},
1,
);
let topic = format!(
"/sys/{}/{}/thing/config/log/get",
self.three.product_key, self.three.device_name
);
self.publish(topic, &payload).await
}
pub async fn get_default(&self) -> crate::Result<()> {
self.get("device", "content").await
}
pub async fn post(&self, logs: Vec<LogItem>) -> crate::Result<()> {
let payload: LogPostRequest = AlinkRequest::new_no_ack("thing.log.post", logs);
let topic = format!(
"/sys/{}/{}/thing/log/post",
self.three.product_key, self.three.device_name
);
self.publish(topic, &payload).await
}
}
pub type LogConfigGetRequest = AlinkRequest<LogConfigGet>;
pub type LogPostRequest = AlinkRequest<Vec<LogItem>>;