Skip to content

Commit

Permalink
cleanup and add new features
Browse files Browse the repository at this point in the history
  • Loading branch information
talkkonnect committed Jan 5, 2022
1 parent bf89be6 commit 59d9d0c
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 160 deletions.
2 changes: 1 addition & 1 deletion autoprovision.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func autoProvision() error {

fileURL := Config.Global.Software.AutoProvisioning.URL + Config.Global.Software.AutoProvisioning.TkID
log.Println("info: Trying to Autoprovision with URL: ", fileURL)
err := downloadFile(Config.Global.Software.AutoProvisioning.SaveFilePath, "talkkonnect.xml", fileURL)
err := downloadFile(Config.Global.Software.AutoProvisioning.SaveFilePath, Config.Global.Software.AutoProvisioning.SaveFilename, fileURL)
if err != nil {
return fmt.Errorf("error: DownloadFile Module Returned an Error: %q", err.Error())
}
Expand Down
11 changes: 8 additions & 3 deletions commandkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (b *Talkkonnect) cmdVolumeUp() {
}

if origVolume < 100 {
err := volume.IncreaseVolume(+1, Config.Global.Software.Settings.OutputVolControlDevice)
err := volume.IncreaseVolume(Config.Global.Hardware.IO.VolumeButtonStep.VolUpStep, Config.Global.Software.Settings.OutputVolControlDevice)
if err != nil {
log.Println("warn: F5 Increase Volume Failed! ", err)
}
Expand Down Expand Up @@ -226,7 +226,7 @@ func (b *Talkkonnect) cmdVolumeDown() {

if origVolume > 0 {
origVolume--
err := volume.IncreaseVolume(-1, Config.Global.Software.Settings.OutputVolControlDevice)
err := volume.IncreaseVolume(Config.Global.Hardware.IO.VolumeButtonStep.VolDownStep, Config.Global.Software.Settings.OutputVolControlDevice)
if err != nil {
log.Println("error: F6 Decrease Volume Failed! ", err)
}
Expand Down Expand Up @@ -752,7 +752,12 @@ func (b *Talkkonnect) cmdShowUptime() {
func (b *Talkkonnect) cmdDisplayVersion() {
log.Println("debug: Ctrl-V Pressed")
log.Println("info: Talkkonnect Version Request ")
log.Printf("info: Talkkonnect Version %v Released %v\n", talkkonnectVersion, talkkonnectReleased)
releasedVersion := checkGitHubVersion()
if talkkonnectVersion != releasedVersion {
log.Printf("warn: Ver %v Rel %v (Newer Ver %v Available!)\n", talkkonnectVersion, talkkonnectReleased, releasedVersion)
} else {
log.Printf("info: Ver %v Rel %v (Latest Release)\n", talkkonnectVersion, talkkonnectReleased)
}
}

func (b *Talkkonnect) cmdDumpXMLConfig() {
Expand Down
104 changes: 18 additions & 86 deletions gpio.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,7 @@ func (b *Talkkonnect) initGPIO() {
if isTx {
isTx = false
b.TransmitStop(true)
if Config.Global.Software.Sounds.Input.Enabled {
var inputEventSoundFile InputEventSoundFileStruct = findInputEventSoundFile("txpttstop")
if inputEventSoundFile.Enabled {
go aplayLocal(inputEventSoundFile.File)
}
} else {
time.Sleep(150 * time.Millisecond)
}
playIOMedia("iotxpttstop")
if Config.Global.Software.Settings.TxCounter {
txcounter++
log.Println("debug: Tx Button Count ", txcounter)
Expand All @@ -257,18 +250,11 @@ func (b *Talkkonnect) initGPIO() {
log.Println("debug: Tx Button is pressed")
if !isTx {
isTx = true
if Config.Global.Software.Sounds.Input.Enabled {
var inputEventSoundFile InputEventSoundFileStruct = findInputEventSoundFile("txpttstart")
if inputEventSoundFile.Enabled {
go aplayLocal(inputEventSoundFile.File)
} else {
time.Sleep(150 * time.Millisecond)
}
} else {
time.Sleep(150 * time.Millisecond)
}
b.TransmitStart()
playIOMedia("iotxpttstart")
} else {
time.Sleep(150 * time.Millisecond)
}
b.TransmitStart()
}
}
}
Expand Down Expand Up @@ -296,12 +282,7 @@ func (b *Talkkonnect) initGPIO() {
if isTx {
b.TransmitStop(true)
log.Println("debug: Toggle Stopped Transmitting")
if Config.Global.Software.Sounds.Input.Enabled {
var inputEventSoundFile InputEventSoundFileStruct = findInputEventSoundFile("txtogglestop")
if inputEventSoundFile.Enabled {
go aplayLocal(inputEventSoundFile.File)
}
}
playIOMedia("iotxtogglestop")
for {
currentState, err := TxToggle.Read()
time.Sleep(150 * time.Millisecond)
Expand All @@ -319,7 +300,9 @@ func (b *Talkkonnect) initGPIO() {
go aplayLocal(inputEventSoundFile.File)
}
}
playIOMedia("txtogglestart")
b.TransmitStart()
log.Println("debug: Toggle Started Transmitting")
for {
currentState, err := TxToggle.Read()
time.Sleep(150 * time.Millisecond)
Expand All @@ -328,7 +311,6 @@ func (b *Talkkonnect) initGPIO() {
}
}
prevState = 1
log.Println("debug: Toggle Started Transmitting")
time.Sleep(150 * time.Millisecond)
}
}
Expand All @@ -352,12 +334,7 @@ func (b *Talkkonnect) initGPIO() {
log.Println("debug: UP Button is released")
} else {
log.Println("debug: UP Button is pressed")
if Config.Global.Software.Sounds.Input.Enabled {
var inputEventSoundFile InputEventSoundFileStruct = findInputEventSoundFile("channelup")
if inputEventSoundFile.Enabled {
go aplayLocal(inputEventSoundFile.File)
}
}
playIOMedia("iochannelup")
b.ChannelUp()
time.Sleep(150 * time.Millisecond)
}
Expand Down Expand Up @@ -385,12 +362,7 @@ func (b *Talkkonnect) initGPIO() {
log.Println("debug: Ch Down Button is released")
} else {
log.Println("debug: Ch Down Button is pressed")
if Config.Global.Software.Sounds.Input.Enabled {
var inputEventSoundFile InputEventSoundFileStruct = findInputEventSoundFile("channeldown")
if inputEventSoundFile.Enabled {
go aplayLocal(inputEventSoundFile.File)
}
}
playIOMedia("iochanneldown")
b.ChannelDown()
time.Sleep(150 * time.Millisecond)
}
Expand All @@ -416,12 +388,7 @@ func (b *Talkkonnect) initGPIO() {
log.Println("debug: Panic Button is released")
} else {
log.Println("debug: Panic Button is pressed")
if Config.Global.Software.Sounds.Input.Enabled {
var inputEventSoundFile InputEventSoundFileStruct = findInputEventSoundFile("panic")
if inputEventSoundFile.Enabled {
go aplayLocal(inputEventSoundFile.File)
}
}
playIOMedia("iopanic")
b.cmdPanicSimulation()
time.Sleep(150 * time.Millisecond)
}
Expand All @@ -443,21 +410,11 @@ func (b *Talkkonnect) initGPIO() {
if currentState != CommentButtonState && err == nil {
CommentButtonState = currentState
if CommentButtonState == 1 {
if Config.Global.Software.Sounds.Input.Enabled {
var inputEventSoundFile InputEventSoundFileStruct = findInputEventSoundFile("commenton")
if inputEventSoundFile.Enabled {
go aplayLocal(inputEventSoundFile.File)
}
}
playIOMedia("iocommenton")
log.Println("debug: Comment Button State 1 setting comment to State 1 Message ", Config.Global.Hardware.Comment.CommentMessageOff)
b.SetComment(Config.Global.Hardware.Comment.CommentMessageOff)
} else {
if Config.Global.Software.Sounds.Input.Enabled {
var inputEventSoundFile InputEventSoundFileStruct = findInputEventSoundFile("commentoff")
if inputEventSoundFile.Enabled {
go aplayLocal(inputEventSoundFile.File)
}
}
playIOMedia("iocommentoff")
log.Println("debug: Comment Button State 2 setting comment to State 2 Message ", Config.Global.Hardware.Comment.CommentMessageOn)
b.SetComment(Config.Global.Hardware.Comment.CommentMessageOn)
time.Sleep(150 * time.Millisecond)
Expand All @@ -483,13 +440,8 @@ func (b *Talkkonnect) initGPIO() {
if StreamButtonState == 1 {
log.Println("debug: Stream Button is released")
} else {
playIOMedia("iostreamtoggle")
log.Println("debug: Stream Button is pressed")
if Config.Global.Software.Sounds.Input.Enabled {
var inputEventSoundFile InputEventSoundFileStruct = findInputEventSoundFile("streamtoggle")
if inputEventSoundFile.Enabled {
go aplayLocal(inputEventSoundFile.File)
}
}
b.cmdPlayback()
time.Sleep(150 * time.Millisecond)
}
Expand All @@ -513,22 +465,12 @@ func (b *Talkkonnect) initGPIO() {
if currentStateA != LastStateA && err0 == nil {
currentStateB, err1 := RotaryB.Read()
if currentStateB != currentStateA && err1 == nil {
playIOMedia("iorotarycw")
log.Println("debug: Rotating Clockwise")
if Config.Global.Software.Sounds.Input.Enabled {
var inputEventSoundFile InputEventSoundFileStruct = findInputEventSoundFile("rotarycw")
if inputEventSoundFile.Enabled {
go aplayLocal(inputEventSoundFile.File)
}
}
b.cmdChannelUp()
} else {
log.Println("debug: Rotating CounterClockwise")
if Config.Global.Software.Sounds.Input.Enabled {
var inputEventSoundFile InputEventSoundFileStruct = findInputEventSoundFile("rotarycwc")
if inputEventSoundFile.Enabled {
go aplayLocal(inputEventSoundFile.File)
}
}
playIOMedia("iorotaryccw")
b.cmdChannelDown()
}
}
Expand All @@ -555,12 +497,7 @@ func (b *Talkkonnect) initGPIO() {
log.Println("debug: Vol UP Button is released")
} else {
log.Println("debug: Vol UP Button is pressed")
if Config.Global.Software.Sounds.Input.Enabled {
var inputEventSoundFile InputEventSoundFileStruct = findInputEventSoundFile("volup")
if inputEventSoundFile.Enabled {
go aplayLocal(inputEventSoundFile.File)
}
}
playIOMedia("iovolup")
b.cmdVolumeUp()
}
}
Expand All @@ -584,12 +521,7 @@ func (b *Talkkonnect) initGPIO() {
log.Println("debug: Vol Down Button is released")
} else {
log.Println("debug: Vol Down Button is pressed")
if Config.Global.Software.Sounds.Input.Enabled {
var inputEventSoundFile InputEventSoundFileStruct = findInputEventSoundFile("voldown")
if inputEventSoundFile.Enabled {
go aplayLocal(inputEventSoundFile.File)
}
}
playIOMedia("iovoldown")
b.cmdVolumeDown()
}
}
Expand Down
16 changes: 8 additions & 8 deletions gps.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type GNSSDataStruct struct {
//global variables for gps
var (
GNSSData GNSSDataStruct
GNSSDataPublic = make(chan GNSSDataStruct, Receivers+1)
GNSSDataPublic = make(chan GNSSDataStruct, GPSDataChannelReceivers+1)
)

//local variables for gps
Expand Down Expand Up @@ -219,8 +219,8 @@ func getGpsPosition(verbosity int) (bool, error) {

if RMCSentenceValid && GGASentenceValid && GSVSentenceValid {
goodGPSRead = true
log.Printf("debug: GPS Good Read Broadcasting to %v receivers\n", Receivers)
for a := 0; a < Receivers; a++ {
log.Printf("debug: GPS Good Read Broadcasting to %v GPSDataChannelReceivers\n", GPSDataChannelReceivers)
for a := 0; a < GPSDataChannelReceivers; a++ {
GNSSDataPublic <- GNSSData
time.Sleep(100 * time.Millisecond)
}
Expand All @@ -236,7 +236,7 @@ func getGpsPosition(verbosity int) (bool, error) {

func httpSendTraccarOsmand() {

Receivers++
GPSDataChannelReceivers++
for {
GNSSDataTraccar := <-GNSSDataPublic

Expand Down Expand Up @@ -278,7 +278,7 @@ func httpSendTraccarOsmand() {

func tcpSendT55Traccar() {

Receivers++
GPSDataChannelReceivers++

for {
GNSSDataTraccar := <-GNSSDataPublic
Expand Down Expand Up @@ -353,7 +353,7 @@ func tcpSendT55Traccar() {
}

func httpSendTraccarOpenGTS() {
Receivers++
GPSDataChannelReceivers++
for {
GNSSDataTraccar := <-GNSSDataPublic

Expand Down Expand Up @@ -390,7 +390,7 @@ func httpSendTraccarOpenGTS() {
}

func consoleScreenLogging() {
Receivers++
GPSDataChannelReceivers++
for {
GNSSDataTraccar := <-GNSSDataPublic
log.Printf("debug: RMC Validity (%v), GGA GPS Quality Indicator (%v) %v/%v\n", GNSSDataTraccar.Validity, GNSSDataTraccar.FixQuality, GNSSDataTraccar.SatsInUse, GNSSDataTraccar.SatsInView)
Expand All @@ -407,7 +407,7 @@ func consoleScreenLogging() {
}

func localScreenLogging() {
Receivers++
GPSDataChannelReceivers++
for {
GNSSDataTraccar := <-GNSSDataPublic
log.Printf("debug: Device Screen Latitude : %f Longitude : %f\n", GNSSDataTraccar.Lattitude, GNSSDataTraccar.Longitude)
Expand Down
11 changes: 10 additions & 1 deletion media.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func aplayLocal(fileNameWithPath string) {

CmdArguments := []string{fileNameWithPath, "-q", "-N"}

log.Printf("debug: player %v filepath %v CmdArguments %v", player, fileNameWithPath, CmdArguments)
log.Printf("debug: player %v CmdArguments %v", player, CmdArguments)

cmd := exec.Command(player, CmdArguments...)

Expand Down Expand Up @@ -177,3 +177,12 @@ func findInputEventSoundFile(findInputEventSound string) InputEventSoundFileStru
}
return InputEventSoundFileStruct{findInputEventSound, "", false}
}

func playIOMedia(inputEvent string) {
if Config.Global.Software.Sounds.Input.Enabled {
var inputEventSoundFile InputEventSoundFileStruct = findInputEventSoundFile(inputEvent)
if inputEventSoundFile.Enabled {
go aplayLocal(inputEventSoundFile.File)
}
}
}
47 changes: 31 additions & 16 deletions sample-configs/talkkonnect-version2-pc-nogpio.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,37 @@
<sound event="rogerbeep" file="/home/talkkonnect/gocode/src/github.com/talkkonnect/talkkonnect/soundfiles/rogerbeeps/Image.wav" volume="50" blocking="false" enabled="true"/>
<sound event="stream" file="http://prdonline.prd.go.th:8200" volume="50" blocking="true" enabled="true"/>
<!-- <sound event="stream" file="http://d.liveatc.net/vtbs_app_east.mp3" volume="1" blocking="true" enabled="true"/> -->
<input enabled="true">
<sound event="txpttstart" file="/home/talkkonnect/gocode/src/github.com/talkkonnect/talkkonnect/soundfiles/rogerbeeps/YellowJacket.wav" enabled="true"/>
<sound event="txpttstop" file="/home/talkkonnect/gocode/src/github.com/talkkonnect/talkkonnect/soundfiles/rogerbeeps/RogerBeep3.wav" enabled="false"/>
<sound event="txtogglestart" file="" enabled="false"/>
<sound event="txtogglestop" file="" enabled="false"/>
<sound event="channelup" file="" enabled="false"/>
<sound event="channeldown" file="" enabled="false"/>
<sound event="panic" file="" enabled="false"/>
<sound event="streamtoggle" file="" enabled="false"/>
<sound event="commenton" file="" enabled="false"/>
<sound event="commentoff" file="" enabled="false"/>
<sound event="rotarycw" file="" enabled="false"/>
<sound event="rotaryccw" file="" enabled="false"/>
<sound event="volup" file="/home/talkkonnect/gocode/src/github.com/talkkonnect/talkkonnect/soundfiles/rogerbeeps/RC210#2.wav" enabled="true"/>
<sound event="voldown" file="/home/talkkonnect/gocode/src/github.com/talkkonnect/talkkonnect/soundfiles/rogerbeeps/RC210#2.wav" enabled="true"/>
</input>
<input enabled="true">
<sound event="iotxpttstart" file="/home/talkkonnect/gocode/src/github.com/talkkonnect/talkkonnect/soundfiles/rogerbeeps/YellowJacket.wav" enabled="true"/>
<sound event="iotxpttstop" file="/home/talkkonnect/gocode/src/github.com/talkkonnect/talkkonnect/soundfiles/rogerbeeps/RogerBeep3.wav" enabled="false"/>
<sound event="iotxtogglestart" file="" enabled="false"/>
<sound event="iotxtogglestop" file="" enabled="false"/>
<sound event="iochannelup" file="" enabled="false"/>
<sound event="iochanneldown" file="" enabled="false"/>
<sound event="iopanic" file="" enabled="false"/>
<sound event="iostreamtoggle" file="" enabled="false"/>
<sound event="iocommenton" file="" enabled="false"/>
<sound event="iocommentoff" file="" enabled="false"/>
<sound event="iorotarycw" file="" enabled="false"/>
<sound event="iorotaryccw" file="" enabled="false"/>
<sound event="iovolup" file="/home/talkkonnect/gocode/src/github.com/talkkonnect/talkkonnect/soundfiles/rogerbeeps/RC210#2.wav" enabled="true"/>
<sound event="iovoldown" file="/home/talkkonnect/gocode/src/github.com/talkkonnect/talkkonnect/soundfiles/rogerbeeps/RC210#2.wav" enabled="true"/>
<sound event="usbchannelup" file="" enabled="false"/>
<sound event="usbchanneldown" file="" enabled="false"/>
<sound event="usbserverup" file="" enabled="false"/>
<sound event="usbpreviousserver" file="" enabled="false"/>
<sound event="usbmute" file="" enabled="false"/>
<sound event="usbunmute" file="" enabled="false"/>
<sound event="usbmutetoggle" file="" enabled="false"/>
<sound event="usbstreamtoggle" file="" enabled="false"/>
<sound event="usbvolup" file="" enabled="false"/>
<sound event="usbvoldown" file="" enabled="false"/>
<sound event="usbsetcomment" file="" enabled="false"/>
<sound event="usbstarttx" file="" enabled="false"/>
<sound event="usbstoptx" file="" enabled="false"/>
<sound event="usbrecord" file="" enabled="false"/>
<sound event="usbvoicetarget" file="/home/talkkonnect/gocode/src/github.com/talkkonnect/talkkonnect/soundfiles/rogerbeeps/RC210#2.wav" enabled="true"/>
</input>
<repeatertone enabled="true">
<sound event="repeatertone" tonefrequencyhz="1750" volume="50" tonedurationsec="10" blocking="false" enabled="true"/>
</repeatertone>
Expand Down
Loading

0 comments on commit 59d9d0c

Please sign in to comment.