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

feature(*): async client #59

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": []
}
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"editor.formatOnSave": true,
"[toml]": {
"editor.formatOnSave": false
},
"rust-analyzer.cargo.target": "thumbv6m-none-eabi",
"rust-analyzer.cargo.noDefaultFeatures": true,
"rust-analyzer.check.allTargets": false,
"rust-analyzer.check.noDefaultFeatures": true,
"rust-analyzer.linkedProjects": [
"examples/rpi-pico/Cargo.toml",
],
"rust-analyzer.server.extraEnv": {
"WIFI_NETWORK": "foo",
"WIFI_PASSWORD": "foo",
}
}
71 changes: 68 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,72 @@
[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.18.0", features = ["derive", "defmt", "bytes"] }
# atat = { git = "https://github.com/BlackbirdHQ/atat", rev = "70283be", features = ["derive", "defmt", "bytes"] }
heapless = { version = "^0.7", features = ["serde", "defmt-impl"] }
no-std-net = { version = "0.6", features = ["serde"] }
serde = { version = "^1", default-features = false, features = ["derive"] }
ublox-sockets = { version = "0.5", features = ["defmt", "edm"], optional = true }
postcard = "1.0.4"
smoltcp = { version = "0.9.1", default-features = false, optional = true }
atomic-polyfill = "1.0.2"

defmt = { version = "0.3" }
embedded-hal = "=1.0.0-alpha.10"
# embedded-nal = "0.6.0"
embassy-time = "0.1"
embassy-sync = "0.2"
embassy-futures = "0.1"
embassy-hal-common = "0.1"
embassy-net-driver = "0.1"

embedded-nal-async = { version = "0.4", optional = true }
futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] }

embedded-io = "0.4"

[features]
default = ["async", "odin_w2xx", "ublox-sockets", "socket-tcp"]

async = ["dep:embedded-nal-async", "atat/async", "ublox-sockets?/async"]

std = []

defmt = ["postcard/use-defmt"]

odin_w2xx = []
nina_w1xx = []
nina_b1xx = []
anna_b1xx = []
nina_b2xx = []
nina_b3xx = []

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

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


[patch.crates-io]
atat = { git = "https://github.com/BlackbirdHQ/atat", rev = "70283be" }
atat = { path = "../atat/atat" }
ublox-sockets = { path = "../ublox-sockets" }
no-std-net = { path = "../no-std-net" }
embassy-net-driver = { path = "../embassy/embassy-net-driver" }
embassy-hal-common = { path = "../embassy/embassy-hal-common" }
9 changes: 9 additions & 0 deletions examples/rpi-pico/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# runner = "probe-rs-cli run --chip RP2040"
runner = "probe-run --chip RP2040"

[build]
target = "thumbv6m-none-eabi"

[env]
DEFMT_LOG = "debug,atat=warn"
77 changes: 77 additions & 0 deletions examples/rpi-pico/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[package]
name = "ublox-short-range-examples-rpi-pico"
version = "0.1.0"
edition = "2021"


[dependencies]
ublox-short-range-rs = { path = "../../", features = ["async", "defmt", "odin_w2xx", "ublox-sockets", "socket-tcp"] }
embassy-executor = { version = "0.1.0", features = ["defmt", "integrated-timers", "nightly"] }
embassy-time = { version = "0.1.0", features = ["defmt", "defmt-timestamp-uptime"] }
embassy-rp = { version = "0.1.0", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver"] }
embassy-futures = { version = "0.1.0" }
atomic-polyfill = "1.0.2"
static_cell = "1.1"
no-std-net = { version = "0.6", features = ["serde"] }

defmt = "0.3.4"
defmt-rtt = "0.3"
panic-probe = { version = "0.3", features = ["print-defmt"] }

cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0"
futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] }

embedded-io = { version = "0.4.0", features = ["async", "defmt"] }
heapless = "0.7.15"


[patch.crates-io]
# embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" }
# embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" }
# embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" }
# embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" }
# embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" }
# embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "03d6363d5af5dcaf21b52734994a466ca593d2b6" }


embassy-executor = { path = "../../../embassy/embassy-executor" }
embassy-hal-common = { path = "../../../embassy/embassy-hal-common" }
embassy-time = { path = "../../../embassy/embassy-time" }
embassy-futures = { path = "../../../embassy/embassy-futures" }
embassy-sync = { path = "../../../embassy/embassy-sync" }
embassy-rp = { path = "../../../embassy/embassy-rp" }
embassy-net-driver = { path = "../../../embassy/embassy-net-driver" }
atat = { path = "../../../atat/atat" }
ublox-sockets = { path = "../../../ublox-sockets" }
no-std-net = { path = "../../../no-std-net" }

[profile.dev]
debug = 2
debug-assertions = true
opt-level = 1
overflow-checks = true

[profile.release]
codegen-units = 1
debug = 2
debug-assertions = false
incremental = false
lto = 'fat'
opt-level = 'z'
overflow-checks = false

# do not optimize proc-macro crates = faster builds from scratch
[profile.dev.build-override]
codegen-units = 8
debug = false
debug-assertions = false
opt-level = 0
overflow-checks = false

[profile.release.build-override]
codegen-units = 8
debug = false
debug-assertions = false
opt-level = 0
overflow-checks = false
36 changes: 36 additions & 0 deletions examples/rpi-pico/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//! This build script copies the `memory.x` file from the crate root into
//! a directory where the linker can always find it at build time.
//! For many projects this is optional, as the linker always searches the
//! project root directory -- wherever `Cargo.toml` is. However, if you
//! are using a workspace or have a more complicated build setup, this
//! build script becomes required. Additionally, by requesting that
//! Cargo re-run the build script whenever `memory.x` is changed,
//! updating `memory.x` ensures a rebuild of the application with the
//! new memory settings.

use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;

fn main() {
// Put `memory.x` in our output directory and ensure it's
// on the linker search path.
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
File::create(out.join("memory.x"))
.unwrap()
.write_all(include_bytes!("memory.x"))
.unwrap();
println!("cargo:rustc-link-search={}", out.display());

// By default, Cargo will re-run a build script whenever
// any file in the project changes. By specifying `memory.x`
// here, we ensure the build script is only re-run when
// `memory.x` is changed.
println!("cargo:rerun-if-changed=memory.x");

println!("cargo:rustc-link-arg-bins=--nmagic");
println!("cargo:rustc-link-arg-bins=-Tlink.x");
println!("cargo:rustc-link-arg-bins=-Tlink-rp.x");
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
}
5 changes: 5 additions & 0 deletions examples/rpi-pico/memory.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MEMORY {
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
FLASH : ORIGIN = 0x10000100, LENGTH = 1024K - 0x100
RAM : ORIGIN = 0x20000000, LENGTH = 256K
}
Loading