package main import ( "encoding/hex" "encoding/json" "fmt" "math/rand" "time" "git.cheetah.cat/cheetah/opentetraflex-go/common" "git.cheetah.cat/cheetah/opentetraflex-go/common/tmkind" // "strings" ) func main() { rand.Seed(time.Now().UnixNano()) var err error terminalClient := common.NewTerminalClient("192.168.133.106:42381") // err = terminalClient.Connect() if err != nil { panic(err) } // myAddr := common.TetraFlexAddress{ Kind: common.UserNo, UserNo: "1005", } err = terminalClient.Authenticate(myAddr) 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)) err = terminalClient.AttachGroups([]common.GroupConfig{ { Group: common.NewAddressFromSSINumber(101), ScanMode: common.Scanned, }, { Group: common.NewAddressFromSSINumber(102), ScanMode: common.Scanned, }, { Group: common.NewAddressFromSSINumber(103), ScanMode: common.Scanned, }, }) if err != nil { panic(err) } fmt.Println("Groups attached") go func() { fmt.Println("Test started, waiting 3s") time.Sleep(3 * time.Second) groupAddr := common.NewAddressFromSSINumber(101) fmt.Println("Test callSetup") callRef, err := terminalClient.CallSetup(*groupAddr, common.CallTypeGroup, common.CallPriorityDefault, false, common.TetraFlexIdentityInfo{ Description: "Blaa", /* Kind: common.IdentityKindApplication, Address: *common.NewAddressFromSSINumber(1002), UnifiedSSIKinds: common.UnifiedKindExternalNumber, */ Kind: common.IdentityKindTerminal, Address: *common.NewAddressFromSSINumber(1002), UnifiedSSIKinds: common.UnifiedKindPersonalNumber, }) if err != nil { panic(err) } fmt.Printf("callRef=%d\n", callRef) // IpApiCallStreamRequest err = terminalClient.PTTRequest(callRef, common.TetraFlexIdentityInfo{ Description: "Blaa", /* Kind: common.IdentityKindApplication, Address: *common.NewAddressFromSSINumber(1002), UnifiedSSIKinds: common.UnifiedKindExternalNumber, */ Kind: common.IdentityKindTerminal, Address: *common.NewAddressFromSSINumber(1002), UnifiedSSIKinds: common.UnifiedKindPersonalNumber, }, 0) if err != nil { panic(err) } time.Sleep(3 * time.Second) // PTT Release err = terminalClient.PTTRelease(callRef) if err != nil { panic(err) } time.Sleep(3 * time.Second) err = terminalClient.CallDisconnect(callRef, common.DisconnectReason_CallRejectedByCalled) if err != nil { panic(err) } // IpApiCallPttRequest }() // idk send help xD for { select { case parsedMsg := <-terminalClient.RX: fmt.Println(hex.EncodeToString(parsedMsg.Bytes())) if parsedMsg.Kind == tmkind.IpApiAuthenticationChallenge { authChall, err := parsedMsg.AsAuthenticationChallenge() if err != nil { panic(err) } if authChall.PinRequested { fmt.Println("Sending Auth Pin") //terminalClient.SendTM() } } } } }