You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/exit-strategy/exit-strategy.rst
+15-3Lines changed: 15 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,28 @@
1
1
Exit strategy
2
2
=============
3
3
4
-
There are two primary ways of systematically exporting the data from OS2iot:
4
+
There are three primary ways of systematically exporting the data from OS2iot:
5
5
6
-
1. Using the REST API
6
+
1. Using the Export
7
+
8
+
a. Ideal if you just need to get all the information about devices in an application.
9
+
10
+
2. Using the REST API
7
11
8
12
a. Ideal if you want to import/change it into something else, and OS2iot is still running.
9
13
10
-
2. Exporting the database
14
+
3. Exporting the database
11
15
12
16
a. If OS2iot is no longer running, the postgres database will contain all the data from the system.
13
17
18
+
Export using CSV export
19
+
-----------------------
20
+
21
+
It is possible, when on the details page for an application, to get a csv file containing all the devices in the application.
22
+
23
+
This csv file is formatted to be compatible with the bulk import feature, button located right next to it, to make it possible to reimport the devices into a different application.
24
+
25
+
14
26
Export using the REST API
15
27
-------------------------
16
28
The REST API is automatically exported from the backend via swagger.
Copy file name to clipboardExpand all lines: source/external-interface-design/external-interface-design.rst
+40-4Lines changed: 40 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ Integration patterns
20
20
Internal systems
21
21
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22
22
23
-
Internally, OS2iot consists of four components shown in this figure.
23
+
Internally, OS2iot consists of five components shown in this figure.
24
24
25
25
|image2|
26
26
@@ -30,7 +30,7 @@ Two different patterns are used between the internal components:
30
30
|Used between the frontend, backend and database.
31
31
32
32
- | **Publish-subscribe**
33
-
|Used in communication between the backend and MQTT broker for Chirpstack.
33
+
|Used in communication between the backend and MQTT broker for Chirpstack and the internal MQTT broker.
34
34
35
35
External systems
36
36
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -50,11 +50,13 @@ IoT devices
50
50
51
51
Figure 3 - IoT device integration overview
52
52
53
-
All IoT device integrations except LoRaWAN use callbacks to send data to
53
+
All IoT device integrations except LoRaWAN and MQTT use callbacks to send data to
54
54
OS2iot using HTTPS in a request-response manner. Device management for
55
55
Sigfox (i.e. adding and modifying IoT devices) is done by
56
56
sending requests to Sigfox's Cloud backend.
57
57
58
+
MQTT devices uses the MQTT protocol to communicate with the broker.
59
+
58
60
Data from Chirpstack devices are sent to OS2iot through Chirpstack using
59
61
MQTT, where Chirpstack is the publisher and OS2iot is the subscriber.
60
62
Device management is done from OS2iot by sending gRPC requests to
@@ -308,6 +310,40 @@ over the network by a device.
308
310
309
311
.. _update-existing-device-1:
310
312
313
+
MQTT
314
+
^^^^
315
+
316
+
There are two kinds of MQTT devices available. MQTT-publisher and MQTT-subscriber. These two devices works in different matters which will be described below.
317
+
318
+
MQTT-publisher
319
+
~~~~~~~~~~~~~~
320
+
The MQTT-publisher device will make it possible for a physical device to communicate with the internal OS2IoT mosquitto broker.
321
+
The MQTT-publisher is created in the OS2IoT backend and is created with the credentials that the device needs for communicating with the internal broker.
322
+
323
+
The MQTT-publisher device can either be created with username/password or credentials. If the publisher is created with username/password it will use port 8885, and if created with certificate it will use port 8884.
324
+
325
+
When a physical MQTT device will publish some data, then OS2IoT will check for the specific topic that the device is publishing to in the database, and if the topic is set in the database, it will process the data.
326
+
If a MQTT-publisher device with the specific topic isn't created then the broker won't be able to find it in the database and therefore it will reject the data.
327
+
328
+
The specific topic for the created device will be :code:`device/organizationID/applicationID/deviceID`.
329
+
330
+
331
+
332
+
333
+
MQTT-subscriber
334
+
~~~~~~~~~~~~~~~
335
+
336
+
The MQTT-subscriber uses the MQTT protocol to subscribe to a topic on an external MQTT broker. A client is created in the OS2IoT backend.
337
+
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.
338
+
339
+
OS2IoT doesn't have any knowlegde of the external broker so it's totally up to the user to provide the different inputs.
340
+
If the input isn't valid and a connection can't be made to the external broker, a flag will be set in the database which tells OS2IoT that the connection can't be made and then OS2IoT will stop trying to connect to the external broker.
341
+
342
+
If the inputs from the user IS valid, then a connection will be made and the device will listen to any updates from the broker.
343
+
344
+
The MQTT-subscriber device has the possibility to use either certificate or username/password to a external broker if needed.
345
+
346
+
311
347
Sigfox
312
348
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
313
349
@@ -514,7 +550,7 @@ See `the seperate page for KOMBIT adgangsstyring <../kombit-adgangsstyring/kombi
To get the mosquitto broker working, you have to create some certificates and update some values. These following steps is done with Windows. If you use linux, then write :code:`sudo` before the commands.
282
+
283
+
Prerequisites: openssl installed and accesible from path
284
+
285
+
Generate files:
286
+
287
+
1. Open the command prompt in administrator mode.
288
+
289
+
2. Create a certificate authority(CA) key with this command: :code:`openssl genrsa -des3 -out ca.key 2048`. You will be prompted to enter a password. It's very important that you save this password, since it will be used later.
290
+
291
+
3. Create the CA certificate with this command: :code:`openssl req -new -x509 -days 1826 -key ca.key -out ca.crt`. You will be asked to enter the password from the step before. After this, you will be prompted to enter informations. These values are not important, except one: "Common name". Common name HAS to be the ip/hostname of your broker.
292
+
293
+
4. Create the server key (for the broker) with the command: :code:`openssl genrsa -out server.key 2048`
294
+
295
+
6. Create the server signing request with the command: :code:`openssl req -new -out server.csr -key server.key`. You will be prompted to enter some informations. These values are not important, except one: "Common name". Common name HAS to be the ip/hostname of your broker. The rest of the values should not be exact the same as in step 4.
296
+
297
+
7. Create the server certificate (that is signed by the CA) with this command: :code:`openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 360`. You will be prompted to enter the password from step 3.
298
+
299
+
If you want to get docker container with mosquitto running, then follow these steps:
300
+
301
+
1. Place the generated files, ca.key, ca.crt, server.key and server.crt from the above steps in the folder "OS2IoT-docker/configuration/mosquitto-broker-os2iot". You don't need the server.csr.
302
+
303
+
2. Open the mosquitto-os2iot.conf file placed in OS2IoT-docker/configuration/mosquitto-broker-os2iot in a text editor and update the values to match your database.
304
+
305
+
3. Copy the files ca.crt and ca.key and place them in OS2IoT-backend/resources.
306
+
307
+
4. Update the :code:`MQTT_BROKER_HOSTNAME` with the ip/hostname that you used for step 4 and 6, and :code:`CA_KEY_PASSWORD` with the password that you entered in step 3 in the docker-compose.yml file placed in OS2IoT-docker.
308
+
309
+
If you want to use kubernetes to host mosquitto then you need some futher steps.
310
+
311
+
Prerequisites: kubectl installed and accesible from path
312
+
313
+
1. Open a command prompt in administrator mode.
314
+
315
+
2. Create a secret with the server.key and server.crt with the command: :code:`kubectl create secret generic server-keys --from-file=server.key=path/to/server.key --from-file=server.crt=path/to/server.crt`. Replace path/to/ with the path to your server.key and server.crt, created in the steps above.
316
+
317
+
3. Create a secret with the ca.crt and ca.key with the command: :code:`kubectl create secret generic ca-keys --from-file=ca.crt=path/to/ca.crt --from-file=ca.key=path/to/ca.key`. Replace path/to/ with the path to your server.key and server.crt, created in the steps above.
318
+
319
+
4. Update the empty values in OS2IoT-docker/helm/charts/mosquitto-os2iot/values.yaml
320
+
321
+
5. Update the :code:`MQTT_BROKER_HOSTNAME` with the ip/hostname that you used for step 4 and 6 in the steps above, and :code:`CA_KEY_PASSWORD` with the password that you entered in step 3 in the steps above, in the file "OS2IoT-docker/helm/charts/os2iot-backend/deployment.yaml".
0 commit comments