Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions configuration/chirpstack/adr-modules/sensade-adr-mod/sensade-adr.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,27 @@ export function id() {
// txPowerIndex: 1,
// nbTrans: 1
// }

// Handle function for ADR request.
export function handle(req) {
// This defines the default response, which is equal to the current device state.
let resp = {
dr: req.DR,
txPowerIndex: req.TxPowerIndex,
nbTrans: req.NbTrans,
dr: req.dr,
txPowerIndex: 0,
nbTrans: req.nbTrans,
};

resp.txPowerIndex = 0;

// If ADR is disabled, return with current values.
if (!req.ADR) {
return [resp, null];
if (!req.adr) {
return resp;
}

let lostPackageCnt = getLostPackageCount(req);
// If 5 or more packages are lost during the last received packages, decrease the data-rate
if (lostPackageCnt >= 5) {
resp.dr -= 1;
} else if (
req.UplinkHistory.length === 20 &&
req.uplinkHistory.length >= 20 &&
getLostPackageCount(req, 20) <= 2
) {
// If 2 or fewer packages are lost during the last 20 received packages, the dr might be able to be increased
Expand All @@ -78,7 +77,7 @@ export function handle(req) {
// A margin of around 10 seems okay
// This value has been chosen based on the loRaSNR values from sensors installed in a parking lot,
// where a fluctuation of +- 10 can be seen (should be caused by cars parking and leaving).
let diffSNR = minSNR - req.requiredHistoryCount - installationMargin;
let diffSNR = minSNR - req.requiredSnrForDr - installationMargin;

// Examples:
// minSNR = -5
Expand All @@ -104,11 +103,11 @@ export function handle(req) {
resp.dr = req.maxDr;
}

if (req.MinDR > resp.dr) {
resp.dr = req.MinDR;
if (req.minDr > resp.dr) {
resp.dr = req.minDr;
}

return [resp, null];
return resp;
}

function getMinSNR(req) {
Expand Down Expand Up @@ -144,12 +143,12 @@ function getLostPackageCount(req, ...lastXElement) {
const m = elements[i];

if (i === 0) {
previousFCnt = m.FCnt;
previousFCnt = m.fCnt;
continue;
}

lostPackets += m.FCnt - previousFCnt - 1; // there is always an expected difference of 1
previousFCnt = m.FCnt;
lostPackets += m.fCnt - previousFCnt - 1; // there is always an expected difference of 1
previousFCnt = m.fCnt;
}

return lostPackets;
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ services:
- pg-data:/var/lib/postgresql:Z

os2iot-zookeeper:
image: "bitnami/zookeeper:latest"
image: "bitnamilegacy/zookeeper:latest"
ports:
- "2181:2181"
environment:
Expand All @@ -156,7 +156,7 @@ services:
tmpfs: "/datalog"

os2iot-kafka:
image: "bitnami/kafka:latest"
image: "bitnamilegacy/kafka:3"
ports:
- "9092:9092"
- "9093:9093"
Expand Down
2 changes: 2 additions & 0 deletions mosquitto-broker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ RUN git clone https://github.com/iegomez/mosquitto-go-auth.git

WORKDIR /home/mosquitto-go-auth

RUN git checkout tags/2.1.0

RUN make

WORKDIR /etc/mosquitto/conf.d
Expand Down
3 changes: 2 additions & 1 deletion simulator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ RUN apt-get update && apt-get install git -y
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install golang -y
RUN apt-get install golang-statik -y

RUN apt-get install ca-certificates -y

RUN git clone --branch v1.0.2 https://github.com/UniCT-ARSLab/LWN-Simulator.git
RUN git clone https://github.com/UniCT-ARSLab/LWN-Simulator.git

WORKDIR /LWN-Simulator

Expand Down