|
|
@ -2,9 +2,15 @@ package common
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"bytes"
|
|
|
|
"test/common/tmkind"
|
|
|
|
"math/rand"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"git.cheetah.cat/cheetah/opentetraflex-go/common/tmkind"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func NextHandlerID() uint32 {
|
|
|
|
|
|
|
|
return uint32(rand.Int())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type TerminalMessage struct {
|
|
|
|
type TerminalMessage struct {
|
|
|
|
length uint16
|
|
|
|
length uint16
|
|
|
|
kind tmkind.TetraFlexTerminalMessageKinds
|
|
|
|
kind tmkind.TetraFlexTerminalMessageKinds
|
|
|
@ -180,7 +186,7 @@ func (tm *TerminalMessage) Encode() []byte {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewTMAuthReq(addr TetraFlexAddress, num uint32, randomBytes []byte, terminalTypeID byte, terminalTypeStr string, terminalVersionDate uint32, terminalVersionStr string) (tm *TerminalMessage, err error) {
|
|
|
|
func NewTMAuthReq(addr TetraFlexAddress, num uint32, randomBytes []byte, terminalTypeID byte, terminalTypeStr string, terminalVersionDate uint32, terminalVersionStr string) (tm *TerminalMessage, err error) {
|
|
|
|
tfAuthReq, err := NewTerminalMessage(256, tmkind.IpApiRegistrationRequest, 0)
|
|
|
|
tfAuthReq, err := NewTerminalMessage(256, tmkind.IpApiRegistrationRequest, NextHandlerID())
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -227,7 +233,7 @@ func NewTMAuthReq(addr TetraFlexAddress, num uint32, randomBytes []byte, termina
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func NewTMKeepAliveResponse(challenge KeepAliveChallenge) (tm *TerminalMessage, err error) {
|
|
|
|
func NewTMKeepAliveResponse(challenge KeepAliveChallenge) (tm *TerminalMessage, err error) {
|
|
|
|
response := KeepAliveResponse{}
|
|
|
|
response := KeepAliveResponse{}
|
|
|
|
terminalMessage, err := NewTerminalMessage(64, tmkind.IpApiKeepAliveResponse, 0)
|
|
|
|
terminalMessage, err := NewTerminalMessage(64, tmkind.IpApiKeepAliveResponse, NextHandlerID())
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -258,7 +264,7 @@ func NewTMKeepAliveResponse(challenge KeepAliveChallenge) (tm *TerminalMessage,
|
|
|
|
return terminalMessage, nil
|
|
|
|
return terminalMessage, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func NewTMNotificationRequest(messageTypes []tmkind.TetraFlexTerminalMessageKinds) (tm *TerminalMessage, err error) {
|
|
|
|
func NewTMNotificationRequest(messageTypes []tmkind.TetraFlexTerminalMessageKinds) (tm *TerminalMessage, err error) {
|
|
|
|
terminalMessage, err := NewTerminalMessage(128, tmkind.IpApiNotificationRequest, 0)
|
|
|
|
terminalMessage, err := NewTerminalMessage(128, tmkind.IpApiNotificationRequest, NextHandlerID())
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -290,7 +296,7 @@ func NewTMNotificationRequest(messageTypes []tmkind.TetraFlexTerminalMessageKind
|
|
|
|
return terminalMessage, nil
|
|
|
|
return terminalMessage, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func NewTMIpApiGroupAttachRequest(groupConfig []GroupConfig) (tm *TerminalMessage, err error) {
|
|
|
|
func NewTMIpApiGroupAttachRequest(groupConfig []GroupConfig) (tm *TerminalMessage, err error) {
|
|
|
|
terminalMessage, err := NewTerminalMessage(384, tmkind.IpApiGroupAttachRequest, 0)
|
|
|
|
terminalMessage, err := NewTerminalMessage(384, tmkind.IpApiGroupAttachRequest, NextHandlerID())
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -315,8 +321,49 @@ func NewTMIpApiGroupAttachRequest(groupConfig []GroupConfig) (tm *TerminalMessag
|
|
|
|
return terminalMessage, nil
|
|
|
|
return terminalMessage, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewTMIpApiCallSetupRequest(address TetraFlexAddress, callType TetraFlexCallTypes, callPriority TetraFlexCallPriorities, idkBool bool, identityInfo TetraFlexIdentityInfo) (tm *TerminalMessage, err error) {
|
|
|
|
func NewTMIpApiCallConnectRequest(callRef byte) (tm *TerminalMessage, err error) {
|
|
|
|
terminalMessage, err := NewTerminalMessage(192, tmkind.IpApiCallSetupRequest, 0)
|
|
|
|
terminalMessage, err := NewTerminalMessage(64, tmkind.IpApiCallConnectRequest, NextHandlerID())
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if err = terminalMessage.WriteByte(callRef); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Fill 55
|
|
|
|
|
|
|
|
if err = terminalMessage.FillZero(55); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return terminalMessage, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewTMIpApiSoftwareInfoRequest(ref byte) (tm *TerminalMessage, err error) {
|
|
|
|
|
|
|
|
terminalMessage, err := NewTerminalMessage(64, tmkind.IpApiSoftwareInfoRequest, NextHandlerID())
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if err = terminalMessage.WriteByte(ref); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//Fill 55
|
|
|
|
|
|
|
|
if err = terminalMessage.FillZero(55); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return terminalMessage, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewTMIpApiSubscriberInfoRequest(address TetraFlexAddress) (tm *TerminalMessage, err error) {
|
|
|
|
|
|
|
|
terminalMessage, err := NewTerminalMessage(64, tmkind.IpApiSubscriberInfoRequest, NextHandlerID())
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if err = terminalMessage.WriteTFAddress(address); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if err = terminalMessage.FillZero(16); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return terminalMessage, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewTMIpApiCallSetupRequest(address TetraFlexAddress, callType TetraFlexCallTypes, callPriority TetraFlexCallPriorities, hookCall bool, identityInfo TetraFlexIdentityInfo) (tm *TerminalMessage, err error) {
|
|
|
|
|
|
|
|
terminalMessage, err := NewTerminalMessage(192, tmkind.IpApiCallSetupRequest, NextHandlerID())
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -329,7 +376,7 @@ func NewTMIpApiCallSetupRequest(address TetraFlexAddress, callType TetraFlexCall
|
|
|
|
if err = terminalMessage.WriteByte(byte(callPriority)); err != nil {
|
|
|
|
if err = terminalMessage.WriteByte(byte(callPriority)); err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if idkBool {
|
|
|
|
if hookCall {
|
|
|
|
if err = terminalMessage.WriteByte(4); err != nil {
|
|
|
|
if err = terminalMessage.WriteByte(4); err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -367,9 +414,8 @@ func NewTMIpApiCallSetupRequest(address TetraFlexAddress, callType TetraFlexCall
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return terminalMessage, nil
|
|
|
|
return terminalMessage, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewTMIpApiCallStreamRequest(uint1 uint, callRef byte, streamRef byte, audioChannelType TetraFlexAudioChannelTypes) (tm *TerminalMessage, err error) {
|
|
|
|
func NewTMSendIpApiCallStreamRequest(uint1 uint, callRef byte, streamRef byte, audioChannelType TetraFlexAudioChannelTypes) (tm *TerminalMessage, err error) {
|
|
|
|
terminalMessage, err := NewTerminalMessage(64, tmkind.IpApiCallStreamRequest, NextHandlerID())
|
|
|
|
terminalMessage, err := NewTerminalMessage(64, tmkind.IpApiCallStreamRequest, 0)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -429,3 +475,38 @@ func NewTMSendIpApiCallStreamRequest(uint1 uint, callRef byte, streamRef byte, a
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return terminalMessage, nil
|
|
|
|
return terminalMessage, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewTMIpApiCallPTTRequest(callRef byte, identityInfo TetraFlexIdentityInfo, octaStateByte byte) (tm *TerminalMessage, err error) {
|
|
|
|
|
|
|
|
terminalMessage, err := NewTerminalMessage(128, tmkind.IpApiCallPttRequest, NextHandlerID())
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if err = terminalMessage.WriteByte(callRef); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if err = terminalMessage.WriteByte(octaStateByte); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if err = terminalMessage.FillZero(2); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//WriteIdentityInfoAddress
|
|
|
|
|
|
|
|
if err = terminalMessage.WriteIdentityInfoAddress(identityInfo); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//WriteIdentityInfoDescr (protoHelper1:334)
|
|
|
|
|
|
|
|
if err = terminalMessage.WriteString(identityInfo.Description, 64); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//WriteIdentityInfoKind
|
|
|
|
|
|
|
|
if err = terminalMessage.WriteIdentityInfoKind(identityInfo); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//WriteIdentityInfoUnfied ()
|
|
|
|
|
|
|
|
if err = terminalMessage.WriteIdentityInfoUnfied(identityInfo); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if err = terminalMessage.FillZero(10); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return terminalMessage, nil
|
|
|
|
|
|
|
|
}
|
|
|
|