From d04c8134cb7b1d1596378fe36b76a8cb5659aad9 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Mon, 12 Aug 2024 08:25:26 +0200 Subject: [PATCH 1/3] feat(binding-coap): remove cov:observe subprotocol --- packages/binding-coap/src/coap-server.ts | 16 +++------------- packages/binding-coap/test/coap-server-test.ts | 1 - 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/packages/binding-coap/src/coap-server.ts b/packages/binding-coap/src/coap-server.ts index b94d91a9f..a570f66f2 100644 --- a/packages/binding-coap/src/coap-server.ts +++ b/packages/binding-coap/src/coap-server.ts @@ -35,7 +35,7 @@ import { MdnsIntroducer } from "./mdns-introducer"; import { PropertyElement, DataSchema, ActionElement, EventElement } from "wot-thing-description-types"; import { CoapServerConfig } from "./coap"; import { DataSchemaValue } from "wot-typescript-definitions"; -import { filterPropertyObserveOperations, getPropertyOpValues } from "./util"; +import { getPropertyOpValues } from "./util"; const { debug, warn, info, error } = createLoggers("binding-coap", "coap-server"); @@ -248,14 +248,6 @@ export default class CoapServer implements ProtocolServer { continue; } - let subprotocol: string | undefined; - - const observeOpValues = filterPropertyObserveOperations(formOpValues); - - if (observeOpValues.length > 0) { - subprotocol = "cov:observe"; - } - const form = this.createAffordanceForm( base, this.PROPERTY_DIR, @@ -263,8 +255,7 @@ export default class CoapServer implements ProtocolServer { formOpValues, thing.uriVariables, propertyName, - property.uriVariables, - subprotocol + property.uriVariables ); this.addFormToAffordance(form, property); @@ -299,8 +290,7 @@ export default class CoapServer implements ProtocolServer { ["subscribeevent", "unsubscribeevent"], thing.uriVariables, eventName, - event.uriVariables, - "cov:observe" + event.uriVariables ); this.addFormToAffordance(form, event); diff --git a/packages/binding-coap/test/coap-server-test.ts b/packages/binding-coap/test/coap-server-test.ts index dc91d4da7..467e10133 100644 --- a/packages/binding-coap/test/coap-server-test.ts +++ b/packages/binding-coap/test/coap-server-test.ts @@ -679,7 +679,6 @@ class CoapServerTest { if (observeOpValuePresent) { observeOpValueFormCount++; - expect(form.subprotocol).to.eql("cov:observe"); } const readWriteOpValueCount = filterPropertyReadWriteOperations( From 61980a9683019041bafe028f79f7f82fd8364758 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Mon, 12 Aug 2024 09:35:36 +0200 Subject: [PATCH 2/3] docs(binding-coap): update documentation of getPropertyOpValues --- packages/binding-coap/src/util.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/binding-coap/src/util.ts b/packages/binding-coap/src/util.ts index cf4f4529e..e0ad034b9 100644 --- a/packages/binding-coap/src/util.ts +++ b/packages/binding-coap/src/util.ts @@ -60,11 +60,10 @@ export function filterEventOperations(opValues: string[]) { /** * Function to (potentially) generate two arrays of `op` values: One with the * values "readproperty" and "writeproperty", and one with - * "observerproperty" and "unobserveproperty". + * "observeproperty" and "unobserveproperty". * - * This CoAP-specific distinction is made to be able to generate - * separate forms for the observe-related operations, where the addition - * of a `subprotocol` field with a value of `cov:observe` has to be added. + * This distinction is made to be able to generate separate forms for the + * observe-related operations. * * @param property The property for which the forms are going to be * generated. From a5b47118368f75d78718780e394a55e5847cb849 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Mon, 12 Aug 2024 09:40:34 +0200 Subject: [PATCH 3/3] test(binding-coap): adjust cov:observe test --- packages/binding-coap/test/coap-server-test.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/binding-coap/test/coap-server-test.ts b/packages/binding-coap/test/coap-server-test.ts index 467e10133..a947cfff1 100644 --- a/packages/binding-coap/test/coap-server-test.ts +++ b/packages/binding-coap/test/coap-server-test.ts @@ -635,7 +635,7 @@ class CoapServerTest { await coapServer.stop(); } - @test async "should add the cov:observe subprotocol value to observable properties and events "() { + @test async "should add the correct operation types to observable properties and events "() { const coapServer = new CoapServer({ port: 5683 }); const servient = new Servient(); servient.addServer(coapServer); @@ -702,14 +702,17 @@ class CoapServerTest { for (const event of Object.values(td.events!)) { for (const form of event.forms) { const opValues = form.op!; - expect(opValues.length > 0); + // eslint-disable-next-line no-unused-expressions + expect(opValues.length > 0).to.be.true; const eventOpValueCount = filterEventOperations(opValues as Array).length; const eventOpValueCountPresent = eventOpValueCount > 0; - expect(eventOpValueCountPresent); + // eslint-disable-next-line no-unused-expressions + expect(eventOpValueCountPresent).to.be.true; - expect(form.subprotocol === "cov:observe"); + // eslint-disable-next-line no-unused-expressions + expect(form.subprotocol === "cov:observe").to.be.false; } }