Skip to main content

ezsp/frame/parameters/networking/
multi_phy_set_radio_power.rs

1//! Parameters for the [`Networking::multi_phy_set_radio_power`](crate::Networking::multi_phy_set_radio_power) command.
2
3use num_traits::FromPrimitive;
4
5use crate::Error;
6use crate::ember::Status;
7
8crate::frame::parameters::frame!(
9    0x00FA,
10    { phy_index: u8, power: i8 },
11    impl {
12        impl Command {
13            /// Creates command parameters.
14            #[must_use]
15            pub const fn new(phy_index: u8, power: i8) -> Self {
16                Self { phy_index, power }
17            }
18        }
19    },
20    { status: u8 } => Networking(networking)::MultiPhySetRadioPower,
21    impl {
22        /// Convert a response into `()` or an appropriate [`Error`] depending on its status.
23        impl TryFrom<Response> for () {
24            type Error = Error;
25
26            fn try_from(response: Response) -> Result<Self, Self::Error> {
27                match Status::from_u8(response.status).ok_or(response.status) {
28                    Ok(Status::Success) => Ok(()),
29                    other => Err(other.into()),
30                }
31            }
32        }
33    }
34);