Git Product home page Git Product logo

ublox-short-range-rs's Introduction

ublox-short-range

no_std driver crate for interfacing with the ublox short range family over serial

No Std Test Code coverage Crates.io Version Crates.io Downloads


A driver crate for AT-command based serial ublox short range modules, built on top of atat. The driver aims to be compatible with the ublox short range modules:

  • odin_w2xx
  • nina_w1xx
  • nina_b1xx
  • anna_b1xx
  • nina_b2xx
  • nina_b3xx

Documentation

Design diagram:
design diagram

Relevant docs:

Relevant repos:

Tests

The crate is covered by tests. These tests can be run by cargo test --tests, and are run by the CI on every push.

Features

  • device selection (must select one, and only one!):
    • odin_w2xx
    • nina_w1xx
    • nina_b1xx
    • anna_b1xx
    • nina_b2xx
    • nina_b3xx
  • socket-tcp: Enabled by default. Adds TCP socket capabilities, and implements [TcpStack] trait.
  • socket-udp: Enabled by default. Adds UDP socket capabilities, and implements [UdpStack] trait.
  • defmt-default: Disabled by default. Add log statements on trace (dev) or info (release) log levels to aid debugging.
  • defmt-trace: Disabled by default. Add log statements on trace log levels to aid debugging.
  • defmt-debug: Disabled by default. Add log statements on debug log levels to aid debugging.
  • defmt-info: Disabled by default. Add log statements on info log levels to aid debugging.
  • defmt-warn: Disabled by default. Add log statements on warn log levels to aid debugging.
  • defmt-error: Disabled by default. Add log statements on error log levels to aid debugging.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

ublox-short-range-rs's People

Contributors

keisrk avatar kennethknudsen97 avatar mathiaskoch avatar unizippro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

kaidokert geens

ublox-short-range-rs's Issues

Implementing DNS

Might not be that important.

Hostname to IP could be done by extracting the IP from the connect message when conneting directly to a URL
Blocking issue BlackbirdHQ/atat#69.

Release to crates.io

There are a few chores to be fixed before we can look into releasing a 0.1.0 version of this to crates.io

  • Readme
  • Github Actions
  • Repository description
  • Repository topics
  • Rid git dependencies
    • Bump embedded-nal to release version
  • Merge feature/extended-data into master

Not resetting the WiFi module before starting the driver causes stall

The driver will stall if the WiFi module is not reset before starting the driver.
Since the driver utilizes defmt as the logging framework it is not possible to get logs out without resetting the processor. Which in my application also resets the WiFi module. Meaning there is no logs for the issue.

Closing a peer in WaitingForConnection mode causes undefined behaviour

Closing a peer after creation before connection is established, is not registered correctly.
Since having two connections to the same socket address is not allowed the module throws an error if a reconnection is tried.

This should not be possible, as connect should be blocking, but #30 makes this possible. So it might be classified as a symptom of another bug.

161351 DEBUG [TCP] Opening socket
161352 DEBUG Adding socket! 0 Tcp
161352 DEBUG [TCP] Connect socket
161371 DEBUG Sending command with too long payload (80 bytes) to log! (Connect)
161391 DEBUG [Handle(0)] TCP state change: State::Created -> State::WaitingForConnect
161391 DEBUG [Handle(0)] Updating handle Handle(4)
161391 TRACE [TCP] Connecting socket: Handle(4) to url: tcp://34.253.44.78:8883/?ca=root_ca&cert=cert&privKey=priv_key
161392 DEBUG Network connected!
161392 INFO  MQTT connecting..
161394 ERROR [send] NetworkError::Write
161394 DEBUG Disconnecting!
161394 DEBUG [TCP] Closing socket: Handle(4)	(Close is not registered by module)
161394 DEBUG Removing socket! 4 Some(Tcp)
161412 DEBUG Sending command with too long payload (67 bytes) to log! (DNS)
161443 TRACE [EDM_URC] IPv4ConnectEvent! Channel_id: ChannelId(4)	(Peer now connected at modem)
161443 TRACE [EDM_MAP] Handle(4) tied to ChannelId(4)
161443 DEBUG [Handle(4)] TCP state change: State::WaitingForConnect -> State::Connected
161444 TRACE [URC] PeerConnected
161474 TRACE [URC] PingResponse
161474 DEBUG [TCP] Opening socket
161475 DEBUG Adding socket! 0 Tcp
161476 DEBUG [TCP] Connect socket
161494 DEBUG Sending command with too long payload (80 bytes) to log! (Connect to same IP again)
161514 TRACE Digest ReceivingResponse / b"\xaa\x00\x0b\x00E\r\nERROR\r\nU"
161514 ERROR Received error response InvalidResponse
161515 ERROR InvalidResponse: b"\xaa\x00L\x00DAT+UDCP=\"tcp://34.253.44.78:8883/?ca=root_ca&cert=cert&privKey=priv_key\"\r\nU"

Solution

Block untill state changes?
This could cause other issues, as it will cause a stall if the socket ends in this state by mistake.

arduino_nano33iot

This looks like a great crate. I would love to use it with the Arduino Nano 33 IoT. The arduino_nano33iot crate (version 0.7.0) uses embedded-hal ^0.2. Is there a way to make this crate compatible? E.g. with https://github.com/ryankurte/embedded-hal-compat

I can't seem to figure out how to do this. Help would be much appreciated. This is my list of dependencies:

