Skip to content

Commit

Permalink
Merge pull request #50 from thekuwayama/feature/controller_packet
Browse files Browse the repository at this point in the history
feature: support ClassPacket::Controller
  • Loading branch information
tomoyuki-nakabayashi authored Dec 14, 2023
2 parents ae97f98 + 002a75c commit 0c5874b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
14 changes: 14 additions & 0 deletions echonet-lite-core/src/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ pub enum ClassPacket {
LightingSystem(LightingSystemPacket),
/// Node profile class packet
Profile(ProfilePacket),
/// Controller class
Controller(ControllerPacket),
}

impl ClassPacket {
Expand Down Expand Up @@ -69,6 +71,7 @@ impl ClassPacket {
ClassPacket::LightingSystem(LightingSystemPacket(props))
}
ClassCode(code::PROFILE) => ClassPacket::Profile(ProfilePacket(props)),
ClassCode(code::CONTROLLER) => ClassPacket::Controller(ControllerPacket(props)),
_ => ClassPacket::Unimplemented(UnimplementedPacket(eoj.class, props)),
}
}
Expand All @@ -90,6 +93,7 @@ impl ClassPacket {
Self::MonoFunctionLighting(p) => p.properties(),
Self::LightingSystem(p) => p.properties(),
Self::Profile(p) => p.properties(),
Self::Controller(p) => p.properties(),
}
}
}
Expand All @@ -116,6 +120,7 @@ impl From<ElPacket> for ClassPacket {
}
ClassCode(code::LIGHTING_SYSTEM) => ClassPacket::LightingSystem(value.into()),
ClassCode(code::PROFILE) => ClassPacket::Profile(value.into()),
ClassCode(code::CONTROLLER) => ClassPacket::Controller(value.into()),
_ => ClassPacket::Unimplemented(value.into()),
}
}
Expand All @@ -137,6 +142,7 @@ impl fmt::Display for ClassPacket {
ClassPacket::MonoFunctionLighting(v) => write!(f, "{v}")?,
ClassPacket::LightingSystem(v) => write!(f, "{v}")?,
ClassPacket::Profile(v) => write!(f, "{v}")?,
ClassPacket::Controller(v) => write!(f, "{v}")?,
ClassPacket::Unimplemented(v) => write!(f, "{v}")?,
}
Ok(())
Expand Down Expand Up @@ -338,6 +344,14 @@ convert_packet!(
pub struct ProfilePacket(Properties);
convert_packet!(code::PROFILE, ProfilePacket, PROFILE_CLASS, "Node Profile");

pub struct ControllerPacket(Properties);
convert_packet!(
code::CONTROLLER,
ControllerPacket,
CONTROLLER_CLASS,
"Controller"
);

pub struct Controller;
impl Controller {
#[allow(dead_code)]
Expand Down
20 changes: 20 additions & 0 deletions echonet-lite-core/src/object/property_maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,3 +431,23 @@ pub static LIGHTING_SYSTEM_CLASS: phf::Map<u8, &'static str> = phf_map! {
0xC0u8 => "シーン制御設定",
0xC1u8 => "シーン制御設定可能数",
};

pub static CONTROLLER_CLASS: phf::Map<u8, &'static str> = phf_map! {
0xC0u8 => "コントローラID",
0xC1u8 => "管理台数",
0xC2u8 => "インデックス",
0xC3u8 => "機器ID",
0xC4u8 => "機種",
0xC5u8 => "名称",
0xC6u8 => "接続状態",
0xC7u8 => "管理対象機器事業者コード",
0xC8u8 => "管理対象機器商品コード",
0xC9u8 => "管理対象機器製造年月日",
0xCAu8 => "管理対象機器登録情報更新年月日",
0xCBu8 => "管理対象機器登録情報更新バージョン情報",
0xCCu8 => "管理対象機器設置場所",
0xCDu8 => "管理対象機器異常発生状態",
0xCEu8 => "管理対象機器Setプロパティマップ",
0xCFu8 => "管理対象機器Getプロパティマップ",
0xE0u8 => "設置住所",
};

0 comments on commit 0c5874b

Please sign in to comment.