Skip to content

Commit

Permalink
remove transport
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroVega committed Dec 15, 2023
1 parent b1447a4 commit ace7653
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
13 changes: 5 additions & 8 deletions lib/bindings/HTTPBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ function handleIncomingMeasure(req, res, next) {
}
}

iotaUtils.retrieveDevice(req.deviceId, req.apiKey, transport, processDeviceMeasure);
iotaUtils.retrieveDevice(req.deviceId, req.apiKey, processDeviceMeasure);
}

function isCommand(req, res, next) {
Expand Down Expand Up @@ -448,10 +448,7 @@ function sendConfigurationToDevice(apiKey, group, deviceId, results, callback) {

request(resultRequest, handleDeviceResponse(innerCallback));
}
iotaUtils.retrieveDevice(deviceId, apiKey, group ? group.transport : undefined || transport, function (
error,
device
) {
iotaUtils.retrieveDevice(deviceId, apiKey, function (error, device) {
if (error) {
callback(error);
} else if (!device.endpoint) {
Expand All @@ -470,7 +467,7 @@ function handleConfigurationRequest(req, res, next) {
res.status(200).json({});
}
}
iotaUtils.retrieveDevice(req.deviceId, req.apiKey, transport, function (error, device) {
iotaUtils.retrieveDevice(req.deviceId, req.apiKey, function (error, device) {
if (error) {
next(error);
} else {
Expand Down Expand Up @@ -531,7 +528,7 @@ function setPollingAndDefaultTransport(device, group, callback) {
*/
function deviceProvisioningHandler(device, callback) {
config.getLogger().debug(context, 'httpbinding.deviceProvisioningHandler device %j', device);
let group;
let group = {};
iotAgentLib.getConfigurationSilently(config.getConfig().iota.defaultResource || '', device.apikey, function (
error,
foundGroup
Expand All @@ -551,7 +548,7 @@ function deviceProvisioningHandler(device, callback) {
*/
function deviceUpdatingHandler(device, callback) {
config.getLogger().debug(context, 'httpbinding.deviceUpdatingHandler device %j', device);
let group;
let group = {};
iotAgentLib.getConfigurationSilently(config.getConfig().iota.defaultResource || '', device.apikey, function (
error,
foundGroup
Expand Down
2 changes: 1 addition & 1 deletion lib/commonBindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ function messageHandler(topic, message, protocol) {
}

iotAgentLib.alarms.release(constants.MQTTB_ALARM);
iotaUtils.retrieveDevice(deviceId, apiKey, protocol, processDeviceMeasure);
iotaUtils.retrieveDevice(deviceId, apiKey, processDeviceMeasure);
}

/**
Expand Down
14 changes: 3 additions & 11 deletions lib/iotaUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function createConfigurationNotification(results) {
return configurations;
}

function findOrCreate(deviceId, transport, apikey, group, callback) {
function findOrCreate(deviceId, apikey, group, callback) {
iotAgentLib.getDeviceSilently(deviceId, apikey, group.service, group.subservice, function (error, device) {
if (!error && device) {
if (
Expand Down Expand Up @@ -171,14 +171,6 @@ function findOrCreate(deviceId, transport, apikey, group, callback) {
) {
newDevice.protocol = config.getConfig().iota.iotManager.protocol;
}
// // Fix transport depending on binding and group
// if (!newDevice.transport) {
// if ('transport' in group && group.transport !== undefined) {
// newDevice.transport = group.transport;
// } else {
// newDevice.transport = transport;
// }
// }
if ('ngsiVersion' in group && group.ngsiVersion !== undefined) {
newDevice.ngsiVersion = group.ngsiVersion;
}
Expand Down Expand Up @@ -221,7 +213,7 @@ function findOrCreate(deviceId, transport, apikey, group, callback) {
* @param {String} deviceId Device ID of the device that wants to be retrieved or created.
* @param {String} apiKey APIKey of the Device Group (or default APIKey).
*/
function retrieveDevice(deviceId, apiKey, transport, callback) {
function retrieveDevice(deviceId, apiKey, callback) {
if (apiKey === config.getConfig().defaultKey) {
iotAgentLib.getDevicesByAttribute('id', deviceId, null, null, function (error, devices) {
if (error) {
Expand All @@ -245,7 +237,7 @@ function retrieveDevice(deviceId, apiKey, transport, callback) {
async.waterfall(
[
apply(iotAgentLib.getConfigurationSilently, config.getConfig().iota.defaultResource || '', apiKey),
apply(findOrCreate, deviceId, transport, apiKey), // group.apikey and apikey are the same
apply(findOrCreate, deviceId, apiKey), // group.apikey and apikey are the same
apply(
iotAgentLib.mergeDeviceWithConfiguration,
['lazy', 'active', 'staticAttributes', 'commands', 'subscriptions'],
Expand Down
2 changes: 1 addition & 1 deletion lib/iotagent-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const config = require('./configService');
*/
function configurationNotificationHandler(device, updates, callback) {
function invokeConfiguration(apiKey, callback) {
let group;
let group = {};
iotAgentLib.getConfigurationSilently(config.getConfig().iota.defaultResource || '', apiKey, function (
error,
foundGroup
Expand Down

0 comments on commit ace7653

Please sign in to comment.