Improvements to Browan Tab Object locator / Tab-all#8
Open
mfalkvidd wants to merge 1 commit intodasdigidings:mainfrom
Open
Improvements to Browan Tab Object locator / Tab-all#8mfalkvidd wants to merge 1 commit intodasdigidings:mainfrom
mfalkvidd wants to merge 1 commit intodasdigidings:mainfrom
Conversation
Add support for * whether the device is charging or not * battery measurement fault * whether the button was pressed * whether the device is moving or stationary * gnssOk (status bit 4: 1 - GNSS error, 0 - GNSS OK) Manuals: * https://www.browan.com/download/DBk/stream * https://www.thethingsnetwork.org/forum/uploads/short-url/pyAskbn2PnxI1eG3vHOED9Mckki.pdf * https://iot-shop.de/web/content/8056?access_token=df74376f-a349-4e91-98e8-10588ed91e0f&unique=undefined&download=true * https://trello-attachments.s3.amazonaws.com/5d7a8b1edb90646852c8e5c0/5d855fe8c619611862b35b09/dd5ca770e27d82a34bc4d1c9cb5068b2/RM_Object_Locator(S)_20200706_(BQW_02_0021.pdf
Wlanfr3ak
reviewed
Aug 17, 2023
There was a problem hiding this comment.
For me its only working with removed 3 lines from your PR with this code AND remove position from the data fields to let ttn understand its the location from the device and for ttnmapper!:
`
function decodeUplink(input) {
var data = {
"bytes": input.bytes, // original payload
"port" : input.fPort // lorawan port
};
var batteryStatus = input.bytes[1];
switch(batteryStatus){
case 0:
data.charging = true;
data.batteryFault = false;
break;
case 255:
data.batteryFault = true;
break;
default:
data.charging = false;
data.batteryFault = false;
battery = input.bytes[1] & 0x0f;
battery = (25 + battery) / 10;
data.battery = battery;
capacity = input.bytes[1] >> 4;
capacity = (capacity / 15) * 100;
data.capacity = capacity;
}
temperature = input.bytes[2] & 0x7f;
temperature = temperature - 32;
data.temperature = temperature;
if (input.fPort === 100) { // Door & Window Sensor
openingStatusTime = (input.bytes[4] << 8) | input.bytes[3];
openingStatusCount = ((input.bytes[7] << 16) | (input.bytes[6] << 8)) | input.bytes[5];
openingStatus = input.bytes[0] & 0x1;
if (openingStatus === 1) {
openingStatusOpen = true;
} else {
openingStatusOpen = false;
}
data.openingStatusTime = openingStatusTime;
data.openingStatusCount = openingStatusCount;
data.openingStatusOpen = openingStatusOpen;
}
else if (input.fPort === 136) { // Object Locator
if ((input.bytes[0] & 0x8) === 0) {
positionGnssFix = true;
} else {
positionGnssFix = false;
}
positionAccuracy = input.bytes[10] >> 5;
positionAccuracy = Math.pow(2, parseInt(positionAccuracy) + 2);
input.bytes[10] &= 0x1f;
if ((input.bytes[10] & (1 << 4)) !== 0) {
input.bytes[10] |= 0xe0;
}
input.bytes[6] &= 0x0f;
positionLatitude = ((input.bytes[6] << 24 | input.bytes[5] << 16) | input.bytes[4] << 8 ) | input.bytes[3];
positionLongitude = ((input.bytes[10] << 24 | input.bytes[9] << 16) | input.bytes[8] << 8 ) | input.bytes[7];
positionLatitude = positionLatitude / 1000000;
positionLongitude = positionLongitude / 1000000;
data.gnssfix = positionGnssFix;
data.latitude = positionLatitude;
data.longitude = positionLongitude;
data.accuracy = positionAccuracy;
}
return {
data: data,
warnings: [],
errors: []
};
}`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for
Manuals: