Skip to content

Commit 005bcd8

Browse files
feature(*): Full async implementation (#82)
* 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 <mads@astrupa.dk>
1 parent 2d83219 commit 005bcd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+6078
-3293
lines changed

.github/workflows/ci.yml

+56-31
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,81 @@
1+
name: CI
2+
13
on:
24
push:
35
branches:
46
- master
57
pull_request:
68

7-
name: CI
8-
9-
concurrency:
10-
group: ${{ github.workflow }}-${{ github.ref }}
11-
cancel-in-progress: true
9+
defaults:
10+
run:
11+
shell: bash
1212

1313
jobs:
14-
test:
15-
name: Build & Test
14+
rustfmt:
15+
name: rustfmt
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout source code
19-
uses: actions/checkout@v3
20-
- uses: dsherret/rust-toolchain-file@v1
21-
- name: Build
22-
uses: actions-rs/cargo@v1
19+
uses: actions/checkout@v2
20+
21+
- name: Install Rust
22+
uses: actions-rs/toolchain@v1
2323
with:
24-
command: build
25-
args: --all --target thumbv7em-none-eabihf
24+
profile: minimal
25+
toolchain: nightly
26+
override: true
27+
components: rustfmt
2628

27-
- name: Test
29+
- name: Run rustfmt
2830
uses: actions-rs/cargo@v1
2931
with:
30-
command: test
31-
args: --lib
32-
env:
33-
DEFMT_LOG: off
34-
35-
rustfmt:
36-
name: rustfmt
37-
runs-on: ubuntu-latest
38-
steps:
39-
- name: Checkout source code
40-
uses: actions/checkout@v3
41-
- uses: dsherret/rust-toolchain-file@v1
42-
- name: Rustfmt
43-
run: cargo fmt -- --check
32+
command: fmt
33+
args: --all -- --check --verbose
4434

4535
clippy:
4636
name: clippy
4737
runs-on: ubuntu-latest
4838
steps:
4939
- name: Checkout source code
50-
uses: actions/checkout@v3
51-
- uses: dsherret/rust-toolchain-file@v1
40+
uses: actions/checkout@v2
41+
42+
- name: Install Rust
43+
uses: actions-rs/toolchain@v1
44+
with:
45+
profile: minimal
46+
toolchain: stable
47+
override: true
48+
components: clippy
49+
5250
- name: Run clippy
5351
uses: actions-rs/clippy-check@v1
5452
with:
5553
token: ${{ secrets.GITHUB_TOKEN }}
56-
args: -- ${{ env.CLIPPY_PARAMS }}
54+
args: --features odin-w2xx,ppp
55+
56+
test:
57+
name: Test
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout source code
61+
uses: actions/checkout@v2
62+
63+
- name: Install Rust
64+
uses: actions-rs/toolchain@v1
65+
with:
66+
profile: minimal
67+
toolchain: stable
68+
target: thumbv7m-none-eabi
69+
override: true
70+
71+
- name: Build
72+
uses: actions-rs/cargo@v1
73+
with:
74+
command: build
75+
args: --all --target thumbv7m-none-eabi --features odin-w2xx,ppp
76+
77+
- name: Test
78+
uses: actions-rs/cargo@v1
79+
with:
80+
command: test
81+
args: --lib --features odin-w2xx,ppp

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
*.fifo
55
target/
66
*.o
7-
.vscode
87
Cargo.lock

.vscode/extensions.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3+
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4+
// List of extensions which should be recommended for users of this workspace.
5+
"recommendations": [
6+
"rust-lang.rust-analyzer",
7+
"tamasfe.even-better-toml",
8+
],
9+
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10+
"unwantedRecommendations": []
11+
}

.vscode/settings.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"[toml]": {
4+
"editor.formatOnSave": false
5+
},
6+
"rust-analyzer.cargo.target": "thumbv6m-none-eabi",
7+
"rust-analyzer.check.allTargets": false,
8+
"rust-analyzer.linkedProjects": [],
9+
"rust-analyzer.cargo.features": [
10+
"odin-w2xx",
11+
// "internal-network-stack"
12+
"ppp"
13+
],
14+
"rust-analyzer.server.extraEnv": {
15+
"WIFI_NETWORK": "foo",
16+
"WIFI_PASSWORD": "foo",
17+
}
18+
}

Cargo.toml

