just missing rtp streams

master
cheetah 1 year ago
parent 8ad96dce26
commit ad701f7a97

@ -0,0 +1,34 @@
package common
type TetraFlexCallDisconnectCauses byte
const (
DisconnectReason_NotDisconnected TetraFlexCallDisconnectCauses = 255
DisconnectReason_Unknown TetraFlexCallDisconnectCauses = 0
DisconnectReason_UserRequested TetraFlexCallDisconnectCauses = 1
DisconnectReason_CalledPartyBusy TetraFlexCallDisconnectCauses = 2
DisconnectReason_CalledPartyNotReachable TetraFlexCallDisconnectCauses = 3
DisconnectReason_CalledPartyNotSupportEncryption TetraFlexCallDisconnectCauses = 4
DisconnectReason_Congestion TetraFlexCallDisconnectCauses = 5
DisconnectReason_NotAllowedTrafficCase TetraFlexCallDisconnectCauses = 6
DisconnectReason_IncompatibleTrafficCase TetraFlexCallDisconnectCauses = 7
DisconnectReason_RequestedServiceNotAvailable TetraFlexCallDisconnectCauses = 8
DisconnectReason_PreEmptiveUseResource TetraFlexCallDisconnectCauses = 9
DisconnectReason_InvalidCallIdentifier TetraFlexCallDisconnectCauses = 10
DisconnectReason_CallRejectedByCalled TetraFlexCallDisconnectCauses = 11
DisconnectReason_NoIdleCCEntity TetraFlexCallDisconnectCauses = 12
DisconnectReason_ExpiryTimer TetraFlexCallDisconnectCauses = 13
DisconnectReason_SwMIRequestedDisconnection TetraFlexCallDisconnectCauses = 14
DisconnectReason_AcknowledgedServiceNotCompleted TetraFlexCallDisconnectCauses = 15
DisconnectReason_UnknownTetraIdentity TetraFlexCallDisconnectCauses = 16
DisconnectReason_SSSpecificDisconnection TetraFlexCallDisconnectCauses = 17
DisconnectReason_UnknownExternalSubscriberIdentity TetraFlexCallDisconnectCauses = 18
DisconnectReason_CallRestorationOthersFailed TetraFlexCallDisconnectCauses = 19
DisconnectReason_CalledPartyRequiresEncryption TetraFlexCallDisconnectCauses = 20
DisconnectReason_ConcurrentSetupNotSupported TetraFlexCallDisconnectCauses = 21
DisconnectReason_CalledPartySameDM TetraFlexCallDisconnectCauses = 22
DisconnectReason_NonCallOwnerRequestedDisconnection TetraFlexCallDisconnectCauses = 23
DisconnectReason_CallCompletedElsewhere TetraFlexCallDisconnectCauses = 32
DisconnectReason_NetworkFailure TetraFlexCallDisconnectCauses = 100
DisconnectReason_IgnoreCallSilently TetraFlexCallDisconnectCauses = 255
)

