atcommand_set/
atcommand_set.rs1use rustbee::{api, device::DigiMeshDevice};
8use std::error;
9
10#[cfg(target_os = "linux")]
11static PORT: &'static str = "/dev/ttyUSB0";
12
13#[cfg(target_os = "windows")]
14static PORT: &'static str = "COM1";
15
16static NODE_ID: &'static str = "MY_NODE";
17
18fn main() -> Result<(), Box<dyn error::Error>> {
19 let mut device = DigiMeshDevice::new(PORT, 9600)?;
21
22 let _ = api::AtCommandFrame("NI", Some(NODE_ID.as_bytes()));
24
25 let new_node_id = api::AtCommandFrame("NI", None);
27
28 let response = device.send_frame(new_node_id)?;
30
31 let atcommand_response = response.downcast_ref::<api::AtCommandResponse>();
33
34 if let Some(obj) = atcommand_response {
35 let cmd_data = &obj.command_data;
36 println!("{:?}", cmd_data); }
38
39 Ok(())
40}