Skip to content

Commit

Permalink
cleanup and generic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
talkkonnect committed Jan 12, 2022
1 parent 593387b commit b57f237
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 29 deletions.
2 changes: 1 addition & 1 deletion commandkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ func (b *Talkkonnect) cmdDisplayVersion() {
log.Println("info: Talkkonnect Version Request ")
releasedVersion := checkGitHubVersion()
if talkkonnectVersion != releasedVersion {
log.Printf("warn: Ver %v Rel %v (Newer Ver %v Available!)\n", talkkonnectVersion, talkkonnectReleased, releasedVersion)
log.Printf("warn: Ver %v Rel %v (Different Ver %v Available!)\n", talkkonnectVersion, talkkonnectReleased, releasedVersion)
} else {
log.Printf("info: Ver %v Rel %v (Latest Release)\n", talkkonnectVersion, talkkonnectReleased)
}
Expand Down
6 changes: 4 additions & 2 deletions media.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,18 @@ import (
func aplayLocal(fileNameWithPath string) {
var player string

CmdArguments := []string{}

if path, err := exec.LookPath("aplay"); err == nil {
CmdArguments = []string{fileNameWithPath, "-q", "-N"}
player = path
} else if path, err := exec.LookPath("paplay"); err == nil {
CmdArguments = []string{fileNameWithPath}
player = path
} else {
return
}

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

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

cmd := exec.Command(player, CmdArguments...)
Expand Down
6 changes: 6 additions & 0 deletions onevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,19 +337,25 @@ func (b *Talkkonnect) OnPermissionDenied(e *gumble.PermissionDeniedEvent) {
}

func (b *Talkkonnect) OnChannelChange(e *gumble.ChannelChangeEvent) {
log.Println("debug: Channel Change Event Detected")
}

func (b *Talkkonnect) OnUserList(e *gumble.UserListEvent) {
log.Println("debug: On User List Event Detected")
}

func (b *Talkkonnect) OnACL(e *gumble.ACLEvent) {
log.Println("debug: On ACL Event Detected")
}

func (b *Talkkonnect) OnBanList(e *gumble.BanListEvent) {
log.Println("debug: OnBanList Event Detected")
}

func (b *Talkkonnect) OnContextActionChange(e *gumble.ContextActionChangeEvent) {
log.Println("debug: OnContextActionChange Event Detected")
}

func (b *Talkkonnect) OnServerConfig(e *gumble.ServerConfigEvent) {
log.Println("debug: OnServerConfigs Event Detected")
}
2 changes: 1 addition & 1 deletion talkkonnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func talkkonnectBanner(backgroundcolor string) {
log.Println("info: " + backgroundcolor + "└────────────────────────────────────────────────────────────────┘" + backgroundreset)
releasedVersion := checkGitHubVersion()
if talkkonnectVersion != releasedVersion {
log.Printf("warn: Ver %v Rel %v (Newer Ver %v Available!)\n", talkkonnectVersion, talkkonnectReleased, releasedVersion)
log.Printf("warn: Ver %v Rel %v (Different Ver %v Available!)\n", talkkonnectVersion, talkkonnectReleased, releasedVersion)
} else {
log.Printf("info: Ver %v Rel %v (Latest Release)\n", talkkonnectVersion, talkkonnectReleased)
}
Expand Down
15 changes: 11 additions & 4 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,18 @@
package talkkonnect

const (
talkkonnectVersion string = "2.07.20"
talkkonnectReleased string = "Jan 11 2022"
talkkonnectVersion string = "2.07.21"
talkkonnectReleased string = "Jan 12 2022"
)

/* Release Notes
1. Combined http traccar protocols into one function
2. Added sound events for user to know traccar status
1. Sanity Check for voiceactivitytimersecs if less that 200 msecs set to 200 msecs
2. Removed redundant definition of ttyKBStruct and usbStruct and combined into one struct
3. Removed unused definition of InputEventSoundStruct
4. Added Tighter GPIO Checks for Pins 2,3 If I2C Device enabled these pins should be avoided warning
5. Added Tighter GPIO Checks for Pins 7,8,9,10,11 if SPI Device Enabled these pins should be avoided warning
6. Added Tighter GPIO Checks for Pins in the rage 2-27 only
7. Added Debugging Verbosity to currently unhandled mumble events
8. Fixed Command Arguements for PaPlay
9. Changed version checking function instead of saying newer version available say different version available
*/
43 changes: 22 additions & 21 deletions xmlparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,15 +509,7 @@ type VTStruct struct {
}
}

type TTYKBStruct struct {
Enabled bool
KeyLabel uint32
Command string
ParamName string
ParamValue string
}

type USBKBStruct struct {
type KBStruct struct {
Enabled bool
KeyLabel uint32
Command string
Expand All @@ -532,13 +524,6 @@ type EventSoundStruct struct {
Blocking bool
}

type InputEventSoundStruct struct {
Enabled bool
InputEvent string
ToneFrequency int
ToneDuration float32
}

type InputEventSoundFileStruct struct {
Event string
File string
Expand Down Expand Up @@ -597,8 +582,8 @@ var (
var (
LcdText = [4]string{"nil", "nil", "nil", "nil"}
MyLedStrip *LedStrip
TTYKeyMap = make(map[rune]TTYKBStruct)
USBKeyMap = make(map[rune]USBKBStruct)
TTYKeyMap = make(map[rune]KBStruct)
USBKeyMap = make(map[rune]KBStruct)
)

//Mumble Account Settings Global Variables
Expand Down Expand Up @@ -707,10 +692,10 @@ func readxmlconfig(file string, reloadxml bool) error {
for _, kMainCommands := range Config.Global.Hardware.Keyboard.Command {
if kMainCommands.Enabled {
if kMainCommands.Ttykeyboard.Enabled {
TTYKeyMap[kMainCommands.Ttykeyboard.Scanid] = TTYKBStruct{kMainCommands.Ttykeyboard.Enabled, kMainCommands.Ttykeyboard.Keylabel, kMainCommands.Action, kMainCommands.ParamName, kMainCommands.Paramvalue}
TTYKeyMap[kMainCommands.Ttykeyboard.Scanid] = KBStruct{kMainCommands.Ttykeyboard.Enabled, kMainCommands.Ttykeyboard.Keylabel, kMainCommands.Action, kMainCommands.ParamName, kMainCommands.Paramvalue}
}
if kMainCommands.Usbkeyboard.Enabled {
USBKeyMap[kMainCommands.Usbkeyboard.Scanid] = USBKBStruct{kMainCommands.Usbkeyboard.Enabled, kMainCommands.Usbkeyboard.Keylabel, kMainCommands.Action, kMainCommands.ParamName, kMainCommands.Paramvalue}
USBKeyMap[kMainCommands.Usbkeyboard.Scanid] = KBStruct{kMainCommands.Usbkeyboard.Enabled, kMainCommands.Usbkeyboard.Keylabel, kMainCommands.Action, kMainCommands.ParamName, kMainCommands.Paramvalue}
}

}
Expand Down Expand Up @@ -1390,6 +1375,12 @@ func CheckConfigSanity(reloadxml bool) {
}
}

if Config.Global.Hardware.VoiceActivityTimermsecs < 200 {
log.Print("warn: Config Error [Section Hardware] VoiceActivityTimersecs < 200 setting to 200")
Config.Global.Hardware.VoiceActivityTimermsecs = 200
Warnings++
}

for index, gpio := range Config.Global.Hardware.IO.Pins.Pin {
if gpio.Enabled {
if !(gpio.Direction == "input" || gpio.Direction == "output") {
Expand All @@ -1414,12 +1405,22 @@ func CheckConfigSanity(reloadxml bool) {
Warnings++
}

if gpio.PinNo > 30 {
if gpio.PinNo < 2 || gpio.PinNo > 27 {
log.Printf("warn: Config Error [Section GPIO] Enabled GPIO Name %v Pin Number %v Invalid GPIO Number\n", gpio.Name, gpio.PinNo)
Config.Global.Hardware.IO.Pins.Pin[index].Enabled = false
Warnings++
}

if (Config.Global.Hardware.OLED.Enabled || Config.Global.Hardware.IO.GPIOExpander.Enabled || Config.Global.Hardware.LCD.InterfaceType == "i2c") && (gpio.PinNo == 2 || gpio.PinNo == 3) {
log.Printf("warn: Config Possible Pins Clash with I2C Interface [Section GPIO] Enabled GPIO Name %v Pin Number %v Invalid GPIO Number\n", gpio.Name, gpio.PinNo)
Warnings++
}

if (Config.Global.Hardware.LedStripEnabled) && (gpio.PinNo == 7 || gpio.PinNo == 8 || gpio.PinNo == 9 || gpio.PinNo == 10 || gpio.PinNo == 11) {
log.Printf("warn: Config Possible Pins Clash with SPI Interface [Section GPIO] Enabled GPIO Name %v Pin Number %v Invalid GPIO Number\n", gpio.Name, gpio.PinNo)
Warnings++
}

if gpio.ID > 8 {
log.Print("warn: Config Error [Section GPIO] Invalid ChipID Address")
Config.Global.Hardware.IO.Pins.Pin[index].Enabled = false
Expand Down

0 comments on commit b57f237

Please sign in to comment.