added notificationsubscribe method

master
cheetah 1 year ago
parent bd2332d107
commit 8ad96dce26

@ -84,6 +84,22 @@ func (tc *TerminalClient) Authenticate(addr TetraFlexAddress) (err error) {
}
return nil
}
func (tc *TerminalClient) SubscribeEvents(messageTypes []tmkind.TetraFlexTerminalMessageKinds) (err error) {
tfNotReq, err := NewTMNotificationRequest(messageTypes)
if err != nil {
return err
}
tc.HandlerMap[tfNotReq.handler] = make(chan HandlerResponse)
err = tc.Send(tfNotReq)
if err != nil {
return err
}
response := <-tc.HandlerMap[tfNotReq.handler]
if !response.Success {
return response.Error
}
return nil
}
func (tc *TerminalClient) AttachGroups(groups []GroupConfig) (err error) {
tfGroupAttachReq, err := NewTMIpApiGroupAttachRequest(groups)
if err != nil {

@ -32,11 +32,23 @@ func main() {
if err != nil {
panic(err)
}
err = terminalClient.SubscribeEvents([]tmkind.TetraFlexTerminalMessageKinds{
tmkind.IpApiCallUpdateNotification,
tmkind.IpApiSdsTlReportNotification,
tmkind.IpApiSdsTlShortReportNotification,
tmkind.IpApiSdsDataType4Notification,
tmkind.IpApiSdsStatusNotification,
tmkind.IpApiSdsTlTransferNotification,
})
if err != nil {
panic(err)
}
//fmt.Println(hex.EncodeToString(parsedMsg.Bytes()))
regInfoBytes, _ := json.Marshal(terminalClient.RegistrationInfo)
fmt.Println(string(regInfoBytes))
terminalClient.AttachGroups([]common.GroupConfig{
err = terminalClient.AttachGroups([]common.GroupConfig{
{
Group: common.NewAddressFromSSINumber(101),
ScanMode: common.Scanned,
@ -50,6 +62,9 @@ func main() {
ScanMode: common.Scanned,
},
})
if err != nil {
panic(err)
}
for {
select {
@ -65,19 +80,6 @@ func main() {
//terminalClient.SendTM()
}
}
if parsedMsg.Kind == tmkind.IpApiRegistrationConfirm {
regInfo, err := parsedMsg.AsRegistrationInfo()
if err != nil {
panic(err)
}
fmt.Println(hex.EncodeToString(parsedMsg.Bytes()))
regInfoBytes, _ := json.Marshal(regInfo)
fmt.Println(string(regInfoBytes))
}
//if parsedMsg.Kind == tmkind.IpApiNo
}
}

Loading…
Cancel
Save