use std::str;
use ota::{v2::OTAPackage, OtaVersion};
use serde::{Deserialize, Serialize};
use serde_repr::*;
use clap::Parser;
pub mod ota;
pub const DEFAULT_OTA_VERSION: &str = "2";
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct OtaImageListResponse {
pub images: Vec<(String, OTAPackage)>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct OtaGroupListResponse {
pub groups: Vec<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct OtaRequest {
pub cmd: OtaRequestCmd,
pub version: Option<OtaVersion>,
}
#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone, Copy)]
#[repr(u8)]
pub enum OtaRequestCmd {
Check,
Done,
}
#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone, Copy)]
#[repr(u8)]
pub enum ManagmentDataType {
Application,
AddOta,
RemoveOta,
LinkOta,
UnlinkOta,
GetGroupList,
GetImageList,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ManagementData {
pub cmd: ManagmentDataType,
pub target: Option<String>,
pub msg: Vec<u8>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PyrinasEventName {
pub size: u32,
pub bytes: Vec<u8>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PyrinasEventData {
pub size: u32,
pub bytes: Vec<u8>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct PyrinasEvent {
pub name: PyrinasEventName,
pub data: PyrinasEventData,
pub peripheral_addr: Vec<u8>,
pub central_addr: Vec<u8>,
pub peripheral_rssi: i8,
pub central_rssi: i8,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ApplicationData {
pub uid: String,
pub target: String,
pub msg: Vec<u8>,
}
#[derive(Parser, Debug, Serialize, Deserialize)]
#[clap(version)]
pub struct OtaLink {
pub device_id: Option<String>,
pub group_id: Option<String>,
pub image_id: Option<String>,
#[clap(long, default_value = DEFAULT_OTA_VERSION)]
pub ota_version: u8,
}