Receiving data from console.thethingsnetwork.org, nothing coming in?


#1

I while ago I was toying around on staging.thethingsnetwork.org, sending some temperature readings over TTN. Everything worked great after some fiddling and I was able to poll for the data with a piece of nodejs script.

Today I tried the same thing, but this time using console.thethingsnetwork.org. I'm still able to send messages, and see the data coming in on console.thethingsnetwork.org, but I seem to be unable to poll for the data.

Even when I just use the simplest piece if code, it seems like it never gets triggered:

var ttn = require('ttn');
var appEUI = 'xxx';
var accessKey = 'yyy';
var client = new ttn.Client('console.thethingsnetwork.org', appEUI, accessKey);

client.on('uplink', function (msg) {
  console.log('Received message', msg);
});

client.on('activation', function (msg) {
  console.log('Device activated:', msg.devEUI);
});

I can't imagine there's anything wrong with the code, so I'm guessing there is some kind of setting in the console I'm overlooking. Any ideas where I'm going wrong?


(Arjan) #2

Which version of the library are you using? Your code seems to be outdated.

Please add some error reporting:

client.on('error', function(err) {
  console.error('[ERROR]', err.message);
});

Also, it seems you're missing the region when connecting, and I doubt appId is the same as AppEUI:

var client = new ttn.Client(region, appId, accessKey);

See the example for much more logging, as linked from the README.


#3

Thanks Arjan, seems like I was indeed working with a outdated example. replacing appEUI with the appId and adding the region was all I needed to do to get it back working again.


(Arjan) #4

I'd still add the error logging :slight_smile:


#5

I will :slight_smile:


(Jacklin) #6

Hi Eric & Arjan

I used code below but the result is different from the normal.

var ttn = require('ttn');
var region = 'asia-se.thethings.network';
var appId = '<redacted>';
var accessKey = '<redacted>';
var client = new ttn.Client(region, appId, accessKey);

client.on('message', function(deviceId, data) {
  console.info('[INFO] ', 'Message:', deviceId, JSON.stringify(data, null, 2));
});

The code above won't show any message from my node,
but when I replace the 'message' with 'uplink' as v.1 setting in staging,
it will show some information of port and packet counter, but the fields & metadata will show ''undefined'' .

client.on('uplink', function(deviceId, data) {
  console.info('[INFO] ', 'Message:', deviceId, JSON.stringify(data, null, 2));
});

Any setting where I'm wrong?
please kindly advise it. Thank you


(Arjan) #7

@jacklin, I'd guess you're using an old version of the library. Also, be sure to add client.on('error', ...).