Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More robust handling of responses from NINA-FW #72

Merged
merged 12 commits into from
Feb 17, 2023

Conversation

jhodapp
Copy link
Member

@jhodapp jhodapp commented Feb 14, 2023

Description

This PR aims to create a more robust handling of replies & responses back from the NINA-FW on the ESP32 such that we're ready to implement a full handling of a response for issuing a ProtocolInterface::send_data(), after an HTTP GET, for example.

GitHub Issue: Related to #61

Changes

  • Adds a max size check on creating a new NinaParam type and related unit tests
  • Adds an architecture-independent CPU-friendly spin_loop() in wait_for_esp_ready() and wait_for_esp_ack()
  • Ensures that we consume all 3 bytes when we encounter a ControlByte::Error from NINA-FW
  • Breaks NinaProtocolHandler::receive() out into logical child functions to improve readability and maintainability

Testing Strategy

  1. Run all example applications in cross/ on a target device
  2. Run cargo test and ensure all tests pass

Concerns

None

@jhodapp jhodapp added the enhancement Improves existing functionality or feature label Feb 14, 2023
@jhodapp jhodapp added this to the 0.4 Release milestone Feb 14, 2023
@jhodapp jhodapp self-assigned this Feb 14, 2023
@jhodapp jhodapp changed the title More robust wait response cmd More robust handling of responses from NINA-FW Feb 14, 2023
esp32-wroom-rp/src/gpio.rs Show resolved Hide resolved
esp32-wroom-rp/src/protocol.rs Outdated Show resolved Hide resolved
esp32-wroom-rp/src/protocol.rs Outdated Show resolved Hide resolved
esp32-wroom-rp/src/spi.rs Fixed Show fixed Hide fixed
pub(crate) trait NinaConcreteParam {
pub(crate) trait NinaConcreteParam
where
Self: core::marker::Sized,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this necessary?
For my own education.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise Self won't have a known size and you get this error:

error[E0277]: the size for values of type `Self` cannot be known at compilation time
   --> esp32-wroom-rp/src/protocol.rs:58:27
    |
58  |     fn new(data: &str) -> Result<Self, Error>;
    |                           ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
    |
note: required by a bound in `Result`
   --> /Users/jhodapp/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/result.rs:504:17
    |
504 | pub enum Result<T, E> {
    |                 ^ required by this bound in `Result`
help: consider further restricting `Self`
    |
58  |     fn new(data: &str) -> Result<Self, Error> where Self: Sized;
    |                                               +++++++++++++++++

esp32-wroom-rp/src/spi.rs Fixed Show fixed Hide fixed
@jhodapp jhodapp marked this pull request as ready for review February 17, 2023 03:58
Copy link
Collaborator

@calebbourg calebbourg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@jhodapp jhodapp merged commit 34aa554 into main Feb 17, 2023
@jhodapp jhodapp deleted the more_robust_wait_response_cmd branch February 17, 2023 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves existing functionality or feature
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants