kenwood_thd75/protocol/
bluetooth.rs1use crate::error::ProtocolError;
7
8use super::Response;
9
10pub(crate) fn parse_bluetooth(
14 mnemonic: &str,
15 payload: &str,
16) -> Option<Result<Response, ProtocolError>> {
17 if mnemonic != "BT" {
18 return None;
19 }
20 Some(parse_bt(payload))
21}
22
23fn parse_bt(payload: &str) -> Result<Response, ProtocolError> {
25 match payload {
26 "0" => Ok(Response::Bluetooth { enabled: false }),
27 "1" => Ok(Response::Bluetooth { enabled: true }),
28 _ => Err(ProtocolError::FieldParse {
29 command: "BT".to_owned(),
30 field: "enabled".to_owned(),
31 detail: format!("expected 0 or 1, got {payload:?}"),
32 }),
33 }
34}