Skip to content

Commit 369f07b

Browse files
committed
Updating dependencies and removing nightlyt feature
1 parent 884acff commit 369f07b

8 files changed

+66
-30
lines changed

Cargo.toml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "embedded-update"
3-
version = "0.12.0"
3+
version = "0.12.1"
44
edition = "2021"
55
resolver = "2"
66
description = "Firmware updates for embedded devices supporting multiple update services"
@@ -16,15 +16,15 @@ keywords = ["embedded", "async", "dfu", "no_std", "ota"]
1616
exclude = [".github"]
1717

1818
[dependencies]
19-
heapless = "0.7"
19+
heapless = "0.8"
2020
serde = { version = "1", features = ["derive"], default-features = false }
2121
postcard = { version = "1.0", default-features = false, optional = true }
2222
embedded-io-async = { version = "0.6", optional = true }
2323
embedded-io = "0.6"
2424

2525
defmt = { version = "0.3", optional = true }
2626
log = { version = "0.4", optional = true }
27-
embedded-hal-async = {version = "1.0.0-rc.1", optional = true }
27+
embedded-hal-async = { version = "1.0", optional = true }
2828
futures = { version = "0.3", default-features = false, optional = true }
2929
rand_core = { version = "0.6", default-features = false, optional = true }
3030
serde_cbor = { version = "0.11", default-features = false, optional = true }
@@ -38,7 +38,6 @@ log = "0.4"
3838
rand = "0.8"
3939

4040
[features]
41-
default = ["nightly"]
42-
nightly = ["embedded-hal-async", "futures", "postcard", "embedded-io-async"]
41+
default = ["embedded-hal-async", "futures", "postcard", "embedded-io-async"]
4342
defmt = ["dep:defmt"]
4443
std = []

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,4 @@ Update service and device implementations can be added to `embedded-update` when
2727

2828
# Minimum supported Rust version (MSRV)
2929

30-
`embedded-update` requires a feature from `nightly` to compile when using the `nightly` flag.
31-
3230
* async_fn_in_traits

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Before upgrading check that everything is available on all tier1 targets here:
22
# https://rust-lang.github.io/rustup-components-history
33
[toolchain]
4-
channel = "nightly-2023-10-02"
4+
channel = "1.82"
55
components = ["clippy"]

src/fmt.rs

+46-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#![macro_use]
2-
#![allow(unused_macros)]
2+
#![allow(unused)]
3+
4+
use core::fmt::{Debug, Display, LowerHex};
35

46
#[cfg(all(feature = "defmt", feature = "log"))]
57
compile_error!("You may not enable both `defmt` and `log` features.");
68

