|
|
@ -1,10 +1,13 @@
|
|
|
|
package main
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"bufio"
|
|
|
|
"encoding/hex"
|
|
|
|
"encoding/hex"
|
|
|
|
"encoding/json"
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"math/rand"
|
|
|
|
"math/rand"
|
|
|
|
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"git.cheetah.cat/cheetah/opentetraflex-go/common"
|
|
|
|
"git.cheetah.cat/cheetah/opentetraflex-go/common"
|
|
|
@ -26,7 +29,7 @@ func main() {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
myAddr := common.TetraFlexAddress{
|
|
|
|
myAddr := common.TetraFlexAddress{
|
|
|
|
Kind: common.UserNo,
|
|
|
|
Kind: common.UserNo,
|
|
|
|
UserNo: "1005",
|
|
|
|
UserNo: "9400001",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err = terminalClient.Authenticate(myAddr)
|
|
|
|
err = terminalClient.Authenticate(myAddr)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -69,19 +72,17 @@ func main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fmt.Println("Groups attached")
|
|
|
|
fmt.Println("Groups attached")
|
|
|
|
go func() {
|
|
|
|
go func() {
|
|
|
|
fmt.Println("Test started, waiting 3s")
|
|
|
|
|
|
|
|
time.Sleep(3 * time.Second)
|
|
|
|
|
|
|
|
groupAddr := common.NewAddressFromSSINumber(101)
|
|
|
|
groupAddr := common.NewAddressFromSSINumber(101)
|
|
|
|
fmt.Println("Test callSetup")
|
|
|
|
fmt.Println("Test callSetup")
|
|
|
|
callRef, err := terminalClient.CallSetup(*groupAddr, common.CallTypeGroup, common.CallPriorityDefault, false, common.TetraFlexIdentityInfo{
|
|
|
|
callRef, err := terminalClient.CallSetup(*groupAddr, common.CallTypeGroup, common.CallPriorityDefault, false, common.TetraFlexIdentityInfo{
|
|
|
|
Description: "Blaa",
|
|
|
|
Description: "2m/FM Gateway SWM",
|
|
|
|
|
|
|
|
|
|
|
|
/* Kind: common.IdentityKindApplication,
|
|
|
|
/* Kind: common.IdentityKindApplication,
|
|
|
|
Address: *common.NewAddressFromSSINumber(1002),
|
|
|
|
Address: *common.NewAddressFromSSINumber(1002),
|
|
|
|
UnifiedSSIKinds: common.UnifiedKindExternalNumber,
|
|
|
|
UnifiedSSIKinds: common.UnifiedKindExternalNumber,
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
Kind: common.IdentityKindTerminal,
|
|
|
|
Kind: common.IdentityKindTerminal,
|
|
|
|
Address: *common.NewAddressFromSSINumber(1002),
|
|
|
|
Address: *common.NewAddressFromSSINumber(9400001),
|
|
|
|
UnifiedSSIKinds: common.UnifiedKindPersonalNumber,
|
|
|
|
UnifiedSSIKinds: common.UnifiedKindPersonalNumber,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -89,6 +90,11 @@ func main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fmt.Printf("callRef=%d\n", callRef)
|
|
|
|
fmt.Printf("callRef=%d\n", callRef)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err = terminalClient.CallStreamRequest(0, callRef, 0, common.AudioChannel_CMoIP_Tetra) // CMoIP_aLaw
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
panic(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// IpApiCallStreamRequest
|
|
|
|
// IpApiCallStreamRequest
|
|
|
|
err = terminalClient.PTTRequest(callRef, common.TetraFlexIdentityInfo{
|
|
|
|
err = terminalClient.PTTRequest(callRef, common.TetraFlexIdentityInfo{
|
|
|
|
Description: "Blaa",
|
|
|
|
Description: "Blaa",
|
|
|
@ -104,6 +110,48 @@ func main() {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Connect RTP
|
|
|
|
|
|
|
|
err = terminalClient.RTPConnect()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
panic(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file, err := os.Open("./test.tetra.txt")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
panic(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
defer file.Close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scanner := bufio.NewScanner(file)
|
|
|
|
|
|
|
|
var counter byte = 0
|
|
|
|
|
|
|
|
var voiceArray [][]byte
|
|
|
|
|
|
|
|
for scanner.Scan() {
|
|
|
|
|
|
|
|
hexData := scanner.Text()
|
|
|
|
|
|
|
|
hexData = strings.Trim(hexData, " ")
|
|
|
|
|
|
|
|
byteData, _ := hex.DecodeString(hexData)
|
|
|
|
|
|
|
|
fmt.Println(hexData)
|
|
|
|
|
|
|
|
voiceArray = append(voiceArray, byteData)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for {
|
|
|
|
|
|
|
|
for _, byteData := range voiceArray {
|
|
|
|
|
|
|
|
fmt.Println(byteData)
|
|
|
|
|
|
|
|
byteData[8] = counter
|
|
|
|
|
|
|
|
err = terminalClient.RTPSend(byteData)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
panic(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if counter == 255 {
|
|
|
|
|
|
|
|
counter = 128
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
counter++
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
time.Sleep(20 * time.Millisecond)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
time.Sleep(3 * time.Second)
|
|
|
|
time.Sleep(3 * time.Second)
|
|
|
|
// PTT Release
|
|
|
|
// PTT Release
|
|
|
|
err = terminalClient.PTTRelease(callRef)
|
|
|
|
err = terminalClient.PTTRelease(callRef)
|
|
|
@ -116,6 +164,8 @@ func main() {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
// IpApiCallPttRequest
|
|
|
|
// IpApiCallPttRequest
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
// idk send help xD
|
|
|
|
// idk send help xD
|
|
|
|