Configure WiFi settings
This commit is contained in:
@@ -123,7 +123,7 @@ impl std::fmt::Display for ErrorState {
|
||||
#[derive(Clone)]
|
||||
#[repr(u8)]
|
||||
pub enum RPCCommand {
|
||||
SendWifiSettings = 0x01,
|
||||
SendWiFiSettings = 0x01,
|
||||
RequestCurrentState = 0x02,
|
||||
RequestDeviceInformation = 0x03,
|
||||
RequestScannedWiFiNetworks = 0x04,
|
||||
@@ -134,7 +134,7 @@ impl TryFrom<&u8> for RPCCommand {
|
||||
|
||||
fn try_from(b: &u8) -> Result<Self, Self::Error> {
|
||||
match b {
|
||||
0x01 => Ok(Self::SendWifiSettings),
|
||||
0x01 => Ok(Self::SendWiFiSettings),
|
||||
0x02 => Ok(Self::RequestCurrentState),
|
||||
0x03 => Ok(Self::RequestDeviceInformation),
|
||||
0x04 => Ok(Self::RequestScannedWiFiNetworks),
|
||||
@@ -310,6 +310,34 @@ impl ImprovDataFromPacket for ErrorStatePacket {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SendWiFiSettingsPacket {
|
||||
pub ssid: String,
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
impl ImprovDataPacketType for SendWiFiSettingsPacket {
|
||||
const packet_type: PacketType = PacketType::RPCCommand;
|
||||
}
|
||||
|
||||
impl ImprovDataToPacket for SendWiFiSettingsPacket {
|
||||
fn to_bytes(self: &Self) -> Vec<u8> {
|
||||
let ssid_bytes = self.ssid.as_bytes();
|
||||
let ssid_len: u8 = ssid_bytes.len().try_into().unwrap();
|
||||
|
||||
let password_bytes = self.password.as_bytes();
|
||||
let password_len: u8 = password_bytes.len().try_into().unwrap();
|
||||
|
||||
let mut out = Vec::new();
|
||||
out.push(RPCCommand::SendWiFiSettings as u8);
|
||||
out.push(1 + ssid_len + 1 + password_len); // data len
|
||||
out.push(ssid_len);
|
||||
out.extend_from_slice(ssid_bytes);
|
||||
out.push(password_len);
|
||||
out.extend_from_slice(password_bytes);
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
pub struct RequestCurrentStatePacket {
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user