Skip to content

Commit 37cb689

Browse files
Merge pull request #47 from OS2iot/stage
Release stage to master
2 parents da3f296 + fb95b19 commit 37cb689

File tree

86 files changed

+148
-206
lines changed

Some content is hidden

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

86 files changed

+148
-206
lines changed

.readthedocs.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the version of Python and other tools you might need
9+
build:
10+
os: ubuntu-22.04
11+
tools:
12+
python: "3.11"
13+
14+
# Build documentation in the docs/ directory with Sphinx
15+
sphinx:
16+
configuration: source/conf.py
17+
18+
# We recommend specifying your dependencies to enable reproducible builds:
19+
# https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
20+
python:
21+
install:
22+
- requirements: ./requirements.txt

source/exit-strategy/exit-strategy.rst

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ Depending on the goal of the exit, you want to use different data, but in genera
4343

4444
4. IoTDevices
4545

46-
5. Datatargets
46+
5. Gateways
4747

48-
6. Payload decoder
48+
6. Datatargets
4949

50-
7. IoT-Device, PayloadDecoder and DataTarget Connection
50+
7. Payload decoder
51+
52+
8. IoT-Device, PayloadDecoder and DataTarget Connection
5153

5254
Optionally you can export the internal users and their access groups:
5355

@@ -65,17 +67,13 @@ If you want to export Sigfox data too then:
6567

6668
If you want to export LoRaWAN (Chirpstack) data then:
6769

68-
1. Gateway
69-
70-
2. Service Profile
71-
72-
3. Device Profile
70+
1. Device Profile
7371

7472
Export using the database
7573
-------------------------
7674

7775
A full database dump of the PostgreSQL database will backup most of the data.
78-
Sigfox data is stored in their backend; LoRaWAN gateways, service-profiles, and device-profiles are stored in Chirpstacks PostgreSQL database.
76+
Sigfox data is stored in their backend; Device-profiles are stored in Chirpstacks PostgreSQL database.
7977

8078
It is recommended to use :code:`pg_dump` to dump the database: https://www.postgresql.org/docs/current/backup-dump.html
8179

source/external-interface-design/external-interface-design.rst

Lines changed: 30 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,20 @@ in Chirpstack.
126126
Data from IoT devices is received by Chirpstack and sent to OS2iot by
127127
publishing to a MQTT broker which has OS2iot as a subscriber.
128128

129-
Data sent to IoT devices is sent from OS2iot to Chirpstack using a
130-
the REST API. Communication between the IoT devices, gateways
129+
Data sent to IoT devices is sent from OS2iot to Chirpstack using gRPC. Communication between the IoT devices, gateways
131130
and Chirpstack is out of scope of this project.
132131

133132
|image6|
134133

135134
The Chirpstack is comprised of the following 4 modules.
136135

137-
1. `Application
138-
Server <https://www.chirpstack.io/application-server/>`__
136+
1. `Gateway bridge <https://www.chirpstack.io/docs/chirpstack-gateway-bridge/>`__
139137

140-
2. `Network Server <https://www.chirpstack.io/network-server/>`__
138+
2. A postgresql database
141139

142-
3. `Gateway bridge <https://www.chirpstack.io/gateway-bridge/>`__
140+
3. An MQTT Broker
143141

144-
4. A postgresql database
142+
4. `Chirpstack <https://www.chirpstack.io/docs/>`__
145143

146144
Data synchronization
147145
~~~~~~~~~~~~~~~~~~~~
@@ -155,21 +153,13 @@ This includes:
155153

156154
- IoT devices
157155

158-
- Service profiles
159-
160156
- Device profiles
161157

158+
- Multicast groups.
159+
162160
Changes to these entities must always happen in OS2iot, which is then
163161
synchronized to Chirpstack. It is not supported to change data directly
164-
in Chirpstack. All manipulation of settings in the Chirpstack is thus
165-
done via the Chirpstack API. If locally running on port 8080 then Chirpstack Application Services Swagger UI is available at http://localhost:8080/api
166-
167-
There is no direct mapping between applications in OS2iot and applications in Chirpstack, even though they cover a similar concept.
168-
Instead, a separate Chirpstack application is created for each separate ServiceProfile created through OS2iot.
169-
170-
The new Chirpstack application is created the first time a device with a previously unused ServiceProfile is added to an OS2iot application.
171-
This is illustrated in the flowchart below:
172-
|image13|
162+
in Chirpstack. The protocol documentation for the api is documented at https://www.chirpstack.io/docs/chirpstack/api/api.html.
173163