+84-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,88 @@
1+
[package]
2+
name = "ublox-short-range-rs"
3+
version = "0.1.1"
4+
authors = ["Mads Andresen <ma@blackbird.online>"]
5+
description = "Driver crate for u-blox short range devices, implementation follows 'UBX-14044127 - R40'"
6+
readme = "../README.md"
7+
keywords = ["ublox", "wifi", "shortrange", "bluetooth"]
8+
categories = ["embedded", "no-std"]
9+
license = "MIT OR Apache-2.0"
10+
repository = "https://github.com/BlackbirdHQ/ublox-short-range-rs"
11+
edition = "2021"
12+
13+
[lib]
14+
name = "ublox_short_range"
15+
doctest = false
16+
17+
[dependencies]
18+
atat = { version = "0.23", features = ["derive", "bytes"] }
19+
20+
heapless = { version = "^0.8", features = ["serde"] }
21+
no-std-net = { version = "0.6", features = ["serde"] }
22+
serde = { version = "^1", default-features = false, features = ["derive"] }
23+
# ublox-sockets = { version = "0.5", optional = true }
24+
ublox-sockets = { git = "https://github.com/BlackbirdHQ/ublox-sockets", rev = "9f7fe54", optional = true }
25+
portable-atomic = "1.6"
26+
27+
log = { version = "^0.4", default-features = false, optional = true }
28+
defmt = { version = "^0.3", optional = true }
29+
30+
embedded-hal = "1.0"
31+
embassy-time = "0.3"
32+
embassy-sync = "0.6"
33+
embassy-futures = "0.1"
34+
35+
embedded-nal-async = { version = "0.7" }
36+
futures-util = { version = "0.3.29", default-features = false }
37+
38+
embedded-io-async = "0.6"
39+
40+
embassy-net-ppp = { version = "0.1", optional = true }
41+
embassy-net = { version = "0.4", features = [
42+
"proto-ipv4",
43+
"medium-ip",
44+
], optional = true }
45+
46+
47+
[features]
48+
default = ["socket-tcp", "socket-udp"]
49+
50+
internal-network-stack = ["dep:ublox-sockets", "edm"]
51+
edm = ["ublox-sockets?/edm"]
52+
53+
ipv6 = ["embassy-net?/proto-ipv6"]
54+
55+
# PPP mode requires UDP sockets enabled, to be able to do AT commands over UDP port 23
56+
ppp = ["dep:embassy-net-ppp", "dep:embassy-net", "socket-udp"]
57+
58+
socket-tcp = ["ublox-sockets?/socket-tcp", "embassy-net?/tcp"]
59+
socket-udp = ["ublox-sockets?/socket-udp", "embassy-net?/udp"]
60+
61+
defmt = [
62+
"dep:defmt",
63+
"heapless/defmt-03",
64+
"atat/defmt",
65+
"ublox-sockets?/defmt",
66+
"embassy-net-ppp?/defmt",
67+
"embassy-net?/defmt",
68+
]
69+
log = ["dep:log", "ublox-sockets?/log", "atat/log"]
70+
71+
# Supported Ublox modules
72+
odin-w2xx = []
73+
nina-w1xx = []
74+
nina-b1xx = []
75+
anna-b1xx = []
76+
nina-b2xx = []
77+
nina-b3xx = []
78+
179
[workspace]
2-
resolver = "2"
3-
members = [ "ublox-short-range" ]
80+
members = []
81+
default-members = ["."]
82+
exclude = ["examples"]
483

584

685
[patch.crates-io]
7-
atat = { git = "https://github.com/BlackbirdHQ/atat", rev = "c5caaf7" }
86+
no-std-net = { git = "https://github.com/rushmorem/no-std-net", branch = "issue-15" }
87+
atat = { git = "https://github.com/BlackbirdHQ/atat", rev = "a466836" }
88+
# atat = { path = "../atat/atat" }

Design_diagram.drawio

-1
This file was deleted.

Design_diagram.png

-132 KB
Binary file not shown.

README.md

+17-21
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,27 @@
1212

1313
A driver crate for AT-command based serial ublox short range modules, built on top of [atat].
1414
The driver aims to be compatible with the ublox short range modules:
15-
- odin_w2xx
16-
- nina_w1xx
17-
- nina_b1xx
18-
- anna_b1xx
19-
- nina_b2xx
20-
- nina_b3xx
15+
16+
- odin-w2xx
17+
- nina-w1xx
18+
- nina-b1xx
19+
- anna-b1xx
20+
- nina-b2xx
21+
- nina-b3xx
2122

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

2425
## Documentation
25-
Design diagram:
26-
![design diagram](./Design_diagram.png "Design diagram")
27-
2826

2927
Relevant docs:
28+
3029
- https://www.u-blox.com/en/docs/UBX-14044127
3130
- https://www.u-blox.com/en/docs/UBX-14044126
3231
- https://www.u-blox.com/en/docs/UBX-16024251
3332

3433
Relevant repos:
35-
- https://github.com/u-blox/u-connectXpress-host-library
36-
- https://github.com/particle-iot/device-os
37-
- https://github.com/u-blox/ubxlib
3834

35+
- https://github.com/u-blox/ubxlib
3936

4037
## Tests
4138

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

5350
- device selection (must select one, and only one!):
54-
- `odin_w2xx`
55-
- `nina_w1xx`
56-
- `nina_b1xx`
57-
- `anna_b1xx`
58-
- `nina_b2xx`
59-
- `nina_b3xx`
51+
- `odin-w2xx`
52+
- `nina-w1xx`
53+
- `nina-b1xx`
54+
- `anna-b1xx`
55+
- `nina-b2xx`
56+
- `nina-b3xx`
6057
- `socket-tcp`: Enabled by default. Adds TCP socket capabilities, and implements [`TcpStack`] trait.
6158
- `socket-udp`: Enabled by default. Adds UDP socket capabilities, and implements [`UdpStack`] trait.
6259
- `defmt-default`: Disabled by default. Add log statements on trace (dev) or info (release) log levels to aid debugging.
@@ -66,13 +63,12 @@ The samples can be built using `cargo build -p linux_example --target x86_64-unk
6663
- `defmt-warn`: Disabled by default. Add log statements on warn log levels to aid debugging.
6764
- `defmt-error`: Disabled by default. Add log statements on error log levels to aid debugging.
6865

69-
7066
## License
7167

7268
Licensed under either of
7369

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

7874
at your option.
@@ -83,8 +79,8 @@ Unless you explicitly state otherwise, any contribution intentionally submitted
8379
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
8480
dual licensed as above, without any additional terms or conditions.
8581

86-
8782
<!-- Badges -->
83+
8884
[no-std-badge]: https://img.shields.io/badge/no__std-yes-blue
8985
[test]: https://github.com/BlackbirdHQ/ublox-short-range-rs/workflows/Test/badge.svg
9086
[codecov-badge]: https://codecov.io/gh/BlackbirdHQ/ublox-short-range-rs/branch/master/graph/badge.svg

0 commit comments

Comments
 (0)