TheThingsArchive / integration-azure

Microsoft Azure IoT Hub Integration for TTN Applications
MIT License
9 stars 10 forks source link

Receiving a message result in an exception. New message structure not implemented yet? #14

Closed sandervandevelde closed 7 years ago

sandervandevelde commented 7 years ago

I installed the integration using

npm install --save ttn-azure-iothub

And I added

const options = {};
options.ttnBroker = 'eu.thethings.network';
const bridge = new ttnazureiot.Bridge(appEUI, appAccessKey, hubName, keyName, key, options);

The bridge connects and messages are received. But upon receiving, I get this error:

predictive_maintenance_machine_42: Handling uplink
predictive_maintenance_machine_42: Could not get device: TypeError: Cannot read property 'server_time' of undefined
Error TypeError: Cannot read property 'server_time' of undefined
    at Bridge._createMessage (C:\bridge\node_modules\ttn-azure-iothub\index.js:23:30)
    at _getDevice.then.deviceInfo (C:\bridge\node_modules\ttn-azure-iothub\index.js:81:43)
    at process._tickCallback (internal/process/next_tick.js:103:7)

It seems the message is not parsed correctly. Does this have to do with changes in the message structure in production?

Regards,

Sander

johanstokking commented 7 years ago

Yes. This now time

johanstokking commented 7 years ago

It's fixed already but it requires a publish to npm (see https://github.com/TheThingsNetwork/integration-azure/blob/master/index.js#L22)

sandervandevelde commented 7 years ago

It seems the issue is not server_time or time, but the undefined metadata in:

time: message.metadata.time,

I commented out the whole line and I got no exception anymore.

Would love to see a new publish. Is downlink supported too? Current version does not seem to pass them

johanstokking commented 7 years ago

Should be fixed in https://github.com/TheThingsNetwork/integration-azure/commit/bc605a88f450c1417e1eaada2b333b278af880c1. Can you check?

ttn-azure-iothub@2.0.0 has been published to npm

sandervandevelde commented 7 years ago

Hoi Johan, it works. The telemetry is passed without any error. Thanks. But downlink doesn't seem to be supported, or does it?

johanstokking commented 7 years ago

Great. Let's talk in #15