From b23c25b08e9461863384460fe74d53a4265be3ea Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 27 Mar 2023 10:07:10 +0800 Subject: edgehub process send twin msg to twingroup directly to avoid the response of device report be handled by beehiveContext.SendResp() Signed-off-by: Ryan --- edge/pkg/devicetwin/process.go | 2 ++ edge/pkg/edgehub/process.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/edge/pkg/devicetwin/process.go b/edge/pkg/devicetwin/process.go index f6ab34e99..5c2197192 100644 --- a/edge/pkg/devicetwin/process.go +++ b/edge/pkg/devicetwin/process.go @@ -52,8 +52,10 @@ func (dt *DeviceTwin) distributeMsg(m interface{}) error { klog.Infof("Send msg to the %s module in twin", dtcommon.CommModule) confirmMsg := dttype.DTMessage{Msg: model.NewMessage(message.Msg.GetParentID()), Action: dtcommon.Confirm} if err := dt.DTContexts.CommTo(dtcommon.CommModule, &confirmMsg); err != nil { + klog.Errorf("fail to send msg %s to CommModule with err: %+v", confirmMsg.Msg.Header.ID, err) return err } + return nil } if !classifyMsg(&message) { return errors.New("not found action") diff --git a/edge/pkg/edgehub/process.go b/edge/pkg/edgehub/process.go index 05499e3f6..bc08f02bb 100644 --- a/edge/pkg/edgehub/process.go +++ b/edge/pkg/edgehub/process.go @@ -73,6 +73,14 @@ func (*defaultHandler) Process(message *model.Message, clientHub clients.Adapter md = modules.BusGroup } + // TODO: just for a temporary fix. + // The code related to device twin message transmission will be reconstructed + // by using sendSync function instead of send function. + if group == messagepkg.TwinGroupName { + beehiveContext.SendToGroup(md, *message) + return nil + } + isResponse := isSyncResponse(message.GetParentID()) if isResponse { beehiveContext.SendResp(*message) -- cgit v1.2.3