mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-28 21:00:59 +00:00
Stop using ok
in esp-wifi/esp-ieee802154 crates codebase. (#3853)
* is that it? * `expect` <-> `unwrap` * macro update fix macro * how did i manage to forget..?
This commit is contained in:
parent
818d30972d
commit
a2f2a224cd
@ -52,6 +52,19 @@ macro_rules! check_error {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! check_error_expect {
|
||||||
|
($block:block, $msg:literal) => {
|
||||||
|
match unsafe { $block } {
|
||||||
|
0 => (),
|
||||||
|
res => panic!(
|
||||||
|
"{}: {:?}",
|
||||||
|
$msg,
|
||||||
|
EspNowError::Error(Error::from_code(res as u32))
|
||||||
|
),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// Internal errors that can occur with ESP-NOW.
|
/// Internal errors that can occur with ESP-NOW.
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -621,9 +634,15 @@ impl<'d> EspNow<'d> {
|
|||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
};
|
};
|
||||||
|
|
||||||
check_error!({ esp_now_init() }).expect("esp-now-init failed");
|
check_error_expect!({ esp_now_init() }, "esp-now-init failed");
|
||||||
check_error!({ esp_now_register_recv_cb(Some(rcv_cb)) }).ok();
|
check_error_expect!(
|
||||||
check_error!({ esp_now_register_send_cb(Some(send_cb)) }).ok();
|
{ esp_now_register_recv_cb(Some(rcv_cb)) },
|
||||||
|
"receiving callback failed"
|
||||||
|
);
|
||||||
|
check_error_expect!(
|
||||||
|
{ esp_now_register_send_cb(Some(send_cb)) },
|
||||||
|
"sending callback failed"
|
||||||
|
);
|
||||||
|
|
||||||
esp_now
|
esp_now
|
||||||
.add_peer(PeerInfo {
|
.add_peer(PeerInfo {
|
||||||
@ -633,7 +652,7 @@ impl<'d> EspNow<'d> {
|
|||||||
channel: None,
|
channel: None,
|
||||||
encrypt: false,
|
encrypt: false,
|
||||||
})
|
})
|
||||||
.ok();
|
.expect("adding peer failed");
|
||||||
|
|
||||||
esp_now
|
esp_now
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user