github.com/enbility/spine-go@v0.7.0/spine/nodemanagement_destinationlist.go (about) 1 package spine 2 3 import ( 4 "errors" 5 "fmt" 6 7 "github.com/enbility/spine-go/api" 8 "github.com/enbility/spine-go/model" 9 ) 10 11 func (r *NodeManagement) RequestDestinationListData(remoteDeviceAddress *model.AddressDeviceType, sender api.SenderInterface) (*model.MsgCounterType, *model.ErrorType) { 12 return nil, model.NewErrorTypeFromString("Not implemented") 13 } 14 15 func (r *NodeManagement) processReadDestinationListData(featureRemote api.FeatureRemoteInterface, requestHeader *model.HeaderType) error { 16 data := []model.NodeManagementDestinationDataType{ 17 r.Device().DestinationData(), 18 } 19 // add other remote devices here 20 21 cmd := model.CmdType{ 22 NodeManagementDestinationListData: &model.NodeManagementDestinationListDataType{ 23 NodeManagementDestinationData: data, 24 }, 25 } 26 27 return featureRemote.Device().Sender().Reply(requestHeader, r.Address(), cmd) 28 } 29 30 func (r *NodeManagement) processReplyDestinationListData(_ *api.Message, _ model.NodeManagementDestinationListDataType) error { 31 return errors.New("Not implemented") 32 } 33 34 func (r *NodeManagement) handleMsgDestinationListData(message *api.Message, data *model.NodeManagementDestinationListDataType) error { 35 switch message.CmdClassifier { 36 case model.CmdClassifierTypeRead: 37 return r.processReadDestinationListData(message.FeatureRemote, message.RequestHeader) 38 39 case model.CmdClassifierTypeReply: 40 return r.processReplyDestinationListData(message, *data) 41 42 case model.CmdClassifierTypeNotify: 43 return r.processReplyDestinationListData(message, *data) 44 45 default: 46 return fmt.Errorf("nodemanagement.handleMsgDestinationListData: NodeManagementDestinationListDataType CmdClassifierType not implemented: %s", message.CmdClassifier) 47 } 48 }