Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prelanding/fix binary data #760

Merged
merged 17 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
- 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
- Remove: legacy code about unused parsedMessageError flag
4 changes: 2 additions & 2 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ This product is a FIWARE Generic Enabler. If you would like to learn about the o

### Introduction

This IoT Agent uses the [FIWARE IoT Agent Node.js Library](https://github.com/telefonicaid/iotagent-node-lib) framework.
This is why most of the functionalities of this component depend on the new features of the library itself.
This IoT Agent uses the [FIWARE IoT Agent Node.js Library](https://github.com/telefonicaid/iotagent-node-lib) framework.
This is why most of the functionalities of this component depend on the new features of the library itself.

For this reason, the roadmap of this component would be defined by the IoT Agent Node Library Roadmap that you can check
[here](https://github.com/telefonicaid/iotagent-node-lib/blob/master/doc/roadmap.md)
5 changes: 4 additions & 1 deletion lib/bindings/HTTPBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ function parseData(req, res, next) {
next(error);
} else {
req.jsonPayload = data;
mapedraza marked this conversation as resolved.
Show resolved Hide resolved

if (req.body !== undefined ) {
data = data.toString('hex');
}
config.getLogger().debug(context, 'Parsed data: [%j]', data);
next();
}
Expand Down Expand Up @@ -290,6 +292,7 @@ function handleIncomingMeasure(req, res, next) {

if (req.attr && req.jsonPayload) {
config.getLogger().debug(context, 'Parsing attr [%s] with value [%s]', req.attr, req.jsonPayload);
req.jsonPayload = req.jsonPayload.toString('hex');
const theAttr = [{ name: req.attr, value: req.jsonPayload, type: 'None' }];
attributeArr.push(theAttr);
} else {
Expand Down
20 changes: 20 additions & 0 deletions test/unit/ngsiv2/MQTT_receive_measures-test2.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,24 @@ describe('MQTT: Measure reception ', function () {
});
});
});
describe('When a POST single Raw measure arrives for the HTTP binding', function () {
beforeEach(function () {
contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post(
'/v2/entities?options=upsert',
utils.readExampleFile('./test/unit/ngsiv2/contextRequests/singleMeasuresRawTypes1.json')
)
.reply(204);
});
it('should send its value to the Context Broker', function (done) {
mqttClient.publish('/1234/MQTT_2/attrs/humidity', 'A$Ci1', null, function (error) {
setTimeout(function () {
contextBrokerMock.done();
done();
}, 100);
});
});
});
});
8 changes: 1 addition & 7 deletions test/unit/ngsiv2/contextRequests/singleMeasuresRawTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
"type":"AnMQTTDevice",
"humidity":{
"type": "degrees",
"value": {
"type": "Buffer",
"data": [
51,
50
]
}
"value": "3332"
}
}
8 changes: 8 additions & 0 deletions test/unit/ngsiv2/contextRequests/singleMeasuresRawTypes1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id":"Second MQTT Device",
"type":"AnMQTTDevice",
"humidity":{
"type": "degrees",
"value": "4124436931"
}
}
Loading