Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix discover device - use MID from global #106

Merged
merged 1 commit into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.13
require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/go-ocf/cloud v0.0.0-20200722070446-3773fbf08dcb
github.com/go-ocf/go-coap/v2 v2.0.4-0.20200727123524-5a1063fa65b2
github.com/go-ocf/go-coap/v2 v2.0.4-0.20200728093524-65e8ccbe4cd6
github.com/go-ocf/kit v0.0.0-20200702075537-01631a881369
github.com/gofrs/uuid v3.3.0+incompatible
github.com/google/uuid v1.1.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ github.com/go-ocf/go-coap/v2 v2.0.4-0.20200723131250-f4a1b6b8c4b1 h1:J8QrKdn93+i
github.com/go-ocf/go-coap/v2 v2.0.4-0.20200723131250-f4a1b6b8c4b1/go.mod h1:X9wVKcaOSx7wBxKcvrWgMQq1R2DNeA7NBLW2osIb8TM=
github.com/go-ocf/go-coap/v2 v2.0.4-0.20200727123524-5a1063fa65b2 h1:8Ib/QICE+KkwobmufbzeKpamvolRj+tgyF+6irYsZ+4=
github.com/go-ocf/go-coap/v2 v2.0.4-0.20200727123524-5a1063fa65b2/go.mod h1:X9wVKcaOSx7wBxKcvrWgMQq1R2DNeA7NBLW2osIb8TM=
github.com/go-ocf/go-coap/v2 v2.0.4-0.20200728093524-65e8ccbe4cd6 h1:R8rJXhYGIcSIywVb+fYM8ug1xghkc3QG4sUyC/OCFb0=
github.com/go-ocf/go-coap/v2 v2.0.4-0.20200728093524-65e8ccbe4cd6/go.mod h1:X9wVKcaOSx7wBxKcvrWgMQq1R2DNeA7NBLW2osIb8TM=
github.com/go-ocf/grpc-gateway v0.0.0-20191029150757-8ed2b7d67a67/go.mod h1:GuVJZHmSz7KGATOk0tqLPkgBJq2H12hZnG74CTJXOtI=
github.com/go-ocf/grpc-gateway v0.0.0-20191128115804-9c2e8f77af08/go.mod h1:XBVeqnt2JEx0Z6SLEdjnjQ53jEpbAvcx+/CAC43eAb4=
github.com/go-ocf/grpc-gateway v0.0.0-20200206140756-f2e98d630ed6/go.mod h1:UmskFCqe00ISEBHTZJbWIeyvvHcIuVsS/5c5FFEHF8s=
Expand Down
7 changes: 2 additions & 5 deletions local/core/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package core

import (
"context"
"crypto/rand"
"encoding/binary"
"fmt"
"sync"

"github.com/go-ocf/go-coap/v2/message"
"github.com/go-ocf/go-coap/v2/net"
"github.com/go-ocf/go-coap/v2/udp"
"github.com/go-ocf/go-coap/v2/udp/client"
udpMessage "github.com/go-ocf/go-coap/v2/udp/message"
"github.com/go-ocf/go-coap/v2/udp/message/pool"
kitNetCoap "github.com/go-ocf/kit/net/coap"
)
Expand Down Expand Up @@ -71,9 +70,7 @@ func (d *DiscoveryClient) Close() error {
// DialDiscoveryAddresses connects to discovery endpoints.
func DialDiscoveryAddresses(ctx context.Context, cfg DiscoveryConfiguration, errors func(error)) []*DiscoveryClient {
var out []*DiscoveryClient
b := make([]byte, 4)
rand.Read(b)
msgID := uint16(binary.BigEndian.Uint32(b))
msgID := udpMessage.GetMID()

for _, address := range cfg.MulticastAddressUDP4 {
c, err := newDiscoveryClient("udp4", address, msgID, errors)
Expand Down