diff --git a/packages/binding-coap/src/coap-server.ts b/packages/binding-coap/src/coap-server.ts index d316e25a8..04ecb5d3f 100644 --- a/packages/binding-coap/src/coap-server.ts +++ b/packages/binding-coap/src/coap-server.ts @@ -475,7 +475,7 @@ export default class CoapServer implements ProtocolServer { if (req.headers.Observe == null) { this.handleReadProperty(property, req, contentType, thing, res, affordanceKey); } else { - this.handleObserveProperty(req, thing, res, affordanceKey); + this.handleObserveProperty(property, req, contentType, thing, res, affordanceKey); } break; case "PUT": @@ -517,15 +517,25 @@ export default class CoapServer implements ProtocolServer { } private async handleObserveProperty( + property: PropertyElement, req: IncomingMessage, + contentType: string, thing: ExposedThing, res: OutgoingMessage, affordanceKey: string ) { + const interactionOptions = this.createInteractionOptions( + property.forms, + thing, + req, + contentType, + property.uriVariables + ); + const listener = this.createContentListener(req, res, this.PROPERTY_DIR, affordanceKey); try { - await thing.handleObserveProperty(affordanceKey, listener); + await thing.handleObserveProperty(affordanceKey, listener, interactionOptions); } catch (error) { warn(`${error}`); } @@ -536,10 +546,10 @@ export default class CoapServer implements ProtocolServer { if (err) { error(`CoapServer on port ${this.port} failed on observe with: ${err.message}`); } - thing.handleUnobserveProperty(affordanceKey, listener); + thing.handleUnobserveProperty(affordanceKey, listener, interactionOptions); }); - setTimeout(() => thing.handleUnobserveProperty(affordanceKey, listener), 60 * 60 * 1000); + setTimeout(() => thing.handleUnobserveProperty(affordanceKey, listener, interactionOptions), 60 * 60 * 1000); } private createContentListener(