Skip to content

Commit

Permalink
feature(*): Full async implementation (#82)
Browse files Browse the repository at this point in the history
* initial commit - tests not working

* Initial work on async client

* Working async network management & TCP socket stack

* Attempt to rid channel

* Working dns + tcp at 11/6kbps

* Add performance testing example

* Comment out UartExt trait

* Update to latest embassy and embedded-io 0.5

* Update dependencies and fix tests

* Add TlsSocket

* Fix clippy warnings

* Fix TlsSocket and module restart with EDM

* Reduce stack usage from holding large resources across await points

* Correctly handle closing a dropped socket in FinWait1 state

* Add support for PPP mode (#81)

* Simplify initialization of both ppp mode and ublox mode, by providing batteries included new functions that sets up ATAT and all related resources

* Refactor async completely for a more intuitive API. URCs over PPP UDP socket is still not working properly

* Bump embassy-sync to 0.6

* Fix internal-network-stack compiling

* Rework runner, add Proxy client and add working Control handle

* Working control handle for connect and disconnect, with ppp udp bridge

* Add a large number of convenience functions to Control and cleanup runner patterns

* Fix defmt feature gating

---------

Co-authored-by: unizippro <[email protected]>
  • Loading branch information
MathiasKoch and unizippro authored Jul 18, 2024
1 parent 2d83219 commit 005bcd8
Show file tree
Hide file tree
Showing 90 changed files with 6,078 additions and 3,293 deletions.
87 changes: 56 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,81 @@
name: CI

on:
push:
branches:
- master
pull_request:

name: CI

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash

jobs:
test:
name: Build & Test
rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3
- uses: dsherret/rust-toolchain-file@v1
- name: Build
uses: actions-rs/cargo@v1
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
command: build
args: --all --target thumbv7em-none-eabihf
profile: minimal
toolchain: nightly
override: true
components: rustfmt

- name: Test
- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: test
args: --lib
env:
DEFMT_LOG: off

rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3
- uses: dsherret/rust-toolchain-file@v1
- name: Rustfmt
run: cargo fmt -- --check
command: fmt
args: --all -- --check --verbose

clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3
- uses: dsherret/rust-toolchain-file@v1
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy

- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: -- ${{ env.CLIPPY_PARAMS }}
args: --features odin-w2xx,ppp

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: thumbv7m-none-eabi
override: true

- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --all --target thumbv7m-none-eabi --features odin-w2xx,ppp

- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --lib --features odin-w2xx,ppp
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
*.fifo
target/
*.o
.vscode
Cargo.lock
11 changes: 11 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}
18 changes: 18 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"editor.formatOnSave": true,
"[toml]": {
"editor.formatOnSave": false
},
"rust-analyzer.cargo.target": "thumbv6m-none-eabi",
"rust-analyzer.check.allTargets": false,
"rust-analyzer.linkedProjects": [],
"rust-analyzer.cargo.features": [
"odin-w2xx",
// "internal-network-stack"
"ppp"
],
"rust-analyzer.server.extraEnv": {
"WIFI_NETWORK": "foo",
"WIFI_PASSWORD": "foo",
}
}
87 changes: 84 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,88 @@
[package]
name = "ublox-short-range-rs"
version = "0.1.1"
authors = ["Mads Andresen <[email protected]>"]
description = "Driver crate for u-blox short range devices, implementation follows 'UBX-14044127 - R40'"
readme = "../README.md"
keywords = ["ublox", "wifi", "shortrange", "bluetooth"]
categories = ["embedded", "no-std"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/BlackbirdHQ/ublox-short-range-rs"
edition = "2021"

[lib]
name = "ublox_short_range"
doctest = false

[dependencies]
atat = { version = "0.23", features = ["derive", "bytes"] }

heapless = { version = "^0.8", features = ["serde"] }
no-std-net = { version = "0.6", features = ["serde"] }
serde = { version = "^1", default-features = false, features = ["derive"] }
# ublox-sockets = { version = "0.5", optional = true }
ublox-sockets = { git = "https://github.com/BlackbirdHQ/ublox-sockets", rev = "9f7fe54", optional = true }
portable-atomic = "1.6"

log = { version = "^0.4", default-features = false, optional = true }
defmt = { version = "^0.3", optional = true }

embedded-hal = "1.0"
embassy-time = "0.3"
embassy-sync = "0.6"
embassy-futures = "0.1"

embedded-nal-async = { version = "0.7" }
futures-util = { version = "0.3.29", default-features = false }

embedded-io-async = "0.6"

embassy-net-ppp = { version = "0.1", optional = true }
embassy-net = { version = "0.4", features = [
"proto-ipv4",
"medium-ip",
], optional = true }


[features]
default = ["socket-tcp", "socket-udp"]

internal-network-stack = ["dep:ublox-sockets", "edm"]
edm = ["ublox-sockets?/edm"]

ipv6 = ["embassy-net?/proto-ipv6"]

# PPP mode requires UDP sockets enabled, to be able to do AT commands over UDP port 23
ppp = ["dep:embassy-net-ppp", "dep:embassy-net", "socket-udp"]

socket-tcp = ["ublox-sockets?/socket-tcp", "embassy-net?/tcp"]
socket-udp = ["ublox-sockets?/socket-udp", "embassy-net?/udp"]

defmt = [
"dep:defmt",
"heapless/defmt-03",
"atat/defmt",
"ublox-sockets?/defmt",
"embassy-net-ppp?/defmt",
"embassy-net?/defmt",
]
log = ["dep:log", "ublox-sockets?/log", "atat/log"]

# Supported Ublox modules
odin-w2xx = []
nina-w1xx = []
nina-b1xx = []
anna-b1xx = []
nina-b2xx = []
nina-b3xx = []

[workspace]
resolver = "2"
members = [ "ublox-short-range" ]
members = []
default-members = ["."]
exclude = ["examples"]


[patch.crates-io]
atat = { git = "https://github.com/BlackbirdHQ/atat", rev = "c5caaf7" }
no-std-net = { git = "https://github.com/rushmorem/no-std-net", branch = "issue-15" }
atat = { git = "https://github.com/BlackbirdHQ/atat", rev = "a466836" }
# atat = { path = "../atat/atat" }
1 change: 0 additions & 1 deletion Design_diagram.drawio

This file was deleted.

Binary file removed Design_diagram.png
Binary file not shown.
38 changes: 17 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,27 @@

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

- odin-w2xx
- nina-w1xx
- nina-b1xx
- anna-b1xx
- nina-b2xx
- nina-b3xx

[atat]: https://crates.io/crates/atat

## Documentation
Design diagram:
![design diagram](./Design_diagram.png "Design diagram")


Relevant docs:

- https://www.u-blox.com/en/docs/UBX-14044127
- https://www.u-blox.com/en/docs/UBX-14044126
- https://www.u-blox.com/en/docs/UBX-16024251

Relevant repos:
- https://github.com/u-blox/u-connectXpress-host-library
- https://github.com/particle-iot/device-os
- https://github.com/u-blox/ubxlib

- https://github.com/u-blox/ubxlib

## Tests

Expand All @@ -51,12 +48,12 @@ The samples can be built using `cargo build -p linux_example --target x86_64-unk
## Features

- device selection (must select one, and only one!):
- `odin_w2xx`
- `nina_w1xx`
- `nina_b1xx`
- `anna_b1xx`
- `nina_b2xx`
- `nina_b3xx`
- `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.
Expand All @@ -66,13 +63,12 @@ The samples can be built using `cargo build -p linux_example --target x86_64-unk
- `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

- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.
Expand All @@ -83,8 +79,8 @@ 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.


<!-- Badges -->

[no-std-badge]: https://img.shields.io/badge/no__std-yes-blue
[test]: https://github.com/BlackbirdHQ/ublox-short-range-rs/workflows/Test/badge.svg
[codecov-badge]: https://codecov.io/gh/BlackbirdHQ/ublox-short-range-rs/branch/master/graph/badge.svg
Expand Down
Loading

0 comments on commit 005bcd8

Please sign in to comment.