174164
Security
175165
~~~~~~~~
@@ -178,76 +168,33 @@ OS2iot and Chirpstack have separate security models and do not share
178168
users. Instead, all communication between OS2iot and Chirpstack is done
179169
using a service account with administrator permissions in Chirpstack.
180170

181-
For communicating with the chirpstack api, it is necessary to set up a
182-
JWT token.
171+
For communicating with the chirpstack api, it is necessary to create a apikey on Chirpstack, which you must insert in the environment variable: :code:`CHIRPSTACK_API_KEY`.
183172

184-
We use the following code to generate a valid JWT for Chirpstack, here the is taken from the environment variable: :code:`CHIRPSTACK_JWTSECRET`, as described in `the installation guide <../installation-guide/installation-guide.html#id1>`_.
173+
This apikey is included in the header in every call to the Chirpstack api and has the format of an Bearer token:
185174

186175
.. code-block:: typescript
187176
188-
@Injectable()
189-
export class JwtToken {
190-
static setupToken(): string {
191-
const claims = {
192-
iss: "as", // issuer of the claim
193-
aud: "as", // audience for which the claim is intended
194-
iat: Math.floor(new Date().valueOf() / 1000 - 10), // unix time from which the token is valid
195-
nbf: Math.floor(new Date().valueOf() / 1000 - 10), // unix time from which the token is valid
196-
exp: Math.floor(new Date().valueOf() / 1000) + 60 * 60 * 24 * 14, // unix time when the token expires
197-
sub: "user", // subject of the claim (an user)
198-
username: "admin", // username the client claims to be
199-
};
200-
201-
const jwt = nJwt.create(claims, configuration()["chirpstack"]["jwtsecret"], "HS256");
202-
const token = jwt.compact();
203-
return token;
204-
}
205-
}
206-
207-
208-
The JWT is used as part of a special header named: :code:`Grpc-Metadata-Authorization`, while the value is the standard authorization header for a JWT as a Bearer token.
209-
210-
.. code-block:: javascript
211-
212-
var request = require('request');
213-
var headers = {
214-
    'Accept': 'application/json',
215-
    'Grpc-Metadata-Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcGlfa2V5X2lkIjoiYWExMGVkMmQtODdjZC00YmJlLTljZDktNmM4ODQ0ZTc5OTA2IiwiYXVkIjoiYXMiLCJpc3MiOiJhcyIsIm5iZiI6MTU5NjExMzIwMiwic3ViIjoiYXBpX2tleSJ9.7JfLkDe1xqqrqUtoKuSwHobUo7HGv-RvD0atftsgD_c'
216-
};
217-
218-
var options = {
219-
    url: 'http://localhost:8080/api/device-profiles',
220-
    headers: headers
221-
};
177+
makeMetadataHeader(): Metadata {
178+
const metadata = new Metadata();
179+
metadata.set("authorization", "Bearer " + configuration()["chirpstack"]["apikey"]);
180+
return metadata;
181+
}
222182
223183
Prerequisites
224184
""""""""""""""""""""""""""""""
225185

226-
In order to use the Chirpstack for LoRaWAN devices certain things has to be set up, in a
227-
specific order.
228-
229-
- Network server
230-
231-
- The network server has to be added. This is set up as a
232-
automatic process on startup of OS2iot backend.
186+
In order to use the Chirpstack for LoRaWAN devices certain things has to be set up.
233187

234188
- Gateway
235189

236-
- Create gateway profile
237-
238-
- Add a minimum of 1 gateway server to the system (this is done automatically).
190+
- Register gateway
239191

240192
- Devices
241193

242-
- Create service profile
243-
244194
- Create device profile
245195

246196
- Register device
247197

