Skip to content

Commit

Permalink
fix NinaParam type for send_data and avail_data_tcp
Browse files Browse the repository at this point in the history
  • Loading branch information
calebbourg committed Feb 23, 2023
1 parent cc4c417 commit 55a4fac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
8 changes: 6 additions & 2 deletions cross/receive_data_tcp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,12 @@ fn main() -> ! {
defmt::info!("Receiving Response");

match tcp_client.receive_data() {
Ok(response) => { defmt::info!("Response: {:?}", response); }
Err(e) => { defmt::info!("Error receiving data: {:?}", e); }
Ok(response) => {
defmt::info!("Response: {:?}", response);
}
Err(e) => {
defmt::info!("Error receiving data: {:?}", e);
}
}
}
Err(e) => {
Expand Down
18 changes: 13 additions & 5 deletions esp32-wroom-rp/src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ where

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

self.execute(&operation)?;
Expand All @@ -223,8 +223,8 @@ where
}

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

self.execute(&operation)?;

Expand All @@ -246,8 +246,16 @@ where
}

fn receive_data(&mut self, socket: Socket) -> Result<NinaResponseBuffer, Error> {
self.avail_data_tcp(socket);
let mut response_param_buffer: NinaResponseBuffer = [0; MAX_NINA_RESPONSE_LENGTH];
let mut avail_data: usize = 0;
loop {
avail_data = self.avail_data_tcp(socket)?;
if avail_data > 0 {
break;
}
}

defmt::debug!("available data: {:?}", avail_data);
let response_param_buffer: NinaResponseBuffer = [0; MAX_NINA_RESPONSE_LENGTH];

Ok(response_param_buffer)
}
Expand Down

0 comments on commit 55a4fac

Please sign in to comment.