Skip to content

Commit

Permalink
fix: service wrapper was removed as it has been rolled into the Devic…
Browse files Browse the repository at this point in the history
…eServiceSDK interface

Signed-off-by: Marc-Philippe Fuller <marc-philippe.fuller@intel.com>
  • Loading branch information
marcpfuller committed Aug 10, 2022
1 parent 5edf930 commit b17f4e7
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 187 deletions.
12 changes: 12 additions & 0 deletions Attribution.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,15 @@ https://github.com/go-kit/log/blob/main/LICENSE

golang.org/x/sync (Unspecified) https://cs.opensource.google/go/x/sync
https://cs.opensource.google/go/x/sync/+/master:LICENSE

github.com/nats-io/nats.go (Unspecified) https://github.com/nats-io/nats.go
https://github.com/nats-io/nats.go/blob/main/LICENSE

github.com/nats-io/nkeys (Unspecified) https://github.com/nats-io/nkeys
https://github.com/nats-io/nkeys/blob/master/LICENSE

github.com/nats-io/nuid (Unspecified) https://github.com/nats-io/nuid
https://github.com/nats-io/nuid/blob/master/LICENSE

github.com/stretchr/objx (Unspecified) https://github.com/stretchr/objx
https://github.com/stretchr/objx/blob/master/LICENSE
12 changes: 8 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/edgexfoundry/device-rfid-llrp-go
go 1.18

