Skip to content

Commit 2b0c300

Browse files
author
Eric Thieme-Garmann
committed
allow serial port specification
1 parent 1b648f3 commit 2b0c300

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

packages/api/lib/controllers/boxesController.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,10 @@ const getSketch = async function getSketch (req, res) {
556556
lean: false,
557557
});
558558

559+
559560
const params = {
560-
serialPort: req._userParams.serialPort,
561+
sdsSerialPort: req._userParams.sdsSerialPort,
562+
rg15SerialPort: req._userParams.rg15SerialPort,
561563
soilDigitalPort: req._userParams.soilDigitalPort,
562564
soundMeterPort: req._userParams.soundMeterPort,
563565
windSpeedPort: req._userParams.windSpeedPort,
@@ -569,6 +571,8 @@ const getSketch = async function getSketch (req, res) {
569571
display_enabled: req._userParams.display_enabled,
570572
};
571573

574+
575+
572576
// pass access token only if useAuth is true and access_token is available
573577
if (box.access_token) {
574578
params.access_token = box.access_token;
@@ -782,7 +786,12 @@ module.exports = {
782786
retrieveParameters([
783787
{ predef: 'boxId', required: true },
784788
{
785-
name: 'serialPort',
789+
name: 'sdsSerialPort',
790+
dataType: 'String',
791+
allowedValues: ['Serial1', 'Serial2'],
792+
},
793+
{
794+
name: 'rg15SerialPort',
786795
dataType: 'String',
787796
allowedValues: ['Serial1', 'Serial2'],
788797
},

packages/models/src/box/box.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -881,9 +881,12 @@ boxSchema.methods.updateSensors = function updateSensors (sensors) {
881881
}
882882
};
883883

884-
boxSchema.methods.getSketch = function getSketch ({ encoding, serialPort, soilDigitalPort, soundMeterPort, windSpeedPort, ssid, password, devEUI, appEUI, appKey, access_token, display_enabled } = {}) {
885-
if (serialPort) {
886-
this.serialPort = serialPort;
884+
boxSchema.methods.getSketch = function getSketch ({ encoding, sdsSerialPort,rg15SerialPort, soilDigitalPort, soundMeterPort, windSpeedPort, ssid, password, devEUI, appEUI, appKey, access_token, display_enabled } = {}) {
885+
if (sdsSerialPort) {
886+
this.sdsSerialPort = sdsSerialPort;
887+
}
888+
if (rg15SerialPort) {
889+
this.rg15SerialPort = rg15SerialPort;
887890
}
888891
if (soilDigitalPort) {
889892
this.soilDigitalPort = soilDigitalPort;

0 commit comments

Comments
 (0)