diff --git a/bridge/device/device.go b/bridge/device/device.go index 5b972438..a388c26e 100644 --- a/bridge/device/device.go +++ b/bridge/device/device.go @@ -29,9 +29,11 @@ import ( "github.com/plgd-dev/device/v2/bridge/resources" cloudResource "github.com/plgd-dev/device/v2/bridge/resources/cloud" resourcesDevice "github.com/plgd-dev/device/v2/bridge/resources/device" + "github.com/plgd-dev/device/v2/bridge/resources/discovery" "github.com/plgd-dev/device/v2/schema" cloudSchema "github.com/plgd-dev/device/v2/schema/cloud" plgdDevice "github.com/plgd-dev/device/v2/schema/device" + plgdResources "github.com/plgd-dev/device/v2/schema/resources" "github.com/plgd-dev/go-coap/v3/message" "github.com/plgd-dev/go-coap/v3/message/codes" "github.com/plgd-dev/go-coap/v3/message/pool" @@ -122,6 +124,10 @@ func New(cfg Config, onDeviceUpdated func(d *Device), additionalProperties resou onDeviceUpdated: onDeviceUpdated, } d.AddResource(resourcesDevice.New(plgdDevice.ResourceURI, d, additionalProperties)) + // oic/res is not discoverable + discoverResource := discovery.New(plgdResources.ResourceURI, d.GetLinks) + discoverResource.PolicyBitMask = schema.Discoverable + d.AddResource(discoverResource) if cfg.Cloud.Enabled { d.cloudManager = cloud.New(d.cfg.ID, func() { diff --git a/bridge/service/service.go b/bridge/service/service.go index b8cfe94d..88433810 100644 --- a/bridge/service/service.go +++ b/bridge/service/service.go @@ -27,7 +27,6 @@ import ( "github.com/plgd-dev/device/v2/bridge/resources" "github.com/plgd-dev/device/v2/bridge/resources/discovery" "github.com/plgd-dev/device/v2/schema" - "github.com/plgd-dev/device/v2/schema/interfaces" plgdResources "github.com/plgd-dev/device/v2/schema/resources" "github.com/plgd-dev/go-coap/v3/message" "github.com/plgd-dev/go-coap/v3/message/codes" @@ -88,18 +87,6 @@ func (c *Service) handleDiscoverAllLinks(req *net.Request) (*pool.Message, error links = append(links, dlinks...) } } - - links = append(links, schema.ResourceLink{ - Href: plgdResources.ResourceURI, - ResourceTypes: []string{plgdResources.ResourceType}, - Interfaces: []string{interfaces.OC_IF_BASELINE, interfaces.OC_IF_R}, - Endpoints: req.Endpoints, - Anchor: "ocf://" + resources.ToUUID(c.cfg.API.CoAP.ID).String(), - DeviceID: resources.ToUUID(c.cfg.API.CoAP.ID).String(), - Policy: &schema.Policy{ - BitMask: schema.Discoverable, - }, - }) return links }) defer res.Close()