Skip to content

Commit 6f0a915

Browse files
committed
Add CloudProtocl v2 support to sendPropertyAsDevice
1 parent 2f0aabf commit 6f0a915

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ const getCborValue = (senMl) => {
474474
return arrayBufferToBase64(cborEncoded);
475475
};
476476

477-
const sendPropertyAsDevice = (deviceId, thingId, name, value, timestamp) => {
477+
const sendPropertyAsDevice = (deviceId, thingId, name, value, timestamp,
478+
useCloudProtocolV2 = false) => {
478479
const propertyInputTopic = `/a/t/${thingId}/e/o`;
479480

480481
if (timestamp && !Number.isInteger(timestamp)) {
@@ -485,7 +486,7 @@ const sendPropertyAsDevice = (deviceId, thingId, name, value, timestamp) => {
485486
throw new Error('Name must be a valid string');
486487
}
487488

488-
const senMlValue = getSenml(deviceId, name, value, timestamp);
489+
const senMlValue = getSenml(deviceId, name, value, timestamp, useCloudProtocolV2);
489490
return sendMessage(propertyInputTopic, CBOR.encode([senMlValue]));
490491
};
491492

0 commit comments

Comments
 (0)