diff --git a/autoprovision.go b/autoprovision.go index a952149..86d0837 100644 --- a/autoprovision.go +++ b/autoprovision.go @@ -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()) } diff --git a/commandkeys.go b/commandkeys.go index f4857d7..36c4bf6 100644 --- a/commandkeys.go +++ b/commandkeys.go @@ -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) } @@ -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) } @@ -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() { diff --git a/gpio.go b/gpio.go index 42048a6..e85f55a 100644 --- a/gpio.go +++ b/gpio.go @@ -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) @@ -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() } } } @@ -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) @@ -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) @@ -328,7 +311,6 @@ func (b *Talkkonnect) initGPIO() { } } prevState = 1 - log.Println("debug: Toggle Started Transmitting") time.Sleep(150 * time.Millisecond) } } @@ -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) } @@ -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) } @@ -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) } @@ -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) @@ -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) } @@ -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() } } @@ -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() } } @@ -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() } } diff --git a/gps.go b/gps.go index 0f2ad3a..866c84c 100644 --- a/gps.go +++ b/gps.go @@ -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 @@ -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) } @@ -236,7 +236,7 @@ func getGpsPosition(verbosity int) (bool, error) { func httpSendTraccarOsmand() { - Receivers++ + GPSDataChannelReceivers++ for { GNSSDataTraccar := <-GNSSDataPublic @@ -278,7 +278,7 @@ func httpSendTraccarOsmand() { func tcpSendT55Traccar() { - Receivers++ + GPSDataChannelReceivers++ for { GNSSDataTraccar := <-GNSSDataPublic @@ -353,7 +353,7 @@ func tcpSendT55Traccar() { } func httpSendTraccarOpenGTS() { - Receivers++ + GPSDataChannelReceivers++ for { GNSSDataTraccar := <-GNSSDataPublic @@ -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) @@ -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) diff --git a/media.go b/media.go index 96971c7..fff5dff 100644 --- a/media.go +++ b/media.go @@ -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...) @@ -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) + } + } +} diff --git a/sample-configs/talkkonnect-version2-pc-nogpio.xml b/sample-configs/talkkonnect-version2-pc-nogpio.xml index 8f440e9..62016ac 100755 --- a/sample-configs/talkkonnect-version2-pc-nogpio.xml +++ b/sample-configs/talkkonnect-version2-pc-nogpio.xml @@ -124,22 +124,37 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sample-configs/talkkonnect-version2-respeaker.xml b/sample-configs/talkkonnect-version2-respeaker.xml index de6adf0..f6fef41 100755 --- a/sample-configs/talkkonnect-version2-respeaker.xml +++ b/sample-configs/talkkonnect-version2-respeaker.xml @@ -125,23 +125,38 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/sample-configs/talkkonnect-version2-usb-gpio-example.xml b/sample-configs/talkkonnect-version2-usb-gpio-example.xml index 310195d..a703692 100755 --- a/sample-configs/talkkonnect-version2-usb-gpio-example.xml +++ b/sample-configs/talkkonnect-version2-usb-gpio-example.xml @@ -124,23 +124,38 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/usbkeyboard.go b/usbkeyboard.go index 2d89c74..e698547 100644 --- a/usbkeyboard.go +++ b/usbkeyboard.go @@ -65,35 +65,50 @@ func (b *Talkkonnect) USBKeyboard() { if _, ok := USBKeyMap[rune(ke.Scancode)]; ok { switch strings.ToLower(USBKeyMap[rune(ke.Scancode)].Command) { case "channelup": + playIOMedia("usbchannelup") b.cmdChannelUp() case "channeldown": + playIOMedia("usbchanneldown") b.cmdChannelDown() case "serverup": + playIOMedia("usbserverup") b.cmdConnNextServer() case "serverdown": + playIOMedia("usbpreviousserver") b.cmdConnPreviousServer() case "mute": + playIOMedia("usbmute") b.cmdMuteUnmute("mute") case "unmute": b.cmdMuteUnmute("unmute") + playIOMedia("usbunmute") case "mute-toggle": + playIOMedia("usbmutetoggle") b.cmdMuteUnmute("toggle") + playIOMedia("usbmutetoggle") case "stream-toggle": + playIOMedia("usbstreamtoggle") b.cmdPlayback() case "volumeup": + playIOMedia("usbvolup") b.cmdVolumeUp() case "volumedown": + playIOMedia("usbvoldown") b.cmdVolumeDown() case "setcomment": if USBKeyMap[rune(ke.Scancode)].ParamName == "setcomment" { log.Println("info: Set Commment ", USBKeyMap[rune(ke.Scancode)].ParamValue) + playIOMedia("usbsetcomment") b.Client.Self.SetComment(USBKeyMap[rune(ke.Scancode)].ParamValue) } case "transmitstart": + playIOMedia("usbstarttx") b.cmdStartTransmitting() case "transmitstop": + playIOMedia("usbstoptx") b.cmdStopTransmitting() case "record": + playIOMedia("usbrecord") b.cmdAudioTrafficRecord() b.cmdAudioMicRecord() case "voicetargetset": @@ -101,6 +116,7 @@ func (b *Talkkonnect) USBKeyboard() { if err != nil { log.Println("error: Target is Non-Numeric Value") } else { + playIOMedia("usbvoicetarget") b.cmdSendVoiceTargets(uint32(voicetarget)) } default: diff --git a/version.go b/version.go index 7ef59dc..72e16b6 100644 --- a/version.go +++ b/version.go @@ -31,11 +31,15 @@ package talkkonnect const ( - talkkonnectVersion string = "2.07.15" + talkkonnectVersion string = "2.07.16" talkkonnectReleased string = "Jan 05 2022" ) /* Release Notes -1. Used Zoran's Patch to make traccar working with all 3 protocols -2. Fixed wrong logic for Config.Global.Hardware.TargetBoard == "rpi" && Config.Global.Hardware.Traccar.DeviceScreenEnabled causing the screen not to work +1. Added Volume Button Step Configurability for step size in % +2. fixed autoprovisioning to use filename from xml instead of hardcoded to talkkonnect.xml +3, Changed variable "receivers" to "GPSDataChannelReceivers" to make it more descriptive and readable +4. Created new function in media.go for simplifying playing of media on input button press +5. Renamed sound events for io with prefix io for xml configuration +6/ Added Support for usb keypad press sound with prefix usb for xml configuration */ diff --git a/xmlparser.go b/xmlparser.go index 8f2f527..429c904 100644 --- a/xmlparser.go +++ b/xmlparser.go @@ -308,6 +308,10 @@ type ConfigStruct struct { Pulse time.Duration `xml:"pulsemsecs,attr"` Trailing time.Duration `xml:"trailingmsecs,attr"` } `xml:"pulse"` + VolumeButtonStep struct { + VolUpStep int `xml:"volupstep"` + VolDownStep int `xml:"voldownstep"` + } `xml:"volumebuttonstep"` } `xml:"io"` HeartBeat struct { Enabled bool `xml:"enabled,attr"` @@ -557,16 +561,16 @@ var ConfigXMLFile string // Generic Global State Variables var ( - KillHeartBeat bool - IsPlayStream bool - IsConnected bool - Streaming bool - HTTPServRunning bool - NowStreaming bool - InStreamTalking bool - InStreamSource bool - LCDIsDark bool - Receivers int + KillHeartBeat bool + IsPlayStream bool + IsConnected bool + Streaming bool + HTTPServRunning bool + NowStreaming bool + InStreamTalking bool + InStreamSource bool + LCDIsDark bool + GPSDataChannelReceivers int ) // Generic Global Counter Variables @@ -799,6 +803,14 @@ func readxmlconfig(file string, reloadxml bool) error { Config.Global.Hardware.VoiceActivityTimermsecs = 200 } + if Config.Global.Hardware.IO.VolumeButtonStep.VolUpStep == 0 { + Config.Global.Hardware.IO.VolumeButtonStep.VolUpStep = +1 + } + + if Config.Global.Hardware.IO.VolumeButtonStep.VolDownStep == 0 { + Config.Global.Hardware.IO.VolumeButtonStep.VolDownStep = -1 + } + if OLEDEnabled { Oled, err = goled.BeginOled(OLEDDefaultI2cAddress, OLEDDefaultI2cBus, OLEDScreenWidth, OLEDScreenHeight, OLEDDisplayRows, OLEDDisplayColumns, OLEDStartColumn, OLEDCharLength, OLEDCommandColumnAddressing, OLEDAddressBasePageStart) if err != nil {