|
|
|
@ -1,10 +1,13 @@
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"bufio"
|
|
|
|
|
"encoding/hex"
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
|
|
|
|
"math/rand"
|
|
|
|
|
"os"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"git.cheetah.cat/cheetah/opentetraflex-go/common"
|
|
|
|
@ -26,7 +29,7 @@ func main() {
|
|
|
|
|
//
|
|
|
|
|
myAddr := common.TetraFlexAddress{
|
|
|
|
|
Kind: common.UserNo,
|
|
|
|
|
UserNo: "1005",
|
|
|
|
|
UserNo: "9400001",
|
|
|
|
|
}
|
|
|
|
|
err = terminalClient.Authenticate(myAddr)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -69,19 +72,17 @@ func main() {
|
|
|
|
|
}
|
|
|
|
|
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",
|
|
|
|
|
Description: "2m/FM Gateway SWM",
|
|
|
|
|
|
|
|
|
|
/* Kind: common.IdentityKindApplication,
|
|
|
|
|
Address: *common.NewAddressFromSSINumber(1002),
|
|
|
|
|
UnifiedSSIKinds: common.UnifiedKindExternalNumber,
|
|
|
|
|
*/
|
|
|
|
|
Kind: common.IdentityKindTerminal,
|
|
|
|
|
Address: *common.NewAddressFromSSINumber(1002),
|
|
|
|
|
Address: *common.NewAddressFromSSINumber(9400001),
|
|
|
|
|
UnifiedSSIKinds: common.UnifiedKindPersonalNumber,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
@ -89,6 +90,11 @@ func main() {
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("callRef=%d\n", callRef)
|
|
|
|
|
|
|
|
|
|
err = terminalClient.CallStreamRequest(0, callRef, 0, common.AudioChannel_CMoIP_Tetra) // CMoIP_aLaw
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IpApiCallStreamRequest
|
|
|
|
|
err = terminalClient.PTTRequest(callRef, common.TetraFlexIdentityInfo{
|
|
|
|
|
Description: "Blaa",
|
|
|
|
@ -104,6 +110,48 @@ func main() {
|
|
|
|
|
if err != nil {
|
|
|
|
|
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)
|
|
|
|
|
// PTT Release
|
|
|
|
|
err = terminalClient.PTTRelease(callRef)
|
|
|
|
@ -116,6 +164,8 @@ func main() {
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
// IpApiCallPttRequest
|
|
|
|
|
}()
|
|
|
|
|
// idk send help xD
|
|
|
|
|