Skip to content

Commit df4c4a1

Browse files
committed
merge of development
2 parents 461777e + 9c0faf9 commit df4c4a1

File tree

19 files changed

+137
-532
lines changed

19 files changed

+137
-532
lines changed

packages/api/lib/controllers/boxesController.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ const getBox = async function getBox (req, res, next) {
380380
* @apiParam (RequestBody) {Location} location the coordinates of this senseBox.
381381
* @apiParam (RequestBody) {String="homeV2Lora","homeV2Ethernet","homeV2Wifi","homeEthernet","homeWifi","homeEthernetFeinstaub","homeWifiFeinstaub","luftdaten_sds011","luftdaten_sds011_dht11","luftdaten_sds011_dht22","luftdaten_sds011_bmp180","luftdaten_sds011_bme280","hackair_home_v2"} [model] specify the model if you want to use a predefined senseBox model, autocreating sensor definitions.
382382
* @apiParam (RequestBody) {Sensor[]} [sensors] an array containing the sensors of this senseBox. Only use if `model` is unspecified.
383-
* @apiParam (RequestBody) {String="hdc1080","bmp280","tsl45315","veml6070","sds011"} [sensorTemplates] Specify which sensors should be included.
383+
* @apiParam (RequestBody) {String="hdc1080","bmp280","tsl45315","veml6070","sds011","bme680","smt50","soundlevelmeter"} [sensorTemplates] Specify which sensors should be included.
384384
* @apiParam (RequestBody) {Object} [mqtt] specify parameters of the MQTT integration for external measurement upload. Please see below for the accepted parameters
385385
* @apiParam (RequestBody) {Object} [ttn] specify parameters for the TTN integration for measurement from TheThingsNetwork.org upload. Please see below for the accepted parameters
386386
*
@@ -407,14 +407,25 @@ const postNewBox = async function postNewBox (req, res, next) {
407407
* @api {get} /boxes/:senseBoxId/script Download the Arduino script for your senseBox
408408
* @apiName getSketch
409409
* @apiGroup Boxes
410+
* @apiParam {String="Serial1","Serial2"} serialPort the serial port the SDS011 sensor is connected to
411+
* @apiParam {String="A","B","C"} soilDigitalPort the digital port the SMT50 sensor is connected to
412+
* @apiParam {String="A","B","C"} soundMeterPort the digital port the soundlevelmeter sensor is connected to
413+
* @apiParam {String} ssid the ssid of your wifi network
414+
* @apiParam {String} password the password of your wifi network
410415
* @apiUse JWTokenAuth
411416
* @apiUse BoxIdParam
412417
*/
413418
const getSketch = async function getSketch (req, res, next) {
414419
res.header('Content-Type', 'text/plain; charset=utf-8');
415420
try {
416421
const box = await Box.findBoxById(req._userParams.boxId, { populate: false, lean: false });
417-
res.send(box.getSketch({ serialPort: req._userParams.serialPort, ssid: req._userParams.ssid, password: req._userParams.password }));
422+
res.send(box.getSketch({
423+
serialPort: req._userParams.serialPort,
424+
soilDigitalPort: req._userParams.soilDigitalPort,
425+
soundMeterPort: req._userParams.soundMeterPort,
426+
ssid: req._userParams.ssid,
427+
password: req._userParams.password
428+
}));
418429
} catch (err) {
419430
handleError(err, next);
420431
}
@@ -460,6 +471,8 @@ module.exports = {
460471
retrieveParameters([
461472
{ predef: 'boxId', required: true },
462473
{ name: 'serialPort', dataType: 'String', allowedValues: ['Serial1', 'Serial2'] },
474+
{ name: 'soilDigitalPort', dataType: 'String', allowedValues: ['A', 'B', 'C'] },
475+
{ name: 'soundMeterPort', dataType: 'String', allowedValues: ['A', 'B', 'C'] },
463476
{ name: 'ssid', dataType: 'StringWithEmpty' },
464477
{ name: 'password', dataType: 'StringWithEmpty' }
465478
]),
@@ -504,8 +517,10 @@ module.exports = {
504517
{ name: 'exposure', allowedValues: Box.BOX_VALID_EXPOSURES },
505518
{ name: 'model', allowedValues: Box.BOX_VALID_MODELS },
506519
{ name: 'sensors', dataType: ['object'] },
507-
{ name: 'sensorTemplates', dataType: ['String'], allowedValues: ['hdc1080', 'bmp280', 'sds 011', 'tsl45315', 'veml6070'] },
520+
{ name: 'sensorTemplates', dataType: ['String'], allowedValues: ['hdc1080', 'bmp280', 'sds 011', 'tsl45315', 'veml6070', 'bme680', 'smt50', 'soundlevelmeter'] },
508521
{ name: 'serialPort', dataType: 'String', defaultValue: 'Serial1', allowedValues: ['Serial1', 'Serial2'] },
522+
{ name: 'soilDigitalPort', dataType: 'String', defaultValue: 'A', allowedValues: ['A', 'B', 'C'] },
523+
{ name: 'soundMeterPort', dataType: 'String', defaultValue: 'B', allowedValues: ['A', 'B', 'C'] },
509524
{ name: 'mqtt', dataType: 'object' },
510525
{ name: 'ttn', dataType: 'object' },
511526
{ predef: 'location', required: true }

packages/api/lib/controllers/measurementsController.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,10 @@ const postNewMeasurement = async function postNewMeasurement (req, res, next) {
221221
* Decoding of hackAIR json format. Activate by specifying `hackair=true` in the query string. The API now tries to convert the values in the `reading` key to the openSenseMap JSON Array format. Sensors are matched by the key `sensor_description` against the `title` of the sensors of this box. `PM2.5_AirPollutantValue` matches sensors with title `PM2.5`, `PM10_AirPollutantValue` matches sensors with title `PM10`. You can find all matchings in the source code of the openSenseMap-API (`lib/decoding/hackAirHandler.js`)
222222
*
223223
* **senseBox Bytes Format**<br/>
224-
* Submit measurements as raw bytes. Set the "content-type" header to `application/snsbx-bytes`. Send measurements as 12 byte sensor Id with most significant byte first followed by 4 byte float measurement in little endian (least significant byte first) notation. A valid measurement could look like this:<br />[ 0x59, 0x5f, 0x9a, 0x28, 0x2d, 0xcb, 0xee, 0x77, 0xac, 0x0e, 0x5d, 0xc4, 0x9a, 0x99, 0x89, 0x40 ] but encoded as raw bytes. Multiple measurements are just multiple tuples of id and value. The number of bytes should be a multiple of 16.
224+
* Submit measurements as raw bytes. Set the "content-type" header to `application/sbx-bytes`. Send measurements as 12 byte sensor Id with most significant byte first followed by 4 byte float measurement in little endian (least significant byte first) notation. A valid measurement could look like this:<br />[ 0x59, 0x5f, 0x9a, 0x28, 0x2d, 0xcb, 0xee, 0x77, 0xac, 0x0e, 0x5d, 0xc4, 0x9a, 0x99, 0x89, 0x40 ] but encoded as raw bytes. Multiple measurements are just multiple tuples of id and value. The number of bytes should be a multiple of 16.
225225
*
226226
* **senseBox Bytes with Timestamp Format**<br/>
227-
* Submit measurements with timestamp as raw bytes. Set the "content-type" header to `application/snsbx-bytes-ts`. Send measurements as 12 byte sensor Id with most significant byte first followed by 4 byte float measurement in little endian (least significant byte first) notation followed by a 4 byte uint32_t unix timestamp in little endian (least significant byte first) notation. A valid measurement could look like this:<br />[ 0x59, 0x5f, 0x9a, 0x28, 0x2d, 0xcb, 0xee, 0x77, 0xac, 0x0e, 0x5d, 0xc4, 0x9a, 0x99, 0x89, 0x40, 0x34, 0x0c, 0x60, 0x59 ] but encoded as raw bytes. Multiple measurements are just multiple tuples of id, value and timestamp. The number of bytes should be a multiple of 20.
227+
* Submit measurements with timestamp as raw bytes. Set the "content-type" header to `application/sbx-bytes-ts`. Send measurements as 12 byte sensor Id with most significant byte first followed by 4 byte float measurement in little endian (least significant byte first) notation followed by a 4 byte uint32_t unix timestamp in little endian (least significant byte first) notation. A valid measurement could look like this:<br />[ 0x59, 0x5f, 0x9a, 0x28, 0x2d, 0xcb, 0xee, 0x77, 0xac, 0x0e, 0x5d, 0xc4, 0x9a, 0x99, 0x89, 0x40, 0x34, 0x0c, 0x60, 0x59 ] but encoded as raw bytes. Multiple measurements are just multiple tuples of id, value and timestamp. The number of bytes should be a multiple of 20.
228228
*
229229
* For all encodings, the maximum count of values in one request is 2500.
230230
*

packages/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"Norwin Roosen"
1111
],
1212
"dependencies": {
13-
"@sensebox/opensensemap-api-models": "^0.0.12",
13+
"@sensebox/opensensemap-api-models": "^0.0.13",
1414
"@turf/area": "^4.6.0",
1515
"@turf/bbox": "^4.6.0",
1616
"@turf/centroid": "^4.6.1",

packages/models/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
## v0.0.13
6+
- Add BME680 Sensor
7+
- Update @sensebox/node-sketch-templater to v1.5.1
8+
59
## v0.0.12
610
- Update @sensebox/node-sketch-templater to 1.4.0
711
- set lastMeasurementAt on single measruement upload fixes #177

packages/models/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "@sensebox/opensensemap-api-models",
33
"description": "openSenseMap data models and database connection",
4-
"version": "0.0.12",
4+
"version": "0.0.13",
55
"main": "index.js",
66
"license": "MIT",
77
"dependencies": {
88
"@sensebox/osem-protos": "^1.1.0",
9-
"@sensebox/sketch-templater": "^1.4.0",
9+
"@sensebox/sketch-templater": "^1.5.1",
1010
"bcrypt": "^1.0.2",
1111
"bunyan": "^1.8.12",
1212
"config": "^1.29.2",

packages/models/src/box/box.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,10 +800,16 @@ boxSchema.methods.updateSensors = function updateSensors (sensors) {
800800
}
801801
};
802802

803-
boxSchema.methods.getSketch = function getSketch ({ encoding, serialPort, ssid, password } = {}) {
803+
boxSchema.methods.getSketch = function getSketch ({ encoding, serialPort, soilDigitalPort, soundMeterPort, ssid, password } = {}) {
804804
if (serialPort) {
805805
this.serialPort = serialPort;
806806
}
807+
if (soilDigitalPort) {
808+
this.soilDigitalPort = soilDigitalPort;
809+
}
810+
if (soundMeterPort) {
811+
this.soundMeterPort = soundMeterPort;
812+
}
807813

808814
this.ssid = ssid;
809815
this.password = password;

packages/models/src/box/sensorLayouts/sensebox.home.mcu.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ const {
99
tsl45315_lightintensity,
1010
veml6070_uvintensity,
1111
sds011_pm10,
12-
sds011_pm25
12+
sds011_pm25,
13+
bme680_humidity,
14+
bme680_temperature,
15+
bme680_pressure,
16+
bme680_voc,
17+
smt50_soilmoisture,
18+
smt50_soiltemperature,
19+
soundlevelmeter
1320
} = sensorDefinitions;
1421

1522
module.exports = [
@@ -19,5 +26,12 @@ module.exports = [
1926
tsl45315_lightintensity,
2027
veml6070_uvintensity,
2128
sds011_pm10,
22-
sds011_pm25
29+
sds011_pm25,
30+
bme680_humidity,
31+
bme680_temperature,
32+
bme680_pressure,
33+
bme680_voc,
34+
smt50_soilmoisture,
35+
smt50_soiltemperature,
36+
soundlevelmeter
2337
];
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
module.exports = {
4+
title: 'Luftfeuchte',
5+
unit: '%',
6+
sensorType: 'BME680',
7+
icon: 'osem-humidity'
8+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
module.exports = {
4+
title: 'atm. Luftdruck',
5+
unit: 'hPa',
6+
sensorType: 'BME680',
7+
icon: 'osem-barometer'
8+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
module.exports = {
4+
title: 'Lufttemperatur',
5+
unit: '°C',
6+
sensorType: 'BME680',
7+
icon: 'osem-thermometer'
8+
};

0 commit comments

Comments
 (0)