Skip to content

Commit

Permalink
Add: setting to ignore unknown device-telegrams (closes #11)
Browse files Browse the repository at this point in the history
  • Loading branch information
psi-4ward committed May 19, 2020
1 parent 8c17826 commit 8954fc5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/interfaces/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export interface Config {
}
},
_began: number | null,
dropUnkownDevices: boolean,
}
5 changes: 5 additions & 0 deletions app/src/SnifferParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {Transform, TransformOptions} from 'stream';
import devList from './deviceList';
import {Device} from "../interfaces/Device";
import {Telegram} from "../interfaces/Telegram";
import store from "./store";

const strPosBeginnings = {
rssi: 1,
Expand Down Expand Up @@ -81,6 +82,10 @@ export default class SnifferParser extends Transform {
const fromDev = getDevice(fromAddr);
const toDev = getDevice(toAddr);

if(store.getConfig('dropUnkownDevices') && !fromDev && !toDev) {
return callback();
}

const telegram: Telegram = {
tstamp: Date.now(),
rssi: -1 * parseInt(line.substr(1, 2), 16),
Expand Down
3 changes: 2 additions & 1 deletion app/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class Store {
url: 'http://raspberrymatic:8181/a.exe?r=dom.GetObject("AskSinAnalyzerAlarm").State(true)'
}
},
_began: null
_began: null,
dropUnkownDevices: false,
};

appPath: string = path.resolve(__dirname, '..');
Expand Down
1 change: 1 addition & 0 deletions ui/src/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default class Service {
latestVersion: null,
devlistCreated: null,
liveData: true,
dropUnkownDevices: false,
};
rssiLog = [];
ws = null;
Expand Down
9 changes: 9 additions & 0 deletions ui/src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@
Animationen benötigen zusätzliche Rechenleistung.
</div>
</div>
<q-toggle
v-model="cfg.dropUnkownDevices"
label="Nur bekannte Geräte anzeigen"
/>
<div class="q-field__bottom" style="margin-top: 0; padding-top: 0">
<div class="q-field__messages">
Es werden nur Telegramme verarbeitet, wenn der Sender oder Empfänger durch die Device-Liste zugeordnet werden kann.
</div>
</div>
</q-card-section>
</q-card>
</div>
Expand Down

0 comments on commit 8954fc5

Please sign in to comment.