diff options
Diffstat (limited to 'edge')
| -rw-r--r-- | edge/pkg/devicetwin/process.go | 6 | ||||
| -rw-r--r-- | edge/pkg/devicetwin/process_test.go | 2 | ||||
| -rw-r--r-- | edge/pkg/eventbus/mqtt/client.go | 4 | ||||
| -rw-r--r-- | edge/test/integration/utils/helpers/helpers.go | 2 |
4 files changed, 9 insertions, 5 deletions
diff --git a/edge/pkg/devicetwin/process.go b/edge/pkg/devicetwin/process.go index 05178e569..b4f808a7e 100644 --- a/edge/pkg/devicetwin/process.go +++ b/edge/pkg/devicetwin/process.go @@ -214,7 +214,11 @@ func classifyMsg(message *dttype.DTMessage) bool { } else { identity = splitString[idLoc] loc := strings.Index(topic, identity) - nextLoc := loc + len(identity) + var nextLoc int + if strings.Contains(topic, dtcommon.DeviceETPrefix) { + identity = identity + "/" + splitString[idLoc+1] + } + nextLoc = loc + len(identity) prefix := topic[0:loc] suffix := topic[nextLoc:] klog.Infof("%s %s", prefix, suffix) diff --git a/edge/pkg/devicetwin/process_test.go b/edge/pkg/devicetwin/process_test.go index 6d35fde38..50ab9392f 100644 --- a/edge/pkg/devicetwin/process_test.go +++ b/edge/pkg/devicetwin/process_test.go @@ -397,7 +397,7 @@ func Test_classifyMsg(t *testing.T) { otherTopic := "/membership/detail/result" otherEncodedTopic := base64.URLEncoding.EncodeToString([]byte(otherTopic)) //Encoded eventbus resource - eventbusTopic := "$hw/events/device/+/state/update" + eventbusTopic := "$hw/events/device/+/+/state/update" eventbusResource := base64.URLEncoding.EncodeToString([]byte(eventbusTopic)) content := testutil.GenerateAddDevicePalyloadMsg(t) diff --git a/edge/pkg/eventbus/mqtt/client.go b/edge/pkg/eventbus/mqtt/client.go index 760380076..898b952be 100644 --- a/edge/pkg/eventbus/mqtt/client.go +++ b/edge/pkg/eventbus/mqtt/client.go @@ -42,8 +42,8 @@ var ( // SubTopics which edge-client should be sub SubTopics = []string{ "$hw/events/upload/#", - "$hw/events/device/+/state/update", - "$hw/events/device/+/twin/+", + "$hw/events/device/+/+/state/update", + "$hw/events/device/+/+/twin/+", "$hw/events/node/+/membership/get", UploadTopic, "+/user/#", diff --git a/edge/test/integration/utils/helpers/helpers.go b/edge/test/integration/utils/helpers/helpers.go index 48ec24181..fb8e1590e 100644 --- a/edge/test/integration/utils/helpers/helpers.go +++ b/edge/test/integration/utils/helpers/helpers.go @@ -82,7 +82,7 @@ type TwinAttribute struct { } func GenerateDeviceID(deviceSuffix string) string { - return deviceSuffix + edge.GetRandomString(10) + return "default/" + deviceSuffix + edge.GetRandomString(10) } // Function to Generate Device |
