1use fidl_fuchsia_wlan_ieee80211 as fidl_ieee80211;
6use fidl_fuchsia_wlan_sme as fidl_sme;
7use serde::{Deserialize, Serialize};
8
9#[derive(Serialize, Deserialize)]
10#[serde(remote = "fidl_sme::Protection")]
11pub(crate) enum ProtectionDef {
12 Unknown = 0,
13 Open = 1,
14 Wep = 2,
15 Wpa1 = 3,
16 Wpa1Wpa2PersonalTkipOnly = 4,
17 Wpa2PersonalTkipOnly = 5,
18 Wpa1Wpa2Personal = 6,
19 Wpa2Personal = 7,
20 Wpa2Wpa3Personal = 8,
21 Wpa3Personal = 9,
22 Wpa2Enterprise = 10,
23 Wpa3Enterprise = 11,
24 Owe = 12,
25 OpenOweTransition = 13,
26}
27
28#[derive(Serialize, Deserialize)]
31#[repr(u32)]
32pub(crate) enum ChannelBandwidthDef {
33 Cbw20 = 0,
34 Cbw40 = 1,
35 Cbw40Below = 2,
36 Cbw80 = 3,
37 Cbw160 = 4,
38 Cbw80P80 = 5,
39 Unknown = u32::MAX,
40}
41
42impl From<fidl_ieee80211::ChannelBandwidth> for ChannelBandwidthDef {
43 fn from(fidl_type: fidl_ieee80211::ChannelBandwidth) -> Self {
44 match fidl_type {
45 fidl_ieee80211::ChannelBandwidth::Cbw20 => Self::Cbw20,
46 fidl_ieee80211::ChannelBandwidth::Cbw40 => Self::Cbw40,
47 fidl_ieee80211::ChannelBandwidth::Cbw40Below => Self::Cbw40Below,
48 fidl_ieee80211::ChannelBandwidth::Cbw80 => Self::Cbw80,
49 fidl_ieee80211::ChannelBandwidth::Cbw160 => Self::Cbw160,
50 fidl_ieee80211::ChannelBandwidth::Cbw80P80 => Self::Cbw80P80,
51 fidl_ieee80211::ChannelBandwidthUnknown!() => Self::Unknown,
52 }
53 }
54}
55
56impl From<ChannelBandwidthDef> for fidl_ieee80211::ChannelBandwidth {
57 fn from(serde_type: ChannelBandwidthDef) -> Self {
58 match serde_type {
59 ChannelBandwidthDef::Cbw20 => Self::Cbw20,
60 ChannelBandwidthDef::Cbw40 => Self::Cbw40,
61 ChannelBandwidthDef::Cbw40Below => Self::Cbw40Below,
62 ChannelBandwidthDef::Cbw80 => Self::Cbw80,
63 ChannelBandwidthDef::Cbw160 => Self::Cbw160,
64 ChannelBandwidthDef::Cbw80P80 => Self::Cbw80P80,
65 ChannelBandwidthDef::Unknown => Self::unknown(),
66 }
67 }
68}
69
70#[derive(Serialize, Deserialize)]
71pub(crate) struct WlanChannelDef {
72 pub primary: u8,
73 pub cbw: ChannelBandwidthDef,
74 pub secondary80: u8,
75}
76
77impl From<fidl_ieee80211::WlanChannel> for WlanChannelDef {
78 fn from(fidl_type: fidl_ieee80211::WlanChannel) -> Self {
79 Self {
80 primary: fidl_type.primary,
81 cbw: fidl_type.cbw.into(),
82 secondary80: fidl_type.secondary80,
83 }
84 }
85}
86
87impl From<WlanChannelDef> for fidl_ieee80211::WlanChannel {
88 fn from(serde_type: WlanChannelDef) -> Self {
89 Self {
90 primary: serde_type.primary,
91 cbw: serde_type.cbw.into(),
92 secondary80: serde_type.secondary80,
93 }
94 }
95}
96
97#[derive(Serialize)]
98pub(crate) struct ServingApInfoDef {
99 pub bssid: [u8; 6],
100 pub ssid: Vec<u8>,
101 pub rssi_dbm: i8,
102 pub snr_db: i8,
103 pub channel: WlanChannelDef,
104 #[serde(with = "ProtectionDef")]
105 pub protection: fidl_sme::Protection,
106}
107
108impl From<fidl_sme::ServingApInfo> for ServingApInfoDef {
109 fn from(fidl_type: fidl_sme::ServingApInfo) -> Self {
110 Self {
111 bssid: fidl_type.bssid,
112 ssid: fidl_type.ssid,
113 rssi_dbm: fidl_type.rssi_dbm,
114 snr_db: fidl_type.snr_db,
115 channel: fidl_type.channel.into(),
116 protection: fidl_type.protection,
117 }
118 }
119}
120
121#[derive(Serialize)]
122#[serde(remote = "fidl_sme::Empty")]
123pub(crate) struct SmeEmptyDef;
124
125#[derive(Serialize)]
126pub(crate) enum ClientStatusResponseDef {
127 Connected(ServingApInfoDef),
128 Connecting(Vec<u8>),
129 Roaming(Vec<u8>),
130 #[serde(with = "SmeEmptyDef")]
131 Idle(fidl_sme::Empty),
132}
133
134impl From<fidl_sme::ClientStatusResponse> for ClientStatusResponseDef {
135 fn from(fidl_type: fidl_sme::ClientStatusResponse) -> Self {
136 match fidl_type {
137 fidl_sme::ClientStatusResponse::Connected(info) => Self::Connected(info.into()),
138 fidl_sme::ClientStatusResponse::Connecting(vec) => Self::Connecting(vec),
139 fidl_sme::ClientStatusResponse::Roaming(bssid) => Self::Roaming(bssid.to_vec()),
140 fidl_sme::ClientStatusResponse::Idle(empty) => Self::Idle(empty),
141 }
142 }
143}