require (
github.com/edgexfoundry/device-sdk-go/v2 v2.2.1-dev.14
github.com/edgexfoundry/device-sdk-go/v2 v2.3.0-dev.18
github.com/edgexfoundry/go-mod-core-contracts/v2 v2.2.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.0
Expand All @@ -18,7 +18,7 @@ require (
github.com/eclipse/paho.mqtt.golang v1.4.1 // indirect
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0 // indirect
github.com/edgexfoundry/go-mod-configuration/v2 v2.2.0 // indirect
github.com/edgexfoundry/go-mod-messaging/v2 v2.2.1-dev.11 // indirect
github.com/edgexfoundry/go-mod-messaging/v2 v2.3.0-dev.12 // indirect
github.com/edgexfoundry/go-mod-registry/v2 v2.2.0 // indirect
github.com/edgexfoundry/go-mod-secrets/v2 v2.2.0 // indirect
github.com/fatih/color v1.9.0 // indirect
Expand Down Expand Up @@ -50,21 +50,25 @@ require (
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/nats-io/nats.go v1.16.0 // indirect
github.com/nats-io/nkeys v0.3.0 // indirect
github.com/nats-io/nuid v1.0.1 // indirect
github.com/pebbe/zmq4 v1.2.7 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a // indirect
github.com/spiffe/go-spiffe/v2 v2.0.0 // indirect
github.com/stretchr/objx v0.4.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/zeebo/errs v1.2.2 // indirect
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/grpc v1.42.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/square/go-jose.v2 v2.4.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
27 changes: 21 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/eclipse/paho.mqtt.golang v1.4.1 h1:tUSpviiL5G3P9SZZJPC4ZULZJsxQKXxfENpMvdbAXAI=
github.com/eclipse/paho.mqtt.golang v1.4.1/go.mod h1:JGt0RsEwEX+Xa/agj90YJ9d9DH2b7upDZMK9HRbFvCA=
github.com/edgexfoundry/device-sdk-go/v2 v2.2.1-dev.14 h1:M1nMJADLSPnd0M57W61ietbCJt9tV75qxvkPM8eQGxA=
github.com/edgexfoundry/device-sdk-go/v2 v2.2.1-dev.14/go.mod h1:rFZvTH1eTEMbFXo2CG1zrg7OCW+LQe0KoemHyUN7d0I=
github.com/edgexfoundry/device-sdk-go/v2 v2.3.0-dev.18 h1:zNMhvKby8G/4nTwrhqsvey1DhrDcu4opLAoD/b1BfGM=
github.com/edgexfoundry/device-sdk-go/v2 v2.3.0-dev.18/go.mod h1:OicWI5MGWgLzKrA0FtuNefuGhiHPzdxxkLK7G8kUU8E=
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0 h1:4UVNGRaKbkH5aEhQrto26Q65ydmhZYReRw/6ZNQ5J5E=
github.com/edgexfoundry/go-mod-bootstrap/v2 v2.2.0/go.mod h1:JKRxVTC5g1IRoQuT6T7pW6O6XnfjQTZgFjEazPHAHng=
github.com/edgexfoundry/go-mod-configuration/v2 v2.2.0 h1:AZeaAPJM5X93ITFgwbwluYDtYEJ7tkCMSlj35GwfLLU=
github.com/edgexfoundry/go-mod-configuration/v2 v2.2.0/go.mod h1:YP17JhMnXTitowXE13QJwFaKo0oc03iyoKLjWAYl4FE=
github.com/edgexfoundry/go-mod-core-contracts/v2 v2.2.0 h1:Sfi9jAIgRXZaJQw8Ji6+8//47D+iOyGiXQSNZXhy3HE=
github.com/edgexfoundry/go-mod-core-contracts/v2 v2.2.0/go.mod h1:jyfVSx7mI3u/o/oo10COxBRBvJ8O/9I3z2xAwPmNt/Q=
github.com/edgexfoundry/go-mod-messaging/v2 v2.2.1-dev.11 h1:mvVU/eRl5GGIH1r/PDRgK3AR8Zsq81Lsi9qjduPsoFk=
github.com/edgexfoundry/go-mod-messaging/v2 v2.2.1-dev.11/go.mod h1:h7iBbErPlPBEjYoO5UpwdFxR+Tqg/eObEbNGy2INVlo=
github.com/edgexfoundry/go-mod-messaging/v2 v2.3.0-dev.12 h1:YdO9V8pSFK3L2FSpPru3OulK0kFCt96+tsdxTtkfeqk=
github.com/edgexfoundry/go-mod-messaging/v2 v2.3.0-dev.12/go.mod h1:yLJ9EK4Feg409FDr0oP87LbaRLyOSGJk/ikaIfEDKcI=
github.com/edgexfoundry/go-mod-registry/v2 v2.2.0 h1:dk9ul1t7INAiyZXeu/GrpinFE3qOekdy8uZOqEGgIiE=
github.com/edgexfoundry/go-mod-registry/v2 v2.2.0/go.mod h1:DUQRnAd5fVzoROc5SI+PTFUD/vCNeZmZHBMrLElbmwI=
github.com/edgexfoundry/go-mod-secrets/v2 v2.2.0 h1:Rqr1CgBXppAeehCkPAHQ6hjyLlm2KTR4IKiKpExm7gg=
Expand Down Expand Up @@ -143,6 +143,7 @@ github.com/hashicorp/serf v0.9.5 h1:EBWvyu9tcRszt3Bxp3KNssBMP1KuHWyO51lz9+786iM=
github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
Expand All @@ -167,6 +168,7 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/miekg/dns v1.1.26 h1:gPxPSwALAeHJSjarOs00QjVdV9QoBvc1D2ujQUr5BzU=
github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g=
github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI=
github.com/mitchellh/consulstructure v0.0.0-20190329231841-56fdc4d2da54 h1:DcITQwl3ymmg7i1XfwpZFs/TPv2PuTwxE8bnuKVtKlk=
github.com/mitchellh/consulstructure v0.0.0-20190329231841-56fdc4d2da54/go.mod h1:dIfpPVUR+ZfkzkDcKnn+oPW1jKeXe4WlNWc7rIXOVxM=
Expand All @@ -181,6 +183,14 @@ github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQz
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/reflectwalk v1.0.0 h1:9D+8oIskB4VJBN5SFlmc27fSlIBZaov1Wpk/IfikLNY=
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/nats-io/jwt/v2 v2.3.0 h1:z2mA1a7tIf5ShggOFlR1oBPgd6hGqcDYsISxZByUzdI=
github.com/nats-io/nats-server/v2 v2.7.4 h1:c+BZJ3rGzUKCBIM4IXO8uNT2u1vajGbD1kPA6wqCEaM=
github.com/nats-io/nats.go v1.16.0 h1:zvLE7fGBQYW6MWaFaRdsgm9qT39PJDQoju+DS8KsO1g=
github.com/nats-io/nats.go v1.16.0/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w=
github.com/nats-io/nkeys v0.3.0 h1:cgM5tL53EvYRU+2YLXIK0G2mJtK12Ft9oeooSZMA2G8=
github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4=
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo=
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down Expand Up @@ -233,8 +243,10 @@ golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=
golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM=
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
Expand All @@ -251,6 +263,7 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
Expand Down Expand Up @@ -294,6 +307,7 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 h1:ftMN5LMiBFjbzleLqtoBZk7KdJwhuybIU+FckUHgoyQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
Expand Down Expand Up @@ -337,8 +351,9 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
5 changes: 3 additions & 2 deletions internal/driver/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"sync"
"time"

"github.com/edgexfoundry/device-sdk-go/v2/pkg/interfaces"
dsModels "github.com/edgexfoundry/device-sdk-go/v2/pkg/models"
"github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger"
"github.com/edgexfoundry/go-mod-core-contracts/v2/common"
Expand Down Expand Up @@ -344,7 +345,7 @@ func (l *LLRPDevice) resetConn() {
//
// If the event is a new successful connection event,
// it ensures the Reader has our desired configuration state.
func (l *LLRPDevice) newReaderEventHandler(svc ServiceWrapper) llrp.MessageHandler {
func (l *LLRPDevice) newReaderEventHandler(svc interfaces.DeviceServiceSDK) llrp.MessageHandler {
return llrp.MessageHandlerFunc(func(c *llrp.Client, msg llrp.Message) {
now := time.Now()

Expand Down Expand Up @@ -457,7 +458,7 @@ func processReport(readerStart time.Time, report *llrp.ROAccessReport) {
}

// onConnect is called when we open a new connection to a Reader.
func (l *LLRPDevice) onConnect(svc ServiceWrapper) {
func (l *LLRPDevice) onConnect(svc interfaces.DeviceServiceSDK) {
l.deviceMu.RLock()
isEnabled := l.isUp
l.deviceMu.RUnlock()
Expand Down
19 changes: 13 additions & 6 deletions internal/driver/discover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import (
"time"

"github.com/edgexfoundry/device-rfid-llrp-go/internal/llrp"
"github.com/edgexfoundry/device-sdk-go/v2/pkg/interfaces/mocks"
"github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger"
"github.com/edgexfoundry/go-mod-core-contracts/v2/models"
"github.com/stretchr/testify/mock"
)

type inetTest struct {
Expand All @@ -30,7 +33,7 @@ type inetTest struct {
}

var (
svc = NewMockSdkService()
svc = &mocks.DeviceServiceSDK{}
)

func TestMain(m *testing.M) {
Expand All @@ -39,6 +42,8 @@ func TestMain(m *testing.M) {
driver.svc = svc
driver.lc = logger.NewClient("test", "DEBUG")

svc.On("Devices").Return([]models.Device{})

os.Exit(m.Run())
}

Expand Down Expand Up @@ -163,6 +168,7 @@ func TestAutoDiscoverNaming(t *testing.T) {
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
svc.On("GetDeviceByName", mock.Anything).Return(models.Device{}, fmt.Errorf("error")).Once()
emu := llrp.NewTestEmulator(!testing.Verbose())
if err := emu.StartAsync(scanPort); err != nil {
t.Fatalf("unable to start emulator: %+v", err)
Expand Down Expand Up @@ -224,7 +230,7 @@ func TestAutoDiscover(t *testing.T) {
params := makeParams()

// attempt to discover without emulator, expect none found
svc.clearDevices()

discovered := autoDiscover(context.Background(), params)
if len(discovered) != 0 {
t.Fatalf("expected 0 discovered devices, however got: %d", len(discovered))
Expand Down Expand Up @@ -260,14 +266,17 @@ func TestAutoDiscover(t *testing.T) {
}
emu.SetResponse(llrp.MsgGetReaderCapabilities, &readerCaps)

svc.On("GetDeviceByName", mock.Anything).Return(models.Device{}, fmt.Errorf("error")).Once()
discovered = autoDiscover(context.Background(), params)
if len(discovered) != 1 {
t.Fatalf("expected 1 discovered device, however got: %d", len(discovered))
}
svc.AddDiscoveredDevices(discovered)


// attempt to discover again WITH emulator, however expect emulator to be skipped
svc.resetAddedCount()

svc.On("GetDeviceByName", mock.Anything).Return(models.Device{Name: discovered[0].Name, Protocols: discovered[0].Protocols}, nil).Once()

discovered = autoDiscover(context.Background(), params)
if len(discovered) != 0 {
t.Fatalf("expected no devices to be discovered, but was %d", len(discovered))
Expand All @@ -276,8 +285,6 @@ func TestAutoDiscover(t *testing.T) {
if err := emu.Shutdown(); err != nil {
t.Errorf("error shutting down test emulator: %+v", err)
}
// reset
svc.clearDevices()
}

func mockIpWorker(ipCh <-chan uint32, result *inetTest) {
Expand Down
8 changes: 3 additions & 5 deletions internal/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"sync"
"time"

"github.com/edgexfoundry/device-sdk-go/v2/pkg/interfaces"
dsModels "github.com/edgexfoundry/device-sdk-go/v2/pkg/models"
"github.com/edgexfoundry/device-sdk-go/v2/pkg/service"
"github.com/edgexfoundry/go-mod-core-contracts/v2/clients/logger"
Expand Down Expand Up @@ -91,7 +92,7 @@ type Driver struct {
addedWatchers bool
watchersMu sync.Mutex

svc ServiceWrapper
svc interfaces.DeviceServiceSDK

// debounceTimer and debounceMu keep track of when to fire a debounced discovery call
debounceTimer *time.Timer
Expand Down Expand Up @@ -142,10 +143,7 @@ func (d *Driver) Initialize(lc logger.LoggingClient, asyncCh chan<- *dsModels.As

d.asyncCh = asyncCh
d.deviceCh = deviceCh
d.svc = &DeviceSDKService{
DeviceService: service.RunningService(),
lc: lc,
}
d.svc = service.RunningService()

d.config = &ServiceConfig{}

Expand Down
55 changes: 0 additions & 55 deletions internal/driver/service.go

This file was deleted.

Loading

0 comments on commit b17f4e7

Please sign in to comment.