Skip to content

Commit

Permalink
feat: device EUI is passed when using configuration provisioning (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcalvoalonso committed Feb 18, 2019
1 parent affc32b commit c0109b0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/applicationServers/ttnAppService.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,17 @@ class TtnAppService extends appService.AbstractAppService {
var dataModel = this.getDataModel(deviceId, null);

if (message) {
var deviceEui;
if (message['hardware_serial']) {
deviceEui = message['hardware_serial'];
}

if (dataModel === 'application_server' && message['payload_fields']) {
this.messageHandler(this, deviceId, null, message['payload_fields']);
this.messageHandler(this, deviceId, deviceEui, message['payload_fields']);
} else if (message['payload_raw']) {
this.messageHandler(this, deviceId, null, message['payload_raw']);
this.messageHandler(this, deviceId, deviceEui, message['payload_raw']);
} else {
this.messageHandler(this, deviceId, null, null);
this.messageHandler(this, deviceId, deviceEui, null);
}
} else {
this.messageHandler(this, deviceId, null, null);
Expand Down
7 changes: 7 additions & 0 deletions test/unit/groupProvisioningLoRaServerIo.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ describe('Configuration provisioning API: Provision groups', function() {
body.devices.should.be.an('array');
body.devices.should.have.length(1);
body.devices[0].should.have.property('device_id', devId);
body.devices[0].should.have.property('internal_attributes');
body.devices[0].internal_attributes.should.be.an('array');
body.devices[0].internal_attributes.should.have.length(1);
body.devices[0].internal_attributes[0].should.be.an('object');
body.devices[0].internal_attributes[0].should.have.property('lorawan');
body.devices[0].internal_attributes[0].lorawan.should.be.an('object');
body.devices[0].internal_attributes[0].lorawan.should.have.property('dev_eui', '3339343752356A14');
done();
});
});
Expand Down
7 changes: 7 additions & 0 deletions test/unit/groupProvisioningTTN.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ describe('Configuration provisioning API: Provision groups', function() {
body.devices.should.be.an('array');
body.devices.should.have.length(1);
body.devices[0].should.have.property('device_id', devId);
body.devices[0].should.have.property('internal_attributes');
body.devices[0].internal_attributes.should.be.an('array');
body.devices[0].internal_attributes.should.have.length(1);
body.devices[0].internal_attributes[0].should.be.an('object');
body.devices[0].internal_attributes[0].should.have.property('lorawan');
body.devices[0].internal_attributes[0].lorawan.should.be.an('object');
body.devices[0].internal_attributes[0].lorawan.should.have.property('dev_eui', '3339343771356214');
done();
});
});
Expand Down

0 comments on commit c0109b0

Please sign in to comment.