Skip to content

Commit

Permalink
Fix lints and defmt feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Mossop committed Dec 6, 2024
1 parent c280303 commit 916ae45
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 14 deletions.
6 changes: 6 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "A no-std, no-alloc, opinionated MQTT client for IoT devices"
default = ["homeassistant"]
homeassistant = ["serde"]
serde = ["dep:serde", "dep:serde-json-core"]
defmt = ["dep:defmt"]
defmt = ["dep:defmt", "embassy-net/defmt"]
log = ["dep:log"]

[dependencies]
Expand Down
5 changes: 4 additions & 1 deletion src/homeassistant/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use serde::{ser::SerializeStruct, Deserialize, Serialize, Serializer};

use crate::{
homeassistant::{binary_sensor::BinarySensorState, ser::List, Component},
Error, Payload, Publishable, Topic,
Error,
Payload,
Publishable,
Topic,
};

#[derive(Serialize)]
Expand Down
17 changes: 14 additions & 3 deletions src/homeassistant/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,23 @@ use core::{future::Future, ops::Deref};
use mqttrs::QoS;
use serde::{
ser::{Error as _, SerializeStruct},
Serialize, Serializer,
Serialize,
Serializer,
};

use crate::{
device_id, device_type, homeassistant::ser::DiscoverySerializer, io::publish, Error,
McutieTask, MqttMessage, Payload, Publishable, Topic, TopicString, DATA_CHANNEL,
device_id,
device_type,
homeassistant::ser::DiscoverySerializer,
io::publish,
Error,
McutieTask,
MqttMessage,
Payload,
Publishable,
Topic,
TopicString,
DATA_CHANNEL,
};

pub mod binary_sensor;
Expand Down
3 changes: 2 additions & 1 deletion src/homeassistant/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use core::ops::Deref;

use serde::{
ser::{SerializeSeq, SerializeStruct},
Serialize, Serializer,
Serialize,
Serializer,
};

use crate::{
Expand Down
31 changes: 25 additions & 6 deletions src/io.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::ops::Deref;

use crate::fmt::Debug2Format;
pub(crate) use atomic16::assign_pid;
use embassy_futures::select::{select, select3, Either};
use embassy_net::{
dns::DnsQueryType,
Expand All @@ -16,16 +16,35 @@ use embassy_sync::{
use embassy_time::Timer;
use embedded_io_async::Write;
use mqttrs::{
decode_slice, Connect, ConnectReturnCode, LastWill, Packet, Pid, Protocol, Publish, QoS, QosPid,
decode_slice,
Connect,
ConnectReturnCode,
LastWill,
Packet,
Pid,
Protocol,
Publish,
QoS,
QosPid,
};

use crate::{
device_id, Buffer, ControlMessage, Error, MqttMessage, Payload, Publishable, Topic,
TopicString, CONFIRMATION_TIMEOUT, DATA_CHANNEL, DEFAULT_BACKOFF, RESET_BACKOFF,
device_id,
fmt::Debug2Format,
Buffer,
ControlMessage,
Error,
MqttMessage,
Payload,
Publishable,
Topic,
TopicString,
CONFIRMATION_TIMEOUT,
DATA_CHANNEL,
DEFAULT_BACKOFF,
RESET_BACKOFF,
};

pub(crate) use atomic16::assign_pid;

static WRITE_BUFFER: Mutex<CriticalSectionRawMutex, Buffer<4096>> = Mutex::new(Buffer::new());
static WRITE_PENDING: Signal<CriticalSectionRawMutex, ()> = Signal::new();
static WRITE_COMPLETE: Signal<CriticalSectionRawMutex, ()> = Signal::new();
Expand Down
8 changes: 6 additions & 2 deletions src/topic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ use mqttrs::{Packet, QoS, Subscribe, SubscribeReturnCodes, SubscribeTopic, Unsub
#[cfg(feature = "serde")]
use crate::publish::PublishJson;
use crate::{
device_id, device_type,
device_id,
device_type,
io::{assign_pid, send_packet, subscribe},
publish::{PublishBytes, PublishDisplay},
ControlMessage, Error, TopicString, CONFIRMATION_TIMEOUT,
ControlMessage,
Error,
TopicString,
CONFIRMATION_TIMEOUT,
};

/// An MQTT topic that is optionally prefixed with the device type and unique ID.
Expand Down

0 comments on commit 916ae45

Please sign in to comment.