wled_json_api_library/structures/
net.rs

1use serde;
2use serde::{Serialize, Deserialize};
3use serde_repr::{Deserialize_repr, Serialize_repr};
4use crate::errors::WledJsonApiError;
5use crate::structures::none_function;
6
7
8
9#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
10#[serde(rename_all = "camelCase")]
11pub struct Net {
12    /// list of networks found by most recent scan
13    #[serde(skip_serializing_if = "Option::is_none")]
14    #[serde(default = "none_function")]
15    pub networks: Option<Vec<Network>>,
16}
17
18impl TryFrom<&str> for Net{
19    type Error = WledJsonApiError;
20    fn try_from(str_in: &str) -> Result<Net, WledJsonApiError> {
21        serde_json::from_str(str_in).map_err(|e| {WledJsonApiError::SerdeError(e)})
22    }
23}
24
25#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
26#[serde(rename_all = "camelCase")]
27pub struct Network {
28    /// SSID
29    #[serde(skip_serializing_if = "Option::is_none")]
30    #[serde(default = "none_function")]
31    pub ssid: Option<String>,
32
33    /// RSSI
34    #[serde(skip_serializing_if = "Option::is_none")]
35    #[serde(default = "none_function")]
36    pub rssi: Option<i32>,
37
38    /// String MAC / BSSID of scanned wifi
39    #[serde(skip_serializing_if = "Option::is_none")]
40    #[serde(default = "none_function")]
41    pub bssid: Option<String>,
42
43    /// Wifi channel. normally these are 1-14 but WLED source uses i32 at time of writing
44    #[serde(skip_serializing_if = "Option::is_none")]
45    #[serde(default = "none_function")]
46    pub channel: Option<i32>,
47
48    /// encryption type (enum wl_enc_type) of the specified item on the networks scanned list
49    #[serde(skip_serializing_if = "Option::is_none")]
50    #[serde(default = "none_function")]
51    pub enc: Option<ApBehaviourEnum>,
52}
53
54
55/// words do not begin to explain how hard this was to find.
56/// its buried in the esp core arduino framework.
57#[derive(Serialize_repr, Deserialize_repr, PartialEq, Debug, Clone)]
58#[allow(non_camel_case_types)]
59#[repr(u8)]
60pub enum ApBehaviourEnum {
61    /** authenticate mode : open */
62    WIFI_AUTH_OPEN,
63    /** authenticate mode : WEP */
64    WIFI_AUTH_WEP,
65    /** authenticate mode : WPA_PSK */
66    WIFI_AUTH_WPA_PSK,
67    /** authenticate mode : WPA2_PSK */
68    WIFI_AUTH_WPA2_PSK,
69    /** authenticate mode : WPA_WPA2_PSK */
70    WIFI_AUTH_WPA_WPA2_PSK,
71    /** authenticate mode : WPA2_ENTERPRISE */
72    WIFI_AUTH_WPA2_ENTERPRISE,
73    /// probaly you found a CIA AP. Run
74    WIFI_AUTH_MAX,
75    /// Reserved to keep some semblance of backwards compatibility when new versions of whatever the fuck this came from come out
76    RSVD1,
77    /// Reserved to keep some semblance of backwards compatibility when new versions of whatever the fuck this came from come out
78    RSVD2,
79    /// Reserved to keep some semblance of backwards compatibility when new versions of whatever the fuck this came from come out
80    RSVD3,
81    /// Reserved to keep some semblance of backwards compatibility when new versions of whatever the fuck this came from come out
82    RSVD4,
83    /// Reserved to keep some semblance of backwards compatibility when new versions of whatever the fuck this came from come out
84    RSVD5,
85    /// Reserved to keep some semblance of backwards compatibility when new versions of whatever the fuck this came from come out
86    RSVD6,
87    /// Reserved to keep some semblance of backwards compatibility when new versions of whatever the fuck this came from come out
88    RSVD7,
89    /// Reserved to keep some semblance of backwards compatibility when new versions of whatever the fuck this came from come out
90    RSVD8,
91    /// Reserved to keep some semblance of backwards compatibility when new versions of whatever the fuck this came from come out
92    RSVD9,
93}