Skip to content

Commit 23d5476

Browse files
authored
Add seeds and update certificate generation and document development setup (#47)
1 parent 72f655f commit 23d5476

File tree

5 files changed

+87
-16
lines changed

5 files changed

+87
-16
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ See [config/default.json](config/default.json). You should at least configure th
2626
}
2727
}
2828

29+
### Development
30+
31+
To get up and running for development run the following steps:
32+
33+
- Run `./scripts/setup_certs.sh` for generating development certificates.
34+
- Set the MQTT URL in row 23 in `./seeds/devices.json`
35+
- Run `docker-compose up -d`
36+
2937
## Environment variables
3038

3139
Its possible to supply your configuration json through the `NODE_CONFIG` environment variable. It is also possible to configure through custom environment variables:
@@ -47,6 +55,5 @@ Stable versions should be tagged using `yarn version` and `git push --follow-tag
4755

4856
[openSenseMap API]: https://github.com/sensebox/openSenseMap-API
4957
[node-config]: https://github.com/lorenwest/node-config
50-
[mongoDB Connection String]: https://docs.mongodb.com/v3.2/reference/connection-string/
5158
[osem-protos]: https://github.com/sensebox/osem-protos/blob/master/mqtt/mqtt.proto
5259
[Github Container Registry]: https://github.com/sensebox/mqtt-osem-integration/pkgs/container/mqtt-osem-integration

certstrap-notes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ certstrap init --common-name "openSenseMapCA"
99
## Create certificate requests for the server and client
1010

1111
```bash
12-
certstrap request-cert --key out/openSenseMapCA.key --common-name "mqtt-integration server" --domain mqtt-integration,localhost
13-
certstrap request-cert --key out/openSenseMapCA.key --common-name "mqtt-integration client" --domain api,localhost
12+
certstrap request-cert --common-name "mqtt-integration server"
13+
certstrap request-cert --common-name "mqtt-integration client"
1414
```
1515

1616
## Sign the certificate requests

config/default.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
{
2+
"openSenseMap-API-models": {
3+
"db": {
4+
"mongo_uri": "mongodb://localhost:27017/osem-mqtt"
5+
}
6+
},
27
"mqtt_client": {
38
"num_retries": 5,
49
"retry_after_minutes": 10
510
},
611
"grpc": {
712
"port": 3925,
813
"certificates": {
9-
"ca_cert": "",
10-
"server_cert": "",
11-
"server_key": ""
14+
"ca_cert": "./out/openSenseMapCA.crt",
15+
"server_cert": "./out/mqtt-integration_server.crt",
16+
"server_key": "./out/mqtt-integration_server.key"
1217
}
1318
},
1419
"mqtts_test_client:": {

scripts/setup_certs.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
echo "Initialize Certificate Authority called openSenseMapCA"
4+
certstrap init --common-name "openSenseMapCA"
5+
6+
echo "Request a certificate called mqtt-integration_server"
7+
certstrap request-cert --common-name "mqtt-integration server"
8+
9+
echo "Sign the requested certificated with the openSenseMapCA"
10+
certstrap sign --CA "openSenseMapCA" mqtt-integration_server

seeds/devices.json

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,63 @@
11
[
22
{
3-
"name": "Joe Smith",
4-
"email": "[email protected]",
5-
"age": 40,
6-
"admin": false
7-
},
8-
{
9-
"name": "Jen Ford",
10-
"email": "[email protected]",
11-
"age": 45,
12-
"admin": true
3+
"_id": "64ff1076088f2df36ed4d8ab",
4+
"createdAt" : "2023-06-23T10:50:48.246Z",
5+
"updatedAt" : "2023-09-11T11:35:12.838Z",
6+
"name" : "MQTT Test Device",
7+
"currentLocation" : {
8+
"timestamp" : "2023-06-23T10:50:48.241Z",
9+
"coordinates" : [
10+
7.2123,
11+
51.4823
12+
],
13+
"type" : "Point"
14+
},
15+
"exposure" : "outdoor",
16+
"integrations" : {
17+
"mqtt" : {
18+
"enabled" : true,
19+
"messageFormat" : "json",
20+
"connectionOptions" : "",
21+
"decodeOptions" : "",
22+
"topic" : "test",
23+
"url" : ""
24+
},
25+
"ttn" : {
26+
"decodeOptions" : [ ],
27+
"profile" : "sensebox/home",
28+
"dev_id" : "43369",
29+
"app_id" : "15649"
30+
}
31+
},
32+
"access_token" : "c343eb5329cf80b1fc26b4943e52ab42d4ef699e17a0499ff2e1a69f3d7ab624",
33+
"useAuth" : true,
34+
"sensors" : [
35+
{
36+
"_id": "64ff1076088f2df36ed4d8ac",
37+
"title": "Temperatur",
38+
"unit": "°C",
39+
"sensorType": "HDC1080",
40+
"icon": "osem-thermometer"
41+
},
42+
{
43+
"_id": "64ff1076088f2df36ed4d8ad",
44+
"title": "rel. Luftfeuchte",
45+
"unit": "%",
46+
"sensorType": "HDC1080",
47+
"icon": "osem-humidity"
48+
}
49+
],
50+
"model" : "homeV2Wifi",
51+
"grouptag" : [],
52+
"locations" : [
53+
{
54+
"timestamp" : "2023-06-23T10:50:48.241Z",
55+
"coordinates" : [
56+
7.2123,
57+
51.4823
58+
],
59+
"type" : "Point"
60+
}
61+
]
1362
}
1463
]

0 commit comments

Comments
 (0)