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(*): Introduce fully async library #58

Draft
wants to merge 36 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0a1edc2
Rework provisioning to async
MathiasKoch Jan 4, 2024
f64903a
Working async provisioning based on embedded-mqtt with integration test
MathiasKoch Jan 6, 2024
cadf3d3
Rework topic formatting slightly
MathiasKoch Jan 6, 2024
548be76
Get rid of additional stack allocation for ownership token
MathiasKoch Jan 6, 2024
e81fd6f
Reenable jobs
MathiasKoch Jan 6, 2024
cd14fc8
Rewrite OTA to async
MathiasKoch Jan 8, 2024
4a09047
Working OTA
MathiasKoch Jan 9, 2024
531d6f1
Formatting
MathiasKoch Jan 9, 2024
eaa82b8
Fully working OTA integration test
MathiasKoch Jan 11, 2024
20f9db9
Clean up OTA integration test, make sure it reports success and add m…
MathiasKoch Jan 11, 2024
f3742a4
Use stable 1.75
MathiasKoch Jan 18, 2024
505bb2c
use git embedded-mqtt
MathiasKoch Jan 18, 2024
f225c96
Fix defmt feature
MathiasKoch Jan 18, 2024
7edb08c
Add support for provisioning by CSR to the Fleet Provisioner
MathiasKoch Mar 15, 2024
e225b1f
Update embedded-mqtt dependency
MathiasKoch May 31, 2024
20ece31
Bump embedded-mqtt, and use DeferredPayload
MathiasKoch Jun 11, 2024
34dc52f
Temporarilly subscribe to only accepted topic
MathiasKoch Jun 20, 2024
604ca46
Bump embedded-mqtt
MathiasKoch Jul 18, 2024
d6d4af3
Fix provisioning topic resulting in status code 143, by subscribing t…
MathiasKoch Jul 19, 2024
f424608
Reduce the overhead of of CreateCertificateFromCsr buffer size
MathiasKoch Jul 19, 2024
f924e1e
Feature/async shadows (#57)
MathiasKoch Sep 25, 2024
1763f6c
Add report fn to persisted shadows
MathiasKoch Sep 26, 2024
967c0b5
OTA tests pass again after rewrite
MathiasKoch Oct 3, 2024
16bdbca
Add more docs
MathiasKoch Oct 3, 2024
bb34d44
Update CI actions
MathiasKoch Oct 3, 2024
916296e
Remove local patch
MathiasKoch Oct 3, 2024
d712932
Make sure OTA request momentum is not running prior to subscription
MathiasKoch Oct 4, 2024
01c44a0
Fix(async): Ensure one sub on topic (#64)
KennethKnudsen97 Oct 10, 2024
c3456cd
bump embedded mqtt
KennethKnudsen97 Oct 10, 2024
2378458
Fix OTA & bump dependencies (#67)
MathiasKoch Oct 29, 2024
798f496
Change default block size, and update frequency
MathiasKoch Nov 6, 2024
f942b03
Enhancement: Replace serde_cbor with minicbor (#68)
KennethKnudsen97 Nov 6, 2024
7e7eab8
Fix minicbor serialize returning number of written bytes correctly
MathiasKoch Nov 21, 2024
2c5757d
Bump embassy dependencies to newly released versions
MathiasKoch Jan 13, 2025
3e2cad0
remove locks (#71)
KennethKnudsen97 Feb 6, 2025
9103492
Feature: Implement defender metrics (#70)
KennethKnudsen97 Feb 7, 2025
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
154 changes: 128 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,75 +6,112 @@ on:
- master
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
ALL_FEATURES: "ota_mqtt_data,ota_http_data"

jobs:
cancel_previous_runs:
name: Cancel previous runs
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout source code
uses: actions/checkout@v4

- uses: dsherret/rust-toolchain-file@v1

- name: Build (library)
run: cargo build --all --target thumbv7em-none-eabihf

# - name: Build (examples)
# run: |
# for EXAMPLE in $(ls examples);
# do
# (cd examples/$EXAMPLE && cargo build)
# done

test:
name: Build & Test
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: dsherret/rust-toolchain-file@v1
- name: Build

- name: Doc Tests
uses: actions-rs/cargo@v1
with:
command: build
args: --all --target thumbv7em-none-eabihf --features ${{ env.ALL_FEATURES }}
command: test
args: --doc --features "std,log"

- name: Test
- name: Unit Tests
uses: actions-rs/cargo@v1
with:
command: test
args: --lib --features "ota_mqtt_data,log"
args: --lib --features "std,log"

rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3

uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- name: Rustfmt
run: cargo fmt -- --check

- name: Run rustfmt (library)
run: cargo fmt --all -- --check --verbose

# - name: Run rustfmt (examples)
# run: |
# for EXAMPLE in $(ls examples);
# do
# (cd examples/$EXAMPLE && cargo fmt --all -- --check --verbose)
# done

clippy:
name: clippy
runs-on: ubuntu-latest
env:
CLIPPY_PARAMS: -W clippy::all -W clippy::pedantic -W clippy::nursery -W clippy::cargo
steps:
- name: Checkout source code
uses: actions/checkout@v3

uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: -- ${{ env.CLIPPY_PARAMS }}

- name: Run clippy (library)
run: cargo clippy --features "log" -- ${{ env.CLIPPY_PARAMS }}

# - name: Run clippy (examples)
# run: |
# for EXAMPLE in $(ls examples);
# do
# (cd examples/$EXAMPLE && cargo clippy -- ${{ env.CLIPPY_PARAMS }})
# done

integration-test:
name: Integration Tests
runs-on: ubuntu-latest
needs: ['test', 'rustfmt', 'clippy']
needs: ["build", "test", "rustfmt", "clippy"]
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: dsherret/rust-toolchain-file@v1

- name: Create OTA Job
run: |
./scripts/create_ota.sh
env:
AWS_DEFAULT_REGION: ${{ secrets.MGMT_AWS_DEFAULT_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.MGMT_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.MGMT_AWS_SECRET_ACCESS_KEY }}

- name: Integration Tests
uses: actions-rs/cargo@v1
with:
Expand All @@ -91,4 +128,69 @@ jobs:
env:
AWS_DEFAULT_REGION: ${{ secrets.MGMT_AWS_DEFAULT_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.MGMT_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.MGMT_AWS_SECRET_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.MGMT_AWS_SECRET_ACCESS_KEY }}

# device_advisor:
# name: AWS IoT Device Advisor
# runs-on: ubuntu-latest
# needs: test
# env:
# AWS_EC2_METADATA_DISABLED: true
# AWS_DEFAULT_REGION: ${{ secrets.MGMT_AWS_DEFAULT_REGION }}
# AWS_ACCESS_KEY_ID: ${{ secrets.MGMT_AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.MGMT_AWS_SECRET_ACCESS_KEY }}
# SUITE_ID: 1gaev57dq6i5
# THING_ARN: arn:aws:iot:eu-west-1:411974994697:thing/embedded-mqtt
# steps:
# - name: Checkout source code
# uses: actions/checkout@v4

# - uses: dsherret/rust-toolchain-file@v1

# - name: Get AWS_HOSTNAME
# id: hostname
# run: |
# hostname=$(aws iotdeviceadvisor get-endpoint --thing-arn ${{ env.THING_ARN }} --output text --query endpoint)
# ret=$?
# echo "::set-output name=AWS_HOSTNAME::$hostname"
# exit $ret

# - name: Build test binary
# env:
# AWS_HOSTNAME: ${{ steps.hostname.outputs.AWS_HOSTNAME }}
# run: cargo build --features=log --example aws_device_advisor --release

# - name: Start test suite
# id: test_suite
# run: |
# suite_id=$(aws iotdeviceadvisor start-suite-run --suite-definition-id ${{ env.SUITE_ID }} --suite-run-configuration "primaryDevice={thingArn=${{ env.THING_ARN }}},parallelRun=true" --output text --query suiteRunId)
# ret=$?
# echo "::set-output name=SUITE_RUN_ID::$suite_id"
# exit $ret

# - name: Execute test binary
# id: binary
# env:
# DEVICE_ADVISOR_PASSWORD: ${{ secrets.DEVICE_ADVISOR_PASSWORD }}
# RUST_LOG: trace
# run: |
# nohup ./target/release/examples/aws_device_advisor > device_advisor_integration.log &
# echo "::set-output name=PID::$!"

# - name: Monitor test run
# run: |
# chmod +x ./scripts/da_monitor.sh
# echo ${{ env.SUITE_ID }} ${{ steps.test_suite.outputs.SUITE_RUN_ID }} ${{ steps.binary.outputs.PID }}
# ./scripts/da_monitor.sh ${{ env.SUITE_ID }} ${{ steps.test_suite.outputs.SUITE_RUN_ID }} ${{ steps.binary.outputs.PID }}

# - name: Kill test binary process
# if: ${{ always() }}
# run: kill ${{ steps.binary.outputs.PID }} || true

# - name: Log binary output
# if: ${{ always() }}
# run: cat device_advisor_integration.log

# - name: Stop test suite
# if: ${{ failure() }}
# run: aws iotdeviceadvisor stop-suite-run --suite-definition-id ${{ env.SUITE_ID }} --suite-run-id ${{ steps.test_suite.outputs.SUITE_RUN_ID }}
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"rust-analyzer.checkOnSave.allTargets": false,
"rust-analyzer.checkOnSave.allTargets": true,
"rust-analyzer.cargo.features": ["log"],
"rust-analyzer.cargo.target": "x86_64-unknown-linux-gnu"
"rust-analyzer.cargo.target": "x86_64-unknown-linux-gnu",

}
96 changes: 64 additions & 32 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ members = ["shadow_derive"]

[package]
name = "rustot"
version = "0.4.1"
authors = ["Mathias Koch <[email protected]>"]
version = "0.5.0"
authors = ["Factbird team <[email protected]>"]
description = "AWS IoT"
readme = "README.md"
keywords = ["iot", "no-std"]
categories = ["embedded", "no-std"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/BlackbirdHQ/rustot"
repository = "https://github.com/FactbirdHQ/rustot"
edition = "2021"
documentation = "https://docs.rs/rustot"
exclude = ["/documentation"]
Expand All @@ -22,45 +22,77 @@ name = "rustot"
maintenance = { status = "actively-developed" }

[dependencies]
bitmaps = { version = "^3.1", default-features = false }
heapless = { version = "0.7.0", features = ["serde"] }
mqttrust = { version = "0.6" }
nb = "1"
serde = { version = "1.0.126", default-features = false, features = ["derive"] }
serde_cbor = { version = "^0.11", default-features = false, optional = true }
serde-json-core = { version = "0.4.0" }
smlang = "0.5.0"
fugit-timer = "0.1.2"
bitmaps = { version = "3.1", default-features = false }
heapless = { version = "0.8", features = ["serde"] }
serde = { version = "1.0", default-features = false, features = ["derive"] }

minicbor = { version = "0.25", optional = true }
minicbor-serde = { version = "0.3.2", optional = true }


serde-json-core = { version = "0.6" }
shadow-derive = { path = "shadow_derive", version = "0.2.1" }
embedded-storage = "0.3.0"
embedded-storage-async = "0.4"
embedded-mqtt = { git = "ssh://[email protected]/FactbirdHQ/embedded-mqtt", rev = "dc7c390" }

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

embassy-time = { version = "0.4" }
embassy-sync = "0.6"
embassy-futures = "0.1"

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

[dev-dependencies]
native-tls = { version = "^0.2" }
embedded-nal = "0.6.0"
no-std-net = { version = "^0.5", features = ["serde"] }
dns-lookup = "1.0.3"
mqttrust_core = { version = "0.6", features = ["log"] }
env_logger = "0.9.0"
native-tls = { version = "0.2" }
embedded-nal-async = "0.8"
env_logger = "0.11"
sha2 = "0.10.1"
ecdsa = { version = "0.13.4", features = ["pkcs8"] }
p256 = "0.10.1"
pkcs8 = { version = "0.8", features = ["encryption", "pem"] }
timebomb = "0.1.2"
hex = "0.4.3"
static_cell = { version = "2", features = ["nightly"] }
log = { version = "0.4" }
serde_json = "1"

tokio = { version = "1.33", default-features = false, features = [
"macros",
"rt",
"net",
"time",
"io-std",
] }
tokio-native-tls = { version = "0.3.1" }
embassy-futures = { version = "0.1.0" }
embassy-time = { version = "0.4", features = ["log", "std", "generic-queue-8"] }
embedded-io-adapters = { version = "0.6.0", features = ["tokio-1"] }

ecdsa = { version = "0.16", features = ["pkcs8", "pem"] }
p256 = "0.13"
pkcs8 = { version = "0.10", features = ["encryption", "pem"] }
hex = { version = "0.4.3", features = ["alloc"] }


[features]
default = ["ota_mqtt_data", "provision_cbor"]
default = ["ota_mqtt_data", "metric_cbor", "provision_cbor"]

metric_cbor = ["dep:minicbor", "dep:minicbor-serde"]

provision_cbor = ["serde_cbor"]
provision_cbor = ["dep:minicbor", "dep:minicbor-serde"]

ota_mqtt_data = ["dep:minicbor", "dep:minicbor-serde"]

ota_mqtt_data = ["serde_cbor"]
ota_http_data = []

std = ["serde/std", "serde_cbor?/std"]
std = ["serde/std", "minicbor-serde?/std"]

defmt = [
"dep:defmt",
"heapless/defmt-03",
"embedded-mqtt/defmt",
"embassy-time/defmt",
]
log = ["dep:log", "embedded-mqtt/log"]

defmt = ["dep:defmt", "mqttrust/defmt-impl", "heapless/defmt-impl"]

graphviz = ["smlang/graphviz"]
[patch."ssh://[email protected]/FactbirdHQ/embedded-mqtt"]
embedded-mqtt = { path = "../embedded-mqtt" }
Loading