Skip to content

Commit 55a4fac

Browse files
committed
fix NinaParam type for send_data and avail_data_tcp
1 parent cc4c417 commit 55a4fac

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

cross/receive_data_tcp/src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,12 @@ fn main() -> ! {
180180
defmt::info!("Receiving Response");
181181

182182
match tcp_client.receive_data() {
183-
Ok(response) => { defmt::info!("Response: {:?}", response); }
184-
Err(e) => { defmt::info!("Error receiving data: {:?}", e); }
183+
Ok(response) => {
184+
defmt::info!("Response: {:?}", response);
185+
}
186+
Err(e) => {
187+
defmt::info!("Error receiving data: {:?}", e);
188+
}
185189
}
186190
}
187191
Err(e) => {

esp32-wroom-rp/src/spi.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ where
212212

213213
fn send_data(&mut self, data: &str, socket: Socket) -> Result<[u8; 1], Error> {
214214
let operation = Operation::new(NinaCommand::SendDataTcp)
215-
.param(NinaLargeArrayParam::from_bytes(&[socket])?)
215+
.param(NinaByteParam::from_bytes(&[socket])?)
216216
.param(NinaLargeArrayParam::new(data)?);
217217

218218
self.execute(&operation)?;
@@ -223,8 +223,8 @@ where
223223
}
224224

225225
fn avail_data_tcp(&mut self, socket: Socket) -> Result<usize, Error> {
226-
let operation = Operation::new(NinaCommand::AvailDataTcp)
227-
.param(NinaLargeArrayParam::from_bytes(&[socket])?);
226+
let operation =
227+
Operation::new(NinaCommand::AvailDataTcp).param(NinaByteParam::from_bytes(&[socket])?);
228228

229229
self.execute(&operation)?;
230230

@@ -246,8 +246,16 @@ where
246246
}
247247

248248
fn receive_data(&mut self, socket: Socket) -> Result<NinaResponseBuffer, Error> {
249-
self.avail_data_tcp(socket);
250-
let mut response_param_buffer: NinaResponseBuffer = [0; MAX_NINA_RESPONSE_LENGTH];
249+
let mut avail_data: usize = 0;
250+
loop {
251+
avail_data = self.avail_data_tcp(socket)?;
252+
if avail_data > 0 {
253+
break;
254+
}
255+
}
256+
257+
defmt::debug!("available data: {:?}", avail_data);
258+
let response_param_buffer: NinaResponseBuffer = [0; MAX_NINA_RESPONSE_LENGTH];
251259

252260
Ok(response_param_buffer)
253261
}

0 commit comments

Comments
 (0)