Skip to content

Commit 83905ac

Browse files
committed
remove clippy warnings
1 parent c96867d commit 83905ac

File tree

6 files changed

+31
-17
lines changed

6 files changed

+31
-17
lines changed

cross/secrets/secrets.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
// all example applications
44
//
55

6-
const SSID: &str = "Zion";
7-
const PASSPHRASE: &str = "Diesel12103465";
6+
const SSID: &str = "";
7+
const PASSPHRASE: &str = "";

esp32-wroom-rp/src/network.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,43 @@ pub(crate) type Socket = u8;
1616
#[repr(u8)]
1717
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
1818
pub enum TransportMode {
19+
/// TCP mode
1920
Tcp = 0,
21+
/// UDP mode
2022
Udp = 1,
23+
/// TLS mode
2124
Tls = 2,
25+
/// UDP multicast mode
2226
UdpMulticast = 3,
27+
/// TLS BearSSL mode
2328
TlsBearSsl = 4,
2429
}
2530

2631
/// Defines all possible TCP connection states for a client or server instance.
2732
#[repr(u8)]
2833
#[derive(PartialEq, PartialOrd, Debug)]
2934
pub enum ConnectionState {
35+
/// Closed
3036
Closed = 0,
37+
/// Listening
3138
Listening = 1,
39+
/// SynSent
3240
SynSent = 2,
41+
/// SynReceived
3342
SynReceived = 3,
43+
/// Established
3444
Established = 4,
45+
/// FinWait1
3546
FinWait1 = 5,
47+
/// Finwait2
3648
FinWait2 = 6,
49+
/// CloseWait
3750
CloseWait = 7,
51+
/// Closing
3852
Closing = 8,
53+
/// LastAck
3954
LastAck = 9,
55+
/// TimeWait
4056
TimeWait = 10,
4157
}
4258

esp32-wroom-rp/src/protocol.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl NinaParam for NinaAbstractParam {
128128
}
129129

130130
fn length(&self) -> u16 {
131-
self.length as u16
131+
self.length
132132
}
133133

134134
fn length_size(&self) -> u8 {
@@ -220,7 +220,7 @@ impl NinaConcreteParam for NinaByteParam {
220220
}
221221

222222
fn length_as_bytes(&self) -> Self::LengthAsBytes {
223-
[self.length as u8]
223+
[self.length]
224224
}
225225
}
226226

@@ -253,7 +253,7 @@ impl NinaConcreteParam for NinaWordParam {
253253
}
254254

255255
fn length_as_bytes(&self) -> Self::LengthAsBytes {
256-
[self.length as u8]
256+
[self.length]
257257
}
258258
}
259259

@@ -286,7 +286,7 @@ impl NinaConcreteParam for NinaSmallArrayParam {
286286
}
287287

288288
fn length_as_bytes(&self) -> Self::LengthAsBytes {
289-
[self.length as u8]
289+
[self.length]
290290
}
291291
}
292292

esp32-wroom-rp/src/spi.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ where
245245
operation.params.iter().for_each(|param| {
246246
self.send_param(param).ok();
247247

248-
total_params_length += param.length() as u16;
248+
total_params_length += param.length();
249249
total_params_length_size += param.length_size() as u16;
250250
});
251251

@@ -341,7 +341,7 @@ where
341341
fn get_byte(&mut self) -> Result<u8, Infallible> {
342342
let word_out = &mut [ControlByte::Dummy as u8];
343343
let word = self.bus.borrow_mut().transfer(word_out).ok().unwrap();
344-
Ok(word[0] as u8)
344+
Ok(word[0])
345345
}
346346

347347
fn wait_for_byte(&mut self, wait_byte: u8) -> Result<bool, Error> {
@@ -369,18 +369,16 @@ where
369369

370370
fn send_param<P: NinaParam>(&mut self, param: &P) -> Result<(), Infallible> {
371371
self.send_param_length(param)?;
372-
let data_length = param.length() as usize;
373-
let bytes = param.data();
374-
for i in 0..data_length {
375-
self.bus.borrow_mut().transfer(&mut [bytes[i]]).ok();
372+
for byte in param.data().iter() {
373+
self.bus.borrow_mut().transfer(&mut [*byte]).ok();
376374
}
377375
Ok(())
378376
}
379377

380378
fn send_param_length<P: NinaParam>(&mut self, param: &P) -> Result<(), Infallible> {
381379
let bytes = param.length_as_bytes();
382-
for i in 0..param.length_size() as usize {
383-
self.bus.borrow_mut().transfer(&mut [bytes[i]]).ok();
380+
for byte in bytes.iter().take(param.length_size() as usize) {
381+
self.bus.borrow_mut().transfer(&mut [*byte]).ok();
384382
}
385383
Ok(())
386384
}

esp32-wroom-rp/src/tcp_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ use embedded_hal::blocking::spi::Transfer;
1212

1313
use heapless::String;
1414

15-
// TODO: find a good max length
16-
const MAX_DATA_LENGTH: usize = 512;
1715
const MAX_HOSTNAME_LENGTH: usize = 255;
1816

1917
/// Connect trait that allows for a `TcpClient` instance to connect to a remote
@@ -131,11 +129,13 @@ where
131129
}
132130

133131
// TODO: Make this non-public
132+
/// Requests a Socket
134133
pub fn get_socket(&mut self) -> Result<Socket, Error> {
135134
self.protocol_handler.get_socket()
136135
}
137136

138137
// TODO: Make this non-public
138+
/// Returns `Socket` reference set by calling `get_socket()`
139139
pub fn socket(&self) -> Socket {
140140
self.socket.unwrap()
141141
}

esp32-wroom-rp/src/wifi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub struct Wifi<B, C> {
9999
pub(crate) protocol_handler: RefCell<NinaProtocolHandler<B, C>>,
100100
}
101101

102-
impl<'a, S, C> Wifi<S, C>
102+
impl<S, C> Wifi<S, C>
103103
where
104104
S: Transfer<u8>,
105105
C: EspControlInterface,

0 commit comments

Comments
 (0)