Skip to content

Commit

Permalink
Merge pull request #78 from JKRhb/confirmable
Browse files Browse the repository at this point in the history
feat: add option for (non-)confirmable requests
  • Loading branch information
JKRhb authored Jan 2, 2023
2 parents c159f05 + 4c7c981 commit 15401df
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions coap/coap-request.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
value: "GET",
validate: (v) => ["", "GET", "PUT", "POST", "DELETE", "FETCH", "PATCH", "iPATCH"].includes(v),
},
confirmable: { value: true, required: true },
observe: { value: false, required: true },
multicast: { value: false, required: true },
multicastTimeout: { value: 20000, required: false },
Expand Down Expand Up @@ -52,6 +53,12 @@
<option value="iPATCH">iPATCH</option>
</select>
</div>

<div class="form-row">
<input type="checkbox" id="node-input-confirmable" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-confirmable" style="width: auto" data-i18n="coapRequest.inputConfirmable.label"></label>
</div>

<div class="form-row">
<input type="checkbox" id="node-input-observe" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-observe" style="width: auto" data-i18n="coapRequest.inputObserve.label"></label>
Expand Down
6 changes: 6 additions & 0 deletions coap/coap-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ module.exports = function (RED) {
reqOpts.headers["Content-Format"] = config["content-format"];
reqOpts.multicast = config.multicast;
reqOpts.multicastTimeout = config.multicastTimeout;
reqOpts.confirmable = msg.confirmable;

if (reqOpts.confirmable == null) {

reqOpts.confirmable = config.confirmable;
}

function _onResponse(res) {
function _send(payload) {
Expand Down
3 changes: 3 additions & 0 deletions coap/locales/de/coap-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"inputObserve": {
"label": "Observe?"
},
"inputConfirmable": {
"label": "Confirmable?"
},
"inputRawBuffer": {
"label": "Rohdaten?"
},
Expand Down
3 changes: 3 additions & 0 deletions coap/locales/en-US/coap-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"inputObserve": {
"label": "Observe?"
},
"inputConfirmable": {
"label": "Confirmable?"
},
"inputRawBuffer": {
"label": "Raw buffer?"
},
Expand Down

0 comments on commit 15401df

Please sign in to comment.