@ -103,7 +103,7 @@ func (tc *TerminalClient) SubscribeEvents(messageTypes []tmkind.TetraFlexTermina
func (tc *TerminalClient) AttachGroups(groups []GroupConfig) (err error) {
tfGroupAttachReq, err := NewTMIpApiGroupAttachRequest(groups)
if err != nil {
panic(err)
return nil
}
fmt.Println(hex.EncodeToString(tfGroupAttachReq.Encode()))
tc.HandlerMap[tfGroupAttachReq.handler] = make(chan HandlerResponse)
@ -120,13 +120,110 @@ func (tc *TerminalClient) AttachGroups(groups []GroupConfig) (err error) {
return nil
}
func (tc *TerminalClient) CallSetup(address TetraFlexAddress, callType TetraFlexCallTypes, callPriority TetraFlexCallPriorities, hookCall bool, identityInfo TetraFlexIdentityInfo) (err error) {
//
func (tc *TerminalClient) CallSetup(address TetraFlexAddress, callType TetraFlexCallTypes, callPriority TetraFlexCallPriorities, hookCall bool, identityInfo TetraFlexIdentityInfo) (callRef byte, err error) {
tfCallSetupReq, err := NewTMIpApiCallSetupRequest(address, callType, callPriority, hookCall, identityInfo)
if err != nil {
return callRef, err
}
fmt.Println(hex.EncodeToString(tfCallSetupReq.Encode()))
tc.HandlerMap[tfCallSetupReq.handler] = make(chan HandlerResponse)
//fmt.Println(hex.EncodeToString(tfAuthReq.Encode()))
err = tc.Send(tfCallSetupReq)
if err != nil {
return callRef, err
}
response := <-tc.HandlerMap[tfCallSetupReq.handler]
if !response.Success {
return callRef, response.Error
}
//fmt.Println(hex.EncodeToString(response.TMR.payload))
callRef, err = response.TMR.readByte()
if err != nil {
return callRef, err
}
return callRef, nil
}
func (tc *TerminalClient) CallDisconnect(callRef byte, disconnectCause TetraFlexCallDisconnectCauses) (err error) {
tfCallDisconnectReq, err := NewTMIpApiCallDisconnectRequest(callRef, disconnectCause)
if err != nil {
return nil
}
fmt.Println(hex.EncodeToString(tfCallDisconnectReq.Encode()))
tc.HandlerMap[tfCallDisconnectReq.handler] = make(chan HandlerResponse)
//fmt.Println(hex.EncodeToString(tfAuthReq.Encode()))
err = tc.Send(tfCallDisconnectReq)
if err != nil {
return err
}
response := <-tc.HandlerMap[tfCallDisconnectReq.handler]
if !response.Success {
return response.Error
}
return nil
}
func (tc *TerminalClient) CallConnect(callRef byte) (err error) {
tfCallConnectReq, err := NewTMIpApiCallConnectRequest(callRef)
if err != nil {
return nil
}
fmt.Println(hex.EncodeToString(tfCallConnectReq.Encode()))
tc.HandlerMap[tfCallConnectReq.handler] = make(chan HandlerResponse)
func (tc *TerminalClient) PTTRequest() {
//fmt.Println(hex.EncodeToString(tfAuthReq.Encode()))
err = tc.Send(tfCallConnectReq)
if err != nil {
return err
}
response := <-tc.HandlerMap[tfCallConnectReq.handler]
if !response.Success {
return response.Error
}
return nil
}
func (tc *TerminalClient) PTTRequest(callRef byte, identityInfo TetraFlexIdentityInfo, octaStateByte byte) (err error) {
// IpApiCallPttRequest
tfPTTRequest, err := NewTMIpApiCallPTTRequest(callRef, identityInfo, octaStateByte)
if err != nil {
return err
}
fmt.Println(hex.EncodeToString(tfPTTRequest.Encode()))
tc.HandlerMap[tfPTTRequest.handler] = make(chan HandlerResponse)
//fmt.Println(hex.EncodeToString(tfAuthReq.Encode()))
err = tc.Send(tfPTTRequest)
if err != nil {
return err
}
response := <-tc.HandlerMap[tfPTTRequest.handler]
if !response.Success {
return response.Error
}
return nil
}
func (tc *TerminalClient) PTTRelease(callRef byte) (err error) {
// IpApiCallPttRequest
tfPTTRelease, err := NewTMIpApiCallPTTRelease(callRef)
if err != nil {
return err
}
fmt.Println(hex.EncodeToString(tfPTTRelease.Encode()))
tc.HandlerMap[tfPTTRelease.handler] = make(chan HandlerResponse)
//fmt.Println(hex.EncodeToString(tfAuthReq.Encode()))
err = tc.Send(tfPTTRelease)
if err != nil {
return err
}
response := <-tc.HandlerMap[tfPTTRelease.handler]
if !response.Success {
return response.Error
}
return nil
}
/*
@ -134,6 +231,8 @@ groupAddr := common.NewAddressFromSSINumber(103)
identityNum := common.NewAddressFromSSINumber(1007)
response, err = common.NewTMIpApiCallSetupRequest(*groupAddr, common.CallTypeGroup, common.CallPriorityDefault, false, common.TetraFlexIdentityInfo{
Description: "blurb",
Kind: common.IdentityKindTerminal,
Address: *identityNum,

@ -321,20 +321,6 @@ func NewTMIpApiGroupAttachRequest(groupConfig []GroupConfig) (tm *TerminalMessag
return terminalMessage, nil
}
func NewTMIpApiCallConnectRequest(callRef byte) (tm *TerminalMessage, err error) {
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 {
@ -414,6 +400,35 @@ func NewTMIpApiCallSetupRequest(address TetraFlexAddress, callType TetraFlexCall
}
return terminalMessage, nil
}
func NewTMIpApiCallConnectRequest(callRef byte) (tm *TerminalMessage, err error) {
terminalMessage, err := NewTerminalMessage(64, tmkind.IpApiCallConnectRequest, NextHandlerID())
if err != nil {
return nil, err
}
if err = terminalMessage.WriteByte(callRef); err != nil {
return nil, err
}
if err = terminalMessage.FillZero(55); err != nil {
return nil, err
}
return terminalMessage, nil
}
func NewTMIpApiCallDisconnectRequest(callRef byte, disconnectCause TetraFlexCallDisconnectCauses) (tm *TerminalMessage, err error) {
terminalMessage, err := NewTerminalMessage(64, tmkind.IpApiCallDisconnectRequest, NextHandlerID())
if err != nil {
return nil, err
}
if err = terminalMessage.WriteByte(callRef); err != nil {
return nil, err
}
if err = terminalMessage.WriteByte(byte(disconnectCause)); err != nil {
return nil, err
}
if err = terminalMessage.FillZero(54); err != nil {
return nil, err
}
return terminalMessage, nil
}
func NewTMIpApiCallStreamRequest(uint1 uint, callRef byte, streamRef byte, audioChannelType TetraFlexAudioChannelTypes) (tm *TerminalMessage, err error) {
terminalMessage, err := NewTerminalMessage(64, tmkind.IpApiCallStreamRequest, NextHandlerID())
if err != nil {
@ -510,3 +525,38 @@ func NewTMIpApiCallPTTRequest(callRef byte, identityInfo TetraFlexIdentityInfo,
}
return terminalMessage, nil
}
func NewTMIpApiCallPTTRelease(callRef 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(255); err != nil {
return nil, err
}
if err = terminalMessage.FillZero(2); err != nil {
return nil, err
}
//WriteIdentityInfoAddress
if err = terminalMessage.WriteTFAddress(TetraFlexAddressEmpty); err != nil {
return nil, err
}
//WriteIdentityInfoDescr (protoHelper1:334)
if err = terminalMessage.WriteString("", 64); err != nil {
return nil, err
}
//WriteIdentityInfoKind
if err = terminalMessage.WriteByte(0); err != nil {
return nil, err
}
//WriteIdentityInfoUnfied ()
if err = terminalMessage.WriteByte(0); err != nil {
return nil, err
}
if err = terminalMessage.FillZero(10); err != nil {
return nil, err
}
return terminalMessage, nil
}

@ -16,14 +16,14 @@ func main() {
rand.Seed(time.Now().UnixNano())
var err error
terminalClient := common.NewTerminalClient("192.168.133.106:42381")
//data := make([]byte, 256)
terminalClient := common.NewTerminalClient("192.168.133.106:42381")
//
err = terminalClient.Connect()
if err != nil {
panic(err)
}
//
myAddr := common.TetraFlexAddress{
Kind: common.UserNo,
UserNo: "1005",
@ -32,7 +32,7 @@ func main() {
if err != nil {
panic(err)
}
//
err = terminalClient.SubscribeEvents([]tmkind.TetraFlexTerminalMessageKinds{
tmkind.IpApiCallUpdateNotification,
tmkind.IpApiSdsTlReportNotification,
@ -44,6 +44,8 @@ func main() {
if err != nil {
panic(err)
}
//
//fmt.Println(hex.EncodeToString(parsedMsg.Bytes()))
regInfoBytes, _ := json.Marshal(terminalClient.RegistrationInfo)
fmt.Println(string(regInfoBytes))
@ -65,7 +67,58 @@ func main() {
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:
@ -80,7 +133,6 @@ func main() {
//terminalClient.SendTM()
}
}
//if parsedMsg.Kind == tmkind.IpApiNo
}
}
}

Loading…
Cancel
Save