From bd4f83beabd3d8aeaa213eadb9c1181f9e31a7d4 Mon Sep 17 00:00:00 2001 From: Walter Domenico Vergara Date: Fri, 16 Feb 2024 16:43:23 +0100 Subject: [PATCH] fix on data types --- lib/commonBindings.js | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/lib/commonBindings.js b/lib/commonBindings.js index 684d96bf..4d7d8f07 100644 --- a/lib/commonBindings.js +++ b/lib/commonBindings.js @@ -57,19 +57,13 @@ function parseMessage(message) { parsedMessage = message.toString(16); } config.getLogger().debug(context, 'stringMessage: [%s] parsedMessage: [%s]', stringMessage, parsedMessage); - messageArray = []; - if (Array.isArray(parsedMessage)) { - messageArray = parsedMessage; - } else { - messageArray.push(parsedMessage); - } /* istanbul ignore if */ if (parsedMessageError) { config.getLogger().error(context, 'MEASURES-003: Impossible to handle malformed message: %s', message); } config.getLogger().debug(context, 'parserMessage array: %s', messageArray); - return messageArray; + return parsedMessage; } /** @@ -95,20 +89,6 @@ function guessType(attribute, device) { return constants.DEFAULT_ATTRIBUTE_TYPE; } -function extractAttributes(device, current) { - const values = []; - for (const k in current) { - if (current.hasOwnProperty(k)) { - values.push({ - name: k, - type: guessType(k, device), - value: current[k] - }); - } - } - return values; -} - /* istanbul ignore next */ function sendConfigurationToDevice(device, apiKey, deviceId, results, callback) { transportSelector.applyFunctionFromBinding([apiKey, deviceId, results], 'sendConfigurationToDevice', device.transport || config.getConfig().defaultTransport, callback); @@ -158,7 +138,7 @@ function singleMeasure(apiKey, deviceId, attribute, device, parsedMessage) { { name: attribute, type: messageType, - value: messageType === constants.OPCUA_NGSI_BINDING_STRING ? JSON.stringify(parsedMessage) : parsedMessage[0] + value: parsedMessage } ]; config.getLogger().debug(context, 'values updates [%s]', JSON.stringify(values)); @@ -302,5 +282,4 @@ function opcuaMessageHandler(deviceId, mapping, variableValue, timestamp) { exports.opcuaMessageHandler = opcuaMessageHandler; exports.messageHandler = messageHandler; -exports.extractAttributes = extractAttributes; exports.guessType = guessType;