Browan Object Locator and payload formatter

Hi everyone,

has anyone managed to do an uplink payload formatter on TTN for the Browan Object Locator?

I have used this but I am not getting correct location information:

function Decoder(bytes, port) {
var params = {
“bytes”: bytes
};
bytes = bytes.slice(bytes.length-11);
if ((bytes[0] & 0x8) === 0) {
params.gnss_fix = true;
} else {
params.gnss_fix = false;
}
// Mask off enf of temp byte, RFU
temp = bytes[2] & 0x7f;
acc = bytes[10] >> 5;
acc = Math.pow(2, parseInt(acc) + 2);
// Mask off end of accuracy byte, so lon doesn’t get affected
bytes[10] &= 0x1f;
if ((bytes[10] & (1 << 4)) !== 0) {
bytes[10] |= 0xe0;
}
// Mask off end of lat byte, RFU
bytes[6] &= 0x0f;
lat = bytes[6] << 24 | bytes[5] << 16 | bytes[4] << 8 | bytes[3];
lon = bytes[10] << 24 | bytes[9] << 16 | bytes[8] << 8 | bytes[7];
battery = bytes[1];
capacity = battery >> 4;
voltage = battery & 0x0f;
params.latitude = lat/1000000;
params.longitude = lon/1000000;
params.accuracy = acc;
params.temperature = temp - 32;
params.capacity = (capacity / 15) * 100;
params.voltage = (25 + voltage)/10;
params.port=port;
return params;
}

Hi, Did you manage to get the browan object locater installed? (Interrested because I just bought one and is on it’s way. I am now preparing on how to get it added to ttn)

Were you ever able to get an uplink formatter to work? I’ve been unsuccessful as well.

Are they not GNSS devices? So then you need a GNSS solver.

Have you tried

https://github.com/dasdigidings/the_things_stack_v3_tabs_decoder
1 Like

Try this:

function Decoder(bytes, port) {
    // Initialize params object with bytes
    var params = {
        "bytes": bytes
    };
    
    // Slice the last 11 bytes from the array
    bytes = bytes.slice(bytes.length - 11);
    
    // Check GNSS fix status
    if ((bytes[0] & 0x8) === 0) {
        params.gnss_fix = true;
    } else {
        params.gnss_fix = false;
    }

    // Extract and mask temperature byte
    var temp = bytes[2] & 0x7f;

    // Extract and compute accuracy
    var acc = bytes[10] >> 5;
    acc = Math.pow(2, parseInt(acc) + 2);

    // Mask off end of accuracy byte, so lon doesn’t get affected
    bytes[10] &= 0x1f;
    if ((bytes[10] & (1 << 4)) !== 0) {
        bytes[10] |= 0xe0;
    }

    // Mask off end of latitude byte
    bytes[6] &= 0x0f;

    // Combine bytes to form latitude and longitude
    var lat = (bytes[6] << 24) | (bytes[5] << 16) | (bytes[4] << 8) | bytes[3];
    var lon = (bytes[10] << 24) | (bytes[9] << 16) | (bytes[8] << 8) | bytes[7];

    // Extract battery information
    var battery = bytes[1];
    var capacity = battery >> 4;
    var voltage = battery & 0x0f;

    // Populate params with extracted and computed values
    params.latitude = lat / 1000000;
    params.longitude = lon / 1000000;
    params.accuracy = acc;
    params.temperature = temp - 32;
    params.capacity = (capacity / 15) * 100;
    params.voltage = (25 + voltage) / 10;
    params.port = port;

    // Return the final params object
    return params;
}