feat: GetMac command + MacAddress response
New protocol command (tag 8): GetMac returns the board's 6-byte hardware address. Useful when multiple dongles are connected to one host. Response (tag 6): MacAddress containing 6 raw bytes. Updated: PROTOCOL.md, CHANGELOG, donglora.py decoder, all_commands.py.
This commit is contained in:
7 files changed
+33
-7
No files matched your search
@@ -139,6 +139,7 @@ pub enum Command {
|
||||
},
|
||||
DisplayOn,
|
||||
DisplayOff,
|
||||
GetMac,
|
||||
}
|
||||
|
||||
impl Command {
|
||||
@@ -178,6 +179,7 @@ impl Command {
|
||||
}
|
||||
6 => Some(Self::DisplayOn),
|
||||
7 => Some(Self::DisplayOff),
|
||||
8 => Some(Self::GetMac),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -197,6 +199,7 @@ pub enum Response {
|
||||
TxDone,
|
||||
Ok,
|
||||
Error(ErrorCode),
|
||||
MacAddress([u8; 6]),
|
||||
}
|
||||
|
||||
impl Response {
|
||||
@@ -232,6 +235,11 @@ impl Response {
|
||||
buf[1] = code as u8;
|
||||
2
|
||||
}
|
||||
Self::MacAddress(mac) => {
|
||||
buf[0] = 6;
|
||||
buf[1..7].copy_from_slice(&mac);
|
||||
7
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -219,7 +219,7 @@ async fn handle_cmd(
|
||||
status.sender().send(state.clone());
|
||||
responses.send(Response::Ok).await;
|
||||
}
|
||||
Command::DisplayOn | Command::DisplayOff => {}
|
||||
Command::DisplayOn | Command::DisplayOff | Command::GetMac => {}
|
||||
Command::Transmit { config, payload } => {
|
||||
let tx_config = config.map(|c| c.resolve_power(Board::TX_POWER_RANGE)).or(state.config);
|
||||
if let Some(cfg) = tx_config {
|
||||
|
||||
@@ -207,6 +207,12 @@ async fn route_command(
|
||||
responses.send(Response::Error(ErrorCode::NoDisplay)).await;
|
||||
}
|
||||
}
|
||||
Command::GetMac => {
|
||||
use crate::board::{Board, LoRaBoard};
|
||||
responses
|
||||
.send(Response::MacAddress(Board::mac_address()))
|
||||
.await;
|
||||
}
|
||||
other => {
|
||||
commands.send(other).await;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user