arduino_nano33iot = { version = "0.7.0", features = ["usb"] }
atsamd-hal = { version = "0.14", features = ["usb", "unproven"] }
cortex-m = "0.7"
cortex-m-rtic = "1"
embedded-hal = "0.2"
panic-semihosting = "0.6"
systick-monotonic = "1"
usb-device = "0.2"
usbd-serial = "0.1"

Socket handle tied to peer handle causes issues

The libreary uses peer handles as socket handles, this causes major issues.
The module reuses peer handles imediatly after closing them, often only twice before incrementing for some reason.
Sockets are always closed by reciving a EDM_URC disconnect event. This causes all closes to be through ShutdownForWrite.
This means even if a socket is closed, it will excist in the set untill the timeout is reached(15 sek). If a new socket is created and connected, you will have 2 with the same handle. This causes a close to only change the first(old) one, leaving the second(new) one in the state Connected or WaitingForConnection in the socketset.
This also causes crossover during connection, as the state of the old socket is read, and connect is exited before an EDM_URC has arrived

An example is shown below:

110889 DEBUG [TCP] Opening socket
110890 DEBUG Adding socket! 0 Tcp
110890 DEBUG [Socket Set] Adding to: [(Handle(2), Tcp(State::ShutdownForWrite))]
110890 DEBUG [TCP] Connect socket
110909 DEBUG Sending command with too long payload (81 bytes) to log! #(Connection attempt)
110939 DEBUG [Handle(0)] TCP state change: State::Created -> State::WaitingForConnect
110939 DEBUG [Handle(0)] Updating handle Handle(2)
110939 TRACE [TCP] Connecting socket: Handle(2) to url: tcp://54.194.121.54:8883/?ca=root_ca&cert=cert&privKey=priv_key
110939 DEBUG Network connected!
110939 INFO  MQTT connecting..
110942 ERROR [send] NetworkError::Write
110942 DEBUG Disconnecting!
110942 DEBUG [TCP] Closing socket: Handle(2)
110942 DEBUG Removing socket! 2 Some(Tcp)
110959 DEBUG Sending command with too long payload (67 bytes) to log! #(DNS)
110980 TRACE [EDM_URC] IPv4ConnectEvent! Channel_id: ChannelId(2)
110980 TRACE [EDM_MAP] Handle(2) tied to ChannelId(2)
110980 DEBUG [Handle(2)] TCP state change: State::WaitingForConnect -> State::Connected
110980 TRACE [URC] PeerConnected
111021 TRACE [URC] PingResponse
111021 DEBUG [TCP] Opening socket
111022 DEBUG Adding socket! 0 Tcp
111022 DEBUG [Socket Set] Adding to: [(Handle(2), Tcp(State::Connected))]

As it requires one empty space in the set, it can never lock the set, as it will leave one open space.

This is recreatable by creating a connection to anywhere, closing it, and creating a connection to the same place again.

Solution

Decouble Peer handles and socket handles, in the same way peer handle and channel id is set up.

Alternative

Close any sockets with the same peer handle, as they do not match the modem state anymore. This is quite an easy fix.

Imlpementing ATAT types for EDM context

  • Serialization and deserialization for AT commands in EDM context
  • Serialization and deserialization for AT URCs in EDM context
  • Serialization and deserialization for EDM Events
  • Serialization and deserialization for EDM specific commands

Always initiating handles to 0 causes blocks

Only one unconnected socket can exist in the socket set at any one time. Since the socket set checks for dublicate socket handles.

Example:

161642 DEBUG [TCP] Opening socket
161643 DEBUG Adding socket! 0 Tcp
161643 DEBUG [Socket Set] Adding to: [(Handle(0), Tcp(State::Created)), (Handle(2), Tcp(State::Connected)), (Handle(4), Tcp(State::Connected))]
161644 ERROR [TCP] Opening socket Error: DuplicateSocket

Solution

Decouble Peer handles and socket handles, in the same way peer handle and channel id is set up.

Alternative

Create increasing "first" socket handles. This is quite an easy fix. Great care should be taken as to not overlap with the peer handles gotten back from the modem.
Another way would be eliminating the need for actually allocating anything upon creation of the socket, but then the "right of way" is moved onto the client connecting their socket first.

Connections Manager

It would be nice if we could add some kind of connections manager around the config slots in UWSC.

It should be able to do basics of:

Allow configuring network hostname

Currently the hostname of the device will be set to "odin-w2-xxxxxxxxxxxx" where "xxxxxxxxxxxx" is a device-specific number.

It should be possible to set a desired hostname during the client instantiation.

Relevant:
10.1 Network host name +UNHN

Upgrade dependencies

  • heapless v0.7.0

Changes from generic_array to const generics
Example:

impl<C, N, L> Dns for UbloxClient<C, N, L>
where
    C: atat::AtatClient,
    N: ArrayLength<Option<crate::sockets::SocketSetItem<L>>>,
    L: ArrayLength<u8>,
{

becomes:

impl<C, const N: usize, const L: usize> Dns for UbloxClient<C, N, L>
where
    C: atat::AtatClient
{
  • embedded-nal v0.6.0

Drops the requirement of interior mutability (RefCell & Cell)

no-std-net dependency can be dropped, as those are re-exported by embedded-nal, thus not requiring us to version match the two on upgrades.

  • atat v0.11.0

No big changes worth mentioning

  • embedded-time v0.11.0

No changes

4KB EDM data event size

EDM data events can be 4KB in size as per specification.
This means the line defining DATA_PACKAGE_SIZE is wrong.

With the current way of buffering data this means ATAT needs to be required to allocate multiples times this size.. For it to function properly.

Not configuring this size of buffer would will stall the driver.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.