quicksave
This commit is contained in:
28
src/main.rs
28
src/main.rs
@@ -29,16 +29,28 @@ fn main() -> ! {
|
|||||||
|
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
|
|
||||||
for cmd in [Role, Baudrate, PanId, Channel, TransmitPower, MAC, ZigbeeNetworkKey] {
|
let cmd = ZigbeeNetworkKey;
|
||||||
let command_string = cmd.to_str();
|
let command_string = cmd.to_str();
|
||||||
let response = webee.send_cmd(cmd);
|
let response = webee.send_cmd(cmd);
|
||||||
|
|
||||||
ufmt::uwrite!(&mut serial, "{}:", command_string).void_unwrap();
|
ufmt::uwrite!(&mut serial, "[{}] {}:", response.len(), command_string).void_unwrap();
|
||||||
for i in 0..response.len() {
|
for i in 0..response.len() {
|
||||||
ufmt::uwrite!(&mut serial, " {:02X}", *response.get(i).unwrap()).void_unwrap();
|
// for i in 0..10 {
|
||||||
}
|
ufmt::uwrite!(&mut serial, " {:02X}", *response.get(i).unwrap()).void_unwrap();
|
||||||
ufmt::uwriteln!(&mut serial, "").void_unwrap();
|
|
||||||
}
|
}
|
||||||
|
ufmt::uwriteln!(&mut serial, "").void_unwrap();
|
||||||
|
|
||||||
|
// for cmd in [Role, Baudrate, PanId, Channel, TransmitPower, MAC, ZigbeeNetworkKey] {
|
||||||
|
// let command_string = cmd.to_str();
|
||||||
|
// let response = webee.send_cmd(cmd);
|
||||||
|
//
|
||||||
|
// ufmt::uwrite!(&mut serial, "[{}] {}:", response.len(), command_string).void_unwrap();
|
||||||
|
// for i in 0..response.len() {
|
||||||
|
// // for i in 0..10 {
|
||||||
|
// ufmt::uwrite!(&mut serial, " {:02X}", *response.get(i).unwrap()).void_unwrap();
|
||||||
|
// }
|
||||||
|
// ufmt::uwriteln!(&mut serial, "").void_unwrap();
|
||||||
|
// }
|
||||||
|
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
|
|
||||||
|
|||||||
35
src/webee.rs
35
src/webee.rs
@@ -26,7 +26,7 @@ pub enum SendCmd {
|
|||||||
AllDataTransmission = 0xB9,
|
AllDataTransmission = 0xB9,
|
||||||
MAC = 0xBA,
|
MAC = 0xBA,
|
||||||
LocalShortAddress = 0xBB,
|
LocalShortAddress = 0xBB,
|
||||||
ZigbeeNetworkKey = 0xBC
|
ZigbeeNetworkKey = 0xBC,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SendCmd where {
|
impl SendCmd where {
|
||||||
@@ -45,15 +45,15 @@ impl SendCmd where {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<USART, RX, TX>
|
impl<USART, RX, TX>
|
||||||
Webee<
|
Webee<
|
||||||
USART,
|
USART,
|
||||||
Pin<Input, RX>,
|
Pin<Input, RX>,
|
||||||
Pin<Output, TX>
|
Pin<Output, TX>
|
||||||
>
|
>
|
||||||
where
|
where
|
||||||
USART: UsartOps<Atmega, Pin<Input, RX>, Pin<Output, TX>>,
|
USART: UsartOps<Atmega, Pin<Input, RX>, Pin<Output, TX>>,
|
||||||
RX: PinOps,
|
RX: PinOps,
|
||||||
TX: PinOps
|
TX: PinOps
|
||||||
{
|
{
|
||||||
pub fn new(device: USART, rx: Pin<Input, RX>, tx: Pin<Output, TX>) -> Self {
|
pub fn new(device: USART, rx: Pin<Input, RX>, tx: Pin<Output, TX>) -> Self {
|
||||||
let instance = Self {
|
let instance = Self {
|
||||||
@@ -69,7 +69,7 @@ where
|
|||||||
self.webee.write_byte(*byte);
|
self.webee.write_byte(*byte);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.recv();
|
self.recv()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn void_send(&mut self, data: &[u8]) {
|
pub fn void_send(&mut self, data: &[u8]) {
|
||||||
@@ -78,14 +78,12 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_cmd(&mut self, cmd: SendCmd) -> Vec<u8, 128>{
|
pub fn send_cmd(&mut self, cmd: SendCmd) -> Vec<u8, 128> {
|
||||||
let frame = [0x5A, 0xAA, cmd as u8];
|
let frame = [0x5A, 0xAA, cmd as u8];
|
||||||
self.send(&frame)
|
self.send(&frame)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn query_parameter(&mut self) {
|
pub fn query_parameter(&mut self) {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn recv(&mut self) -> Vec<u8, 128> {
|
pub fn recv(&mut self) -> Vec<u8, 128> {
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
@@ -93,11 +91,16 @@ where
|
|||||||
buffer.push(self.webee.read_byte()).unwrap();
|
buffer.push(self.webee.read_byte()).unwrap();
|
||||||
delay_ms(10);
|
delay_ms(10);
|
||||||
|
|
||||||
|
// for i in 0..5 {
|
||||||
|
// buffer.push(self.webee.read_byte()).unwrap();
|
||||||
|
// }
|
||||||
|
|
||||||
while let Ok(byte) = self.webee.read() {
|
while let Ok(byte) = self.webee.read() {
|
||||||
buffer.push(byte).unwrap();
|
buffer.push(byte).unwrap();
|
||||||
|
delay_ms(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
return buffer;
|
buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn vec_to_string(vec: Vec<u8, 128>) -> &'static str {
|
// pub fn vec_to_string(vec: Vec<u8, 128>) -> &'static str {
|
||||||
|
|||||||
Reference in New Issue
Block a user