Skip to content

Commit

Permalink
oic/res will be part of each device
Browse files Browse the repository at this point in the history
  • Loading branch information
jkralik committed Jan 23, 2024
1 parent 114d106 commit 88e9b2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
6 changes: 6 additions & 0 deletions bridge/device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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() {
Expand Down
13 changes: 0 additions & 13 deletions bridge/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 88e9b2c

Please sign in to comment.