9+
#[collapse_debuginfo(yes)]
710
macro_rules! assert {
811
($($x:tt)*) => {
912
{
@@ -15,6 +18,7 @@ macro_rules! assert {
1518
};
1619
}
1720

21+
#[collapse_debuginfo(yes)]
1822
macro_rules! assert_eq {
1923
($($x:tt)*) => {
2024
{
@@ -26,6 +30,7 @@ macro_rules! assert_eq {
2630
};
2731
}
2832

33+
#[collapse_debuginfo(yes)]
2934
macro_rules! assert_ne {
3035
($($x:tt)*) => {
3136
{
@@ -37,6 +42,7 @@ macro_rules! assert_ne {
3742
};
3843
}
3944

45+
#[collapse_debuginfo(yes)]
4046
macro_rules! debug_assert {
4147
($($x:tt)*) => {
4248
{
@@ -48,6 +54,7 @@ macro_rules! debug_assert {
4854
};
4955
}
5056

57+
#[collapse_debuginfo(yes)]
5158
macro_rules! debug_assert_eq {
5259
($($x:tt)*) => {
5360
{
@@ -59,6 +66,7 @@ macro_rules! debug_assert_eq {
5966
};
6067
}
6168

69+
#[collapse_debuginfo(yes)]
6270
macro_rules! debug_assert_ne {
6371
($($x:tt)*) => {
6472
{
@@ -70,6 +78,7 @@ macro_rules! debug_assert_ne {
7078
};
7179
}
7280

81+
#[collapse_debuginfo(yes)]
7382
macro_rules! todo {
7483
($($x:tt)*) => {
7584
{
@@ -81,6 +90,7 @@ macro_rules! todo {
8190
};
8291
}
8392

93+
#[collapse_debuginfo(yes)]
8494
macro_rules! unreachable {
8595
($($x:tt)*) => {
8696
{
@@ -92,6 +102,7 @@ macro_rules! unreachable {
92102
};
93103
}
94104

105+
#[collapse_debuginfo(yes)]
95106
macro_rules! panic {
96107
($($x:tt)*) => {
97108
{
@@ -103,6 +114,7 @@ macro_rules! panic {
103114
};
104115
}
105116

117+
#[collapse_debuginfo(yes)]
106118
macro_rules! trace {
107119
($s:literal $(, $x:expr)* $(,)?) => {
108120
{
@@ -116,6 +128,7 @@ macro_rules! trace {
116128
};
117129
}
118130

131+
#[collapse_debuginfo(yes)]
119132
macro_rules! debug {
120133
($s:literal $(, $x:expr)* $(,)?) => {
121134
{
@@ -129,6 +142,7 @@ macro_rules! debug {
129142
};
130143
}
131144

145+
#[collapse_debuginfo(yes)]
132146
macro_rules! info {
133147
($s:literal $(, $x:expr)* $(,)?) => {
134148
{
@@ -142,6 +156,7 @@ macro_rules! info {
142156
};
143157
}
144158

159+
#[collapse_debuginfo(yes)]
145160
macro_rules! warn {
146161
($s:literal $(, $x:expr)* $(,)?) => {
147162
{
@@ -155,6 +170,7 @@ macro_rules! warn {
155170
};
156171
}
157172

173+
#[collapse_debuginfo(yes)]
158174
macro_rules! error {
159175
($s:literal $(, $x:expr)* $(,)?) => {
160176
{
@@ -169,13 +185,15 @@ macro_rules! error {
169185
}
170186

171187
#[cfg(feature = "defmt")]
188+
#[collapse_debuginfo(yes)]
172189
macro_rules! unwrap {
173190
($($x:tt)*) => {
174191
::defmt::unwrap!($($x)*)
175192
};
176193
}
177194

178195
#[cfg(not(feature = "defmt"))]
196+
#[collapse_debuginfo(yes)]
179197
macro_rules! unwrap {
180198
($arg:expr) => {
181199
match $crate::fmt::Try::into_result($arg) {
@@ -195,9 +213,6 @@ macro_rules! unwrap {
195213
}
196214
}
197215

198-
#[cfg(feature = "defmt-timestamp-uptime")]
199-
defmt::timestamp! {"{=u64:us}", crate::time::Instant::now().as_micros() }
200-
201216
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
202217
pub struct NoneError;
203218

@@ -226,3 +241,30 @@ impl<T, E> Try for Result<T, E> {
226241
self
227242
}
228243
}
244+
245+
pub(crate) struct Bytes<'a>(pub &'a [u8]);
246+
247+
impl<'a> Debug for Bytes<'a> {
248+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
249+
write!(f, "{:#02x?}", self.0)
250+
}
251+
}
252+
253+
impl<'a> Display for Bytes<'a> {
254+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
255+
write!(f, "{:#02x?}", self.0)
256+
}
257+
}
258+
259+
impl<'a> LowerHex for Bytes<'a> {
260+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
261+
write!(f, "{:#02x?}", self.0)
262+
}
263+
}
264+
265+
#[cfg(feature = "defmt")]
266+
impl<'a> defmt::Format for Bytes<'a> {
267+
fn format(&self, fmt: defmt::Formatter) {
268+
defmt::write!(fmt, "{:02x}", self.0)
269+
}
270+
}

src/lib.rs

-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![cfg_attr(not(test), no_std)]
2-
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait))]
32
#![doc = include_str!("../README.md")]
43
#![deny(missing_docs)]
54

@@ -8,20 +7,12 @@ mod fmt;
87
mod protocol;
98
pub use protocol::*;
109

11-
#[cfg(feature = "nightly")]
1210
pub mod device;
1311

14-
#[cfg(feature = "nightly")]
1512
pub mod service;
1613

17-
#[cfg(feature = "nightly")]
1814
mod traits;
19-
20-
#[cfg(feature = "nightly")]
2115
pub use traits::*;
2216

23-
#[cfg(feature = "nightly")]
2417
mod updater;
25-
26-
#[cfg(feature = "nightly")]
2718
pub use updater::*;

src/traits.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(async_fn_in_trait)]
2+
13
use {
24
crate::protocol::{Command, Status},
35
core::fmt::Debug,

src/updater.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use {
33
protocol::{Command, Status},
44
traits::{FirmwareDevice, FirmwareVersion, UpdateService},
55
},
6-
embedded_hal_async::delay::DelayUs,
6+
embedded_hal_async::delay::DelayNs,
77
futures::{
88
future::{select, Either},
99
pin_mut,
@@ -85,7 +85,7 @@ where
8585
}
8686
}
8787

88-
async fn check<F: FirmwareDevice, D: DelayUs>(
88+
async fn check<F: FirmwareDevice, D: DelayNs>(
8989
&mut self,
9090
device: &mut F,
9191
delay: &mut D,
@@ -208,7 +208,7 @@ where
208208
/// 1) The device is in sync, in which case `DeviceStatus::Synced` is returned.
209209
/// 2) The device is updated, in which case `DeviceStatus::Updated` is returned. It is the responsibility
210210
/// of called to reset the device in order to run the new firmware.
211-
pub async fn run<F: FirmwareDevice, D: DelayUs>(
211+
pub async fn run<F: FirmwareDevice, D: DelayNs>(
212212
&mut self,
213213
device: &mut F,
214214
delay: &mut D,
@@ -228,7 +228,11 @@ mod tests {
228228

229229
pub struct TokioDelay;
230230

231-
impl embedded_hal_async::delay::DelayUs for TokioDelay {
231+
impl embedded_hal_async::delay::DelayNs for TokioDelay {
232+
async fn delay_ns(&mut self, i: u32) {
233+
tokio::time::sleep(tokio::time::Duration::from_nanos(i as u64)).await;
234+
}
235+
232236
async fn delay_us(&mut self, i: u32) {
233237
tokio::time::sleep(tokio::time::Duration::from_micros(i as u64)).await;
234238
}

tests/serial.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
#![cfg_attr(feature = "nightly", feature(type_alias_impl_trait))]
2-
#![cfg_attr(feature = "nightly", feature(async_fn_in_trait))]
3-
#![cfg_attr(feature = "nightly", allow(incomplete_features))]
4-
51
use {
62
embedded_update::{device, service, FirmwareUpdater},
73
tokio::sync::mpsc,
@@ -89,7 +85,11 @@ impl embedded_io_async::Write for Link {
8985

9086
pub struct Timer;
9187

92-
impl embedded_hal_async::delay::DelayUs for Timer {
88+
impl embedded_hal_async::delay::DelayNs for Timer {
89+
async fn delay_ns(&mut self, i: u32) {
90+
tokio::time::sleep(tokio::time::Duration::from_nanos(i as u64)).await;
91+
}
92+
9393
async fn delay_us(&mut self, i: u32) {
9494
tokio::time::sleep(tokio::time::Duration::from_micros(i as u64)).await;
9595
}

0 commit comments

Comments
 (0)