Skip to content

Commit

Permalink
update CNR
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroVega committed Nov 7, 2023
1 parent 888bdf2 commit 3bcfdf3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Add: allow to send NGSIv2 and NGSILD as measures depending on payloadType (#778)
- Fix: binary data representation when sending data through HTTP & MQTT (#690)
- Fix: ensure service and subservice from device in logs about error proccesing message
- Remove: legacy code about unused parsedMessageError flag
2 changes: 1 addition & 1 deletion lib/bindings/HTTPBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function handleIncomingMeasure(req, res, next) {
for (const i in payloadDataArr) {
values = commonBindings.extractAttributes(device, payloadDataArr[i], device.payloadType);
if (values[0][0]) {
// Check multimeasure from a ngsiv2 entities array
// Check multimeasure from a ngsiv2/ngsild entities array
attributeArr = attributeArr.concat(values);
} else {
attributeArr.push(values);
Expand Down
8 changes: 4 additions & 4 deletions lib/commonBindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ function extractAttributes(device, current, payloadType) {
let values = [];

const ctxt = fillService(context, device);
config.getLogger().debug(ctxt, 'extractAttributes NGSIV2 current %j payloadType %j', current, payloadType);
config.getLogger().debug(ctxt, 'extractAttributes current %j payloadType %j', current, payloadType);

if (payloadType === constants.PAYLOAD_NGSIv2 || payloadType === constants.PAYLOAD_NGSILD) {
if (payloadType && [constants.PAYLOAD_NGSIv2, constants.PAYLOAD_NGSILD].includes(payloadType.toLowerCase())) {
let arrayEntities = [];
if (current.hasOwnProperty('actionType') && current.hasOwnProperty('entities')) {
arrayEntities = current['entities'];
Expand All @@ -110,14 +110,14 @@ function extractAttributes(device, current, payloadType) {
for (const k in entity) {
// skip id and type
if (entity.hasOwnProperty(k) && !['id', 'type'].includes(k)) {
if (payloadType === constants.PAYLOAD_NGSIv2) {
if (payloadType.toLowerCase() === constants.PAYLOAD_NGSIv2) {
valuesEntity.push({
name: k,
type: entity[k].type,
value: entity[k].value,
metadata: entity[k].metadata ? entity[k].metadata : undefined
});
} else if (payloadType === constants.PAYLOAD_NGSILD) {
} else if (payloadType.toLowerCase() === constants.PAYLOAD_NGSILD) {
if (k === '@context') {
valuesEntity.push({
name: k,
Expand Down

0 comments on commit 3bcfdf3

Please sign in to comment.