Skip to content

Commit

Permalink
added repeater playing functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
talkkonnect committed Jan 22, 2021
1 parent 02096b7 commit 28b7f4d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 18 deletions.
26 changes: 13 additions & 13 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ var (
GPSLongitude float64
Streaming bool
ServerHop bool
httpServRunning bool
HTTPServRunning bool
message string
isrepeattx bool = true
NowStreaming bool
Expand Down Expand Up @@ -119,7 +119,7 @@ type ChannelsListStruct struct {
chanUsers int
}

func PreInit0(file string, ServerIndex string) {
func Init(file string, ServerIndex string) {
err := term.Init()
if err != nil {
log.Println("error: Cannot Initalize Terminal Error: ", err)
Expand Down Expand Up @@ -208,10 +208,6 @@ func PreInit0(file string, ServerIndex string) {
log.Printf("info: MQTT Server Subscription Diabled in Config")
}

b.PreInit1(false)
}

func (b *Talkkonnect) PreInit1(httpServRunning bool) {
if len(b.Username) == 0 {
buf := make([]byte, 6)
_, err := rand.Read(buf)
Expand Down Expand Up @@ -240,7 +236,7 @@ func (b *Talkkonnect) PreInit1(httpServRunning bool) {
b.TLSConfig.Certificates = append(b.TLSConfig.Certificates, cert)
}

if APIEnabled && !httpServRunning {
if APIEnabled && !HTTPServRunning {
go func() {
http.HandleFunc("/", b.httpAPI)

Expand All @@ -251,7 +247,7 @@ func (b *Talkkonnect) PreInit1(httpServRunning bool) {
}()
}

b.Init()
b.ClientStart()
IsConnected = false

sigs := make(chan os.Signal, 1)
Expand All @@ -263,12 +259,12 @@ func (b *Talkkonnect) PreInit1(httpServRunning bool) {
os.Exit(exitStatus)
}

func (b *Talkkonnect) Init() {
func (b *Talkkonnect) ClientStart() {
f, err := os.OpenFile(LogFilenameAndPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
log.Println("info: Trying to Open File ", LogFilenameAndPath)
if err != nil {
log.Println("error: Problem opening talkkonnect.log file Error: ", err)
log.Fatal("Exiting talkkonnect! ...... bye!\n")
log.Fatal("Exiting talkkonnect! ...... Happy Talkkonnecting, Bye!\n")
}

if TargetBoard == "rpi" {
Expand Down Expand Up @@ -511,6 +507,10 @@ keyPressListenerLoop:
b.cmdConnNextServer()
case term.KeyCtrlP:
b.cmdPanicSimulation()
case term.KeyCtrlQ:
b.cmdPlayRepeaterTone()
time.Sleep(1 * time.Second)
b.cmdPlayRepeaterTone()
case term.KeyCtrlR:
b.cmdRepeatTxLoop()
case term.KeyCtrlS:
Expand All @@ -525,14 +525,14 @@ keyPressListenerLoop:
b.cmdDumpXMLConfig()
default:
if ev.Ch != 0 {
log.Println("error: Invalid Keypress ASCII", ev.Ch)
log.Println("error: Invalid Keypress ASCII ", ev.Ch, "Press <DEL> for Menu")
} else {
log.Println("error: Key Not Mapped")
log.Println("error: Key Not Mapped, Press <DEL> for menu")
}
}
case term.EventError:
log.Println("error: Terminal Error: ", ev.Err)
log.Fatal("Exiting talkkonnect! ...... bye!\n")
log.Fatal("Exiting talkkonnect!\n")
}

}
Expand Down
2 changes: 1 addition & 1 deletion cmd/talkkonnect/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func main() {
f.Close()
}

talkkonnect.PreInit0(*config, *serverindex)
talkkonnect.Init(*config, *serverindex)



Expand Down
20 changes: 19 additions & 1 deletion commandkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ func (b *Talkkonnect) cmdPingServers() {

func (b *Talkkonnect) cmdConnNextServer() {
log.Println("debug: Ctrl-N Pressed")
log.Println("info: Next Server Requested")
log.Println("info: Next Server Requested Killing This Session, talkkonnect should be restarted by systemd")

if TTSEnabled && TTSNextServer {
err := PlayWavLocal(TTSNextServerFilenameAndPath, TTSVolumeLevel)
Expand Down Expand Up @@ -821,3 +821,21 @@ func (b *Talkkonnect) cmdDumpXMLConfig() {

printxmlconfig()
}

func (b *Talkkonnect) cmdPlayRepeaterTone() {
log.Println("debug: Ctrl-Q Pressed")
log.Println("info: Play Repeater Tone File into Stream")

b.BackLightTimer()

if b.IsTransmitting {
log.Println("alert: talkkonnect was already transmitting will now stop transmitting and start to play the repeater tone")
b.TransmitStop(false)
}

go b.playIntoStream(RepeaterToneFilenameAndPath, RepeaterToneVolume)

IsPlayStream = !IsPlayStream
// NowStreaming = IsPlayStream

}
4 changes: 2 additions & 2 deletions talkkonnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (b *Talkkonnect) talkkonnectMenu(backgroundcolor string) {
log.Println("info: " + backgroundcolor + "│<Ctrl-D> Debug Stacktrace │ │" + backgroundreset)
log.Println("info: " + backgroundcolor + "│<Ctrl-E> Send Email │<Ctrl-N> Conn Next Server │" + backgroundreset)
log.Println("info: " + backgroundcolor + "│<Ctrl-F> Conn Previous Server│<Ctrl-P> Panic Simulation │" + backgroundreset)
log.Println("info: " + backgroundcolor + "│<Ctrl-Q> Reserved │<Ctrl-S> Scan Channels │" + backgroundreset)
log.Println("info: " + backgroundcolor + "│<Ctrl-Q> Send Repeater Tone │<Ctrl-S> Scan Channels │" + backgroundreset)
log.Println("info: " + backgroundcolor + "│<Ctrl-V> Display Version │<Ctrl-T> Thanks/Acknowledgements│" + backgroundreset)
log.Println("info: " + backgroundcolor + "├─────────────────────────────┼────────────────────────────────┤" + backgroundreset)
log.Println("info: " + backgroundcolor + "│<Ctrl-L> Clear Screen │<Ctrl-O> Ping Servers │" + backgroundreset)
Expand All @@ -111,7 +111,7 @@ func (b *Talkkonnect) talkkonnectMenu(backgroundcolor string) {
log.Println("info: IP Address & Session Information")
b.pingconnectedserver()
localAddresses()

log.Println("info: Internet WAN IP Is", GetOutboundIP())
origMuted, _ := volume.GetMuted(OutputDevice)
if origMuted {
log.Println("info: Speaker Currently Muted")
Expand Down
10 changes: 10 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"errors"
"flag"
"fmt"
"github.com/glendc/go-external-ip"
"github.com/kennygrant/sanitize"
"github.com/talkkonnect/gumble/gumble"
term "github.com/talkkonnect/termbox-go"
Expand Down Expand Up @@ -556,3 +557,12 @@ func getMacAddr() ([]string, error) {
}
return as, nil
}

func GetOutboundIP() string {
consensus := externalip.DefaultConsensus(nil, nil)
ip, err := consensus.ExternalIP()
if err == nil {
return ip.String()
}
return "Could Not Get Public WAN IP"
}
2 changes: 1 addition & 1 deletion xmlparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import (

//version and release date
const (
talkkonnectVersion string = "1.56.04"
talkkonnectVersion string = "1.56.05"
talkkonnectReleased string = "January 22 2021"
)

Expand Down

0 comments on commit 28b7f4d

Please sign in to comment.