Skip to content

Commit e481fbc

Browse files
committed
getDeviceByMulticast: set deviceID as di query parameter to mcast request
1 parent cb0d7ca commit e481fbc

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

client/core/getDevice.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (c *Client) GetDeviceByMulticast(ctx context.Context, deviceID string, disc
8686

8787
h := newDeviceHandler(c.getDeviceConfiguration(), deviceID, cancel)
8888
// we want to just get "oic.wk.d" resource, because links will be get via unicast to /oic/res
89-
err = DiscoverDevices(findCtx, multicastConn, h, coap.WithResourceType(device.ResourceType))
89+
err = DiscoverDevices(findCtx, multicastConn, h, coap.WithResourceType(device.ResourceType), coap.WithDeviceID(deviceID))
9090
if err != nil {
9191
return nil, MakeDataLoss(fmt.Errorf("could not get the device %s: %w", deviceID, err))
9292
}

pkg/net/coap/client.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,15 @@ func WithResourceType(in string) OptionFunc {
157157
}
158158
}
159159

160+
func WithDeviceID(in string) OptionFunc {
161+
return func(opts message.Options) message.Options {
162+
v := "di=" + in
163+
buf := make([]byte, len(v))
164+
opts, _, _ = opts.AddString(buf, message.URIQuery, v)
165+
return opts
166+
}
167+
}
168+
160169
func WithAccept(contentFormat message.MediaType) OptionFunc {
161170
return func(opts message.Options) message.Options {
162171
buf := make([]byte, 4)

0 commit comments

Comments
 (0)