Where can I find the server name in the event that I am not using EU868?
In the documentation that I already linked to above. (And sorry, I am out of here, this is too annoying for me. Success.)
WHAT???
Both device ID queries of dl-pr26_5100
and 5100
produce not response.
I was able to get access to the decoder.
var decentlab_decoder = {
PROTOCOL_VERSION: 2,
/* device-specific parameters */
PARAMETERS: {
Pmin: 0.0,
Pmax: 1.0
},
SENSORS: [
{length: 2,
values: [{name: 'pressure',
displayName: 'Pressure',
convert: function (x) { return (x[0] - 16384) / 32768 * (this.PARAMETERS.Pmax - this.PARAMETERS.Pmin) + this.PARAMETERS.Pmin; },
unit: 'bar'},
{name: 'temperature',
displayName: 'Temperature',
convert: function (x) { return (x[1] - 384) * 0.003125 - 50; },
unit: '°C'}]},
{length: 1,
values: [{name: 'battery_voltage',
displayName: 'Battery voltage',
convert: function (x) { return x[0] / 1000; },
unit: 'V'}]}
],
read_int: function (bytes, pos) {
return (bytes[pos] << 8) + bytes[pos + 1];
},
decode: function (msg) {
var bytes = msg;
var i, j;
if (typeof msg === 'string') {
bytes = [];
for (i = 0; i < msg.length; i += 2) {
bytes.push(parseInt(msg.substring(i, i + 2), 16));
}
}
var version = bytes[0];
if (version != this.PROTOCOL_VERSION) {
return {error: "protocol version " + version + " doesn't match v2"};
}
var deviceId = this.read_int(bytes, 1);
var flags = this.read_int(bytes, 3);
var result = {'protocol_version': version, 'device_id': deviceId};
// decode payload
var pos = 5;
for (i = 0; i < this.SENSORS.length; i++, flags >>= 1) {
if ((flags & 1) !== 1)
continue;
var sensor = this.SENSORS[i];
var x = [];
// convert data to 16-bit integer array
for (j = 0; j < sensor.length; j++) {
x.push(this.read_int(bytes, pos));
pos += 2;
}
// decode sensor values
for (j = 0; j < sensor.values.length; j++) {
var value = sensor.values[j];
if ('convert' in value) {
result[value.name] = {displayName: value.displayName,
value: value.convert.bind(this)(x),
unit: value.unit};
}
}
}
return result;
}
};
function Decoder(bytes, port) {
return decentlab_decoder.decode(bytes);
}
Thanks!
I suspect I know what the answer is, but given you lack of success so far, I think this is the best course of action.
Can you get the decoder removed for a while so the Data Storage just gets the raw data, un-affected by the JS decoder.
Removing the decoder produce a response for the device specific endpoint!
Request URL
https://ruchir_dl-pr-26_5100.data.thethingsnetwork.org/api/v2/query/dl-pr26_5100
Response Body
[
{
"device_id": "dl-pr26_5100",
"raw": "AhPsAANDw1MrCrU=",
"time": "2020-10-21T01:39:39.964664347Z"
},
{
"device_id": "dl-pr26_5100",
"raw": "AhPsAANDw1MiCrM=",
"time": "2020-10-21T01:49:40.710677116Z"
},
...
]
Any chance your payload format decoder is outputting an attribute called
device_id
?
You could also use the access key youâve got for the Storage Integration, to subscribe to the uplink data using an MQTT client . That will show you what is in the JSON attribute
payload_fields
. (And Iâm quite sure youâll see a fielddevice_id
that confuses the Data Storage query.)
var result = {'protocol_version': version, 'device_id': deviceId};
Since yesterday, the decoderâs README also states:
The decoders may output nested objects, which are stored as text in the TTN Data Storage integration.
The decoders may output a field named
device_id
, which may prohobit per-device querying in the TTN Data Storage integration.
Which means there is an error in the decoder.
So this thread can be closed and you can figure out the decoderâs problem.