Skip to content

Commit f63b729

Browse files
authored
Merge pull request #1315 from JKRhb/coap-update
feat(binding-coap): remove cov:observe subprotocol
2 parents 2f88743 + a5b4711 commit f63b729

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

packages/binding-coap/src/coap-server.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { MdnsIntroducer } from "./mdns-introducer";
3535
import { PropertyElement, DataSchema, ActionElement, EventElement } from "wot-thing-description-types";
3636
import { CoapServerConfig } from "./coap";
3737
import { DataSchemaValue } from "wot-typescript-definitions";
38-
import { filterPropertyObserveOperations, getPropertyOpValues } from "./util";
38+
import { getPropertyOpValues } from "./util";
3939

4040
const { debug, warn, info, error } = createLoggers("binding-coap", "coap-server");
4141

@@ -248,23 +248,14 @@ export default class CoapServer implements ProtocolServer {
248248
continue;
249249
}
250250

251-
let subprotocol: string | undefined;
252-
253-
const observeOpValues = filterPropertyObserveOperations(formOpValues);
254-
255-
if (observeOpValues.length > 0) {
256-
subprotocol = "cov:observe";
257-
}
258-
259251
const form = this.createAffordanceForm(
260252
base,
261253
this.PROPERTY_DIR,
262254
offeredMediaType,
263255
formOpValues,
264256
thing.uriVariables,
265257
propertyName,
266-
property.uriVariables,
267-
subprotocol
258+
property.uriVariables
268259
);
269260

270261
this.addFormToAffordance(form, property);
@@ -299,8 +290,7 @@ export default class CoapServer implements ProtocolServer {
299290
["subscribeevent", "unsubscribeevent"],
300291
thing.uriVariables,
301292
eventName,
302-
event.uriVariables,
303-
"cov:observe"
293+
event.uriVariables
304294
);
305295

306296
this.addFormToAffordance(form, event);

packages/binding-coap/src/util.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ export function filterEventOperations(opValues: string[]) {
6060
/**
6161
* Function to (potentially) generate two arrays of `op` values: One with the
6262
* values "readproperty" and "writeproperty", and one with
63-
* "observerproperty" and "unobserveproperty".
63+
* "observeproperty" and "unobserveproperty".
6464
*
65-
* This CoAP-specific distinction is made to be able to generate
66-
* separate forms for the observe-related operations, where the addition
67-
* of a `subprotocol` field with a value of `cov:observe` has to be added.
65+
* This distinction is made to be able to generate separate forms for the
66+
* observe-related operations.
6867
*
6968
* @param property The property for which the forms are going to be
7069
* generated.

packages/binding-coap/test/coap-server-test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ class CoapServerTest {
635635
await coapServer.stop();
636636
}
637637

638-
@test async "should add the cov:observe subprotocol value to observable properties and events "() {
638+
@test async "should add the correct operation types to observable properties and events "() {
639639
const coapServer = new CoapServer({ port: 5683 });
640640
const servient = new Servient();
641641
servient.addServer(coapServer);
@@ -679,7 +679,6 @@ class CoapServerTest {
679679

680680
if (observeOpValuePresent) {
681681
observeOpValueFormCount++;
682-
expect(form.subprotocol).to.eql("cov:observe");
683682
}
684683

685684
const readWriteOpValueCount = filterPropertyReadWriteOperations(
@@ -703,14 +702,17 @@ class CoapServerTest {
703702
for (const event of Object.values(td.events!)) {
704703
for (const form of event.forms) {
705704
const opValues = form.op!;
706-
expect(opValues.length > 0);
705+
// eslint-disable-next-line no-unused-expressions
706+
expect(opValues.length > 0).to.be.true;
707707

708708
const eventOpValueCount = filterEventOperations(opValues as Array<string>).length;
709709
const eventOpValueCountPresent = eventOpValueCount > 0;
710710

711-
expect(eventOpValueCountPresent);
711+
// eslint-disable-next-line no-unused-expressions
712+
expect(eventOpValueCountPresent).to.be.true;
712713

713-
expect(form.subprotocol === "cov:observe");
714+
// eslint-disable-next-line no-unused-expressions
715+
expect(form.subprotocol === "cov:observe").to.be.false;
714716
}
715717
}
716718

0 commit comments

Comments
 (0)