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

Proof-of-concept device-profile struct + test-runner #1

Merged
merged 7 commits into from
Aug 30, 2024
Merged
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
38 changes: 38 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI
on:
push:
branches:
- '*'
tags:
- 'v*'
pull_request:

env:
CARGO_INCREMENTAL: 0

jobs:
tests:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Install Nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-24.05
-
name: Cargo cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
test-runner/target/
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
-
name: Run tests
run: nix-shell --command "cd test-runner && cargo run"
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM nixos/nix

ENV PROJECT_PATH=/lorawan-device-profiles
WORKDIR $PROJECT_PATH

ENTRYPOINT ["nix-shell"]

5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PHONY: test

test:
docker compose run --rm lorawan-device-profiles --run 'cd test-runner && cargo run'

80 changes: 79 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,80 @@
# LoRaWAN(R) device-profiles repository
# LoRaWAN(R) device-profiles

This repository contains device-profiles for LoRaWAN devices grouped by
vendor. A device-profile contains important information about the capabilities
of the device. For example which LoRaWAN mac-version has been implemented,
which regions are supported, if the device supports Class-B or Class-C, etc...
The aim is to build a complete list of LoRaWAN device-profiles that then can
be imported by ChirpStack or potentially any other LNS.

## Why not use the TTN lorawan-devices repository?

Unfortuantely the [https://github.com/thethingsnetwork/lorawan-devices](https://github.com/thethingsnetwork/lorawan-devices)
repository can no longer be used as a whole. The open-source license has been
removed and users are not allowed to _extract and/or reuse the Device Repositoryas
as a whole or a substantial part of its content_.
This prevents ChirpStack users (and other LNS providers) from importing this
repository into their database.

The goal of this repository is to provide an open-source database of LoRaWAN
device-profiles that can be freely imported.

## Structure

Example structure for an `example-vendor` with an `example` device:

```
vendors/
└── example-vendor
├── codecs
│   ├── example.js
│   ├── test_decode_example.json
│   └── test_encode_example.json
├── devices
│   └── example.toml
├── profiles
│   └── example-EU868.toml
└── vendor.toml
```

Please take a look at the `vendors/example-vendor` example documented
configuration files.

### `vendors/example-vendor`

This is the root of the example vendor. It must contain a `vendor.toml`
file. This `vendor.toml`.

### `vendors/example-vendor/codecs`

This directory contains the payload codecs. Codecs can be used by one or
multiple devices. E.g. some vendors have a generic payload codec.

Each codec is expected to have tests for encoding and decoding. If the
codec filename is `example.js`, then you should create two test-files
called `test_decode_example.json` (thus + `test_decode_` prefix and `.json`
extension) and `test_encode_example.json`.

### `vendors/example-vendor/devices`

This directory contains the devices. Each device will have its own `.toml`
configuration.

### `vendors/example-vendor/profiles`

This directory contains the profiles. These profiles can be used by one
or multiple devices. The profile also defines the region.

## Running the test

To run the test-runner, execute:

```
make test
```

This will run all tests within a Docker Compose environment.

## License

This repository is distributed under the MIT license. See also `LICENSE`.
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
services:
lorawan-device-profiles:
build:
context: .
volumes:
- ./:/lorawan-device-profiles
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "1.80.1"
components = ["rustfmt", "clippy"]
profile = "default"
7 changes: 7 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-24.05.tar.gz") {} }:

pkgs.mkShell {
buildInputs = [
pkgs.rustup
];
}
1 change: 1 addition & 0 deletions test-runner/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading