1use std::str;
2
3use ota::{v2::OTAPackage, OtaVersion};
4use serde::{Deserialize, Serialize};
5use serde_repr::*;
6
7use clap::Parser;
8
9pub mod ota;
11
12pub const DEFAULT_OTA_VERSION: &str = "2";
14
15#[derive(Serialize, Deserialize, Debug, Clone)]
16pub struct OtaImageListResponse {
17 pub images: Vec<(String, OTAPackage)>,
18}
19
20#[derive(Serialize, Deserialize, Debug, Clone)]
21pub struct OtaGroupListResponse {
22 pub groups: Vec<String>,
23}
24
25#[derive(Serialize, Deserialize, Debug, Clone)]
26pub struct OtaRequest {
27 pub cmd: OtaRequestCmd,
28 pub version: Option<OtaVersion>,
29}
30
31#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone, Copy)]
33#[repr(u8)]
34pub enum OtaRequestCmd {
35 Check,
36 Done,
37}
38
39#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone, Copy)]
40#[repr(u8)]
41pub enum ManagmentDataType {
42 Application,
43 AddOta,
44 RemoveOta,
45 LinkOta,
46 UnlinkOta,
47 GetGroupList,
48 GetImageList,
49}
50
51#[derive(Serialize, Deserialize, Debug, Clone)]
52pub struct ManagementData {
53 pub cmd: ManagmentDataType,
54 pub target: Option<String>,
55 pub msg: Vec<u8>,
56}
57
58#[derive(Serialize, Deserialize, Debug, Clone)]
59pub struct PyrinasEventName {
60 pub size: u32,
61 pub bytes: Vec<u8>,
62}
63
64#[derive(Serialize, Deserialize, Debug, Clone)]
65pub struct PyrinasEventData {
66 pub size: u32,
67 pub bytes: Vec<u8>,
68}
69
70#[derive(Serialize, Deserialize, Debug, Clone)]
71pub struct PyrinasEvent {
72 pub name: PyrinasEventName,
73 pub data: PyrinasEventData,
74 pub peripheral_addr: Vec<u8>,
75 pub central_addr: Vec<u8>,
76 pub peripheral_rssi: i8,
77 pub central_rssi: i8,
78}
79
80#[derive(Serialize, Deserialize, Debug, Clone)]
81pub struct ApplicationData {
82 pub uid: String,
83 pub target: String,
84 pub msg: Vec<u8>,
85}
86
87#[derive(Parser, Debug, Serialize, Deserialize)]
89#[clap(version)]
90pub struct OtaLink {
91 pub device_id: Option<String>,
93 pub group_id: Option<String>,
95 pub image_id: Option<String>,
97 #[clap(long, default_value = DEFAULT_OTA_VERSION)]
99 pub ota_version: u8,
100}