248-
- Note that once a Service Profile has been selected, it can't be
249-
changed.
250-
251198
Error handling
252199
~~~~~~~~~~~~~~
253200

@@ -258,8 +205,7 @@ If the error occured without it being caused by a user, e.g. IoT-device sends da
258205
Communicating with edge devices
259206
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
260207

261-
REST API is the easiest way to send payloads to edge devices. Retrieving
262-
data is done via MQTT.
208+
REST API is the easiest way to send payloads to edge devices. Retrieving data is done via MQTT.
263209

264210
Reading data
265211

@@ -281,17 +227,6 @@ Reading data
281227
scheduling or handling. E.g. in case when a payload could not be
282228
scheduled as it exceeds the maximum payload-size.
283229

284-
Register network server
285-
~~~~~~~~~~~~~~~~~~~~~~~
286-
287-
When registering the network server. The server attribute has to be set
288-
according to the docker container followed by port 8000 as shown in the
289-
following example.
290-
291-
**"server":"chirpstack-network-server:8000",**
292-
293-
.. _register-new-device-1:
294-
295230
Register new device
296231
~~~~~~~~~~~~~~~~~~~
297232

@@ -301,12 +236,10 @@ means. Over-the-Air Activation (OTAA) and Activation by Personalization
301236
with Network. The network assigns a dynamic DevAddr and negotiate
302237
security keys with the device. In other cases the DevAddr as well as the
303238
security keys is hardcoded in the device. This means activating a device
304-
by personalization (ABP). "Device profile" and "Service profil" has to
305-
be set In order to register a device. The *Device Profile* defines the
306-
boot **parameters** that are needed by ChirpStack Network Server to
307-
“connect” with a edge device. The *Service Profile* defines the features
308-
that are enabled for the devices and the rate of messages that can send
309-
over the network by a device.
239+
by personalization (ABP). "Device profile" has to
240+
be set in order to register a device. The *Device Profile* defines the
241+
boot **parameters** that are needed by the ChirpStack Server to
242+
“connect” with a edge device.
310243

311244
.. _update-existing-device-1:
312245

@@ -316,7 +249,7 @@ MQTT
316249
There are two kinds of MQTT devices available. MQTT external broker and MQTT internal broker. These two devices works in different matters which will be described below.
317250

318251
MQTT external broker
319-
~~~~~~~~~~~~~~
252+
~~~~~~~~~~~~~~~~~~~~~~
320253
The MQTT external broker device will make it possible for a physical device to communicate with the internal OS2IoT mosquitto broker.
321254
The MQTT external broker is created in the OS2IoT backend and is created with the credentials that the device needs for communicating with the internal broker.
322255

@@ -331,7 +264,7 @@ The specific topic for the created device will be :code:`device/organizationID/a
331264

332265

333266
MQTT internal broker
334-
~~~~~~~~~~~~~~~
267+
~~~~~~~~~~~~~~~~~~~~~
335268

336269
The MQTT internal broker uses the MQTT protocol to subscribe to a topic on an external MQTT broker. A client is created in the OS2IoT backend.
337270
This client will connect to the external MQTT broker using the provided URL, port and authentication, and then subscribe to data on the provided topic.
@@ -548,11 +481,9 @@ KOMBIT Adgangstyring
548481
See `the seperate page for KOMBIT adgangsstyring <../kombit-adgangsstyring/kombit-adgangsstyring.html>`_
549482

550483

551-
.. |image1| image:: media/image5.png
552-
.. |image2| image:: media/image6.png
553-
.. |image3| image:: media/image5.png
554-
.. |image4| image:: media/image8.png
555-
.. |image5| image:: media/image9.png
556-
.. |image6| image:: media/image10.png
557-
.. |image7| image:: media/image12.png
558-
.. |image13| image:: media/image13.png
484+
.. |image1| image:: media/external-integration-overview.png
485+
.. |image2| image:: media/internal-integration-design.png
486+
.. |image3| image:: media/external-integration-overview.png
487+
.. |image4| image:: media/datatargets.png
488+
.. |image5| image:: media/authentication.png
489+
.. |image6| image:: media/device-data-flow.png
Loading
-65.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)