From b0429267eeed2ce48517ec63b2ab83f0c81a35a6 Mon Sep 17 00:00:00 2001 From: Suvir Kumar Date: Mon, 30 Aug 2021 07:47:59 +0700 Subject: [PATCH] reorganizing variables for readability --- client.go | 44 ++++------ gps.go | 222 +-------------------------------------------------- stream.go | 14 ++-- xmlparser.go | 173 +++++++++++++++++++++------------------ 4 files changed, 119 insertions(+), 334 deletions(-) diff --git a/client.go b/client.go index 0789606..23f7666 100644 --- a/client.go +++ b/client.go @@ -54,46 +54,32 @@ import ( ) var ( - LcdText = [4]string{"nil", "nil", "nil", "nil"} currentChannelID uint32 prevChannelID uint32 prevParticipantCount int = 0 prevButtonPress string = "none" maxchannelid uint32 - ConfigXMLFile string - Streaming bool - ServerHop bool - HTTPServRunning bool message string isrepeattx bool = true - NowStreaming bool - MyLedStrip *LedStrip - GPSTime string - GPSDate string - GPSLatitude float64 - GPSLongitude float64 - GPSSpeed float64 - GPSCourse float64 - GPSVariation float64 m string ) type Talkkonnect struct { - Config *gumble.Config - Client *gumble.Client - VoiceTarget *gumble.VoiceTarget - Name string - Address string - Username string - Ident string - TLSConfig tls.Config - ConnectAttempts uint - Stream *Stream - ChannelName string - Daemonize bool - IsTransmitting bool - IsPlayStream bool - GPIOEnabled bool + Config *gumble.Config + Client *gumble.Client + VoiceTarget *gumble.VoiceTarget + Name string + Address string + Username string + Ident string + TLSConfig tls.Config + ConnectAttempts uint + Stream *Stream + ChannelName string + Daemonize bool + IsTransmitting bool + IsPlayStream bool + GPIOEnabled bool } type ChannelsListStruct struct { diff --git a/gps.go b/gps.go index bdbcb0e..ef7cdae 100644 --- a/gps.go +++ b/gps.go @@ -50,29 +50,10 @@ import ( "github.com/jacobsa/go-serial/serial" hd44780 "github.com/talkkonnect/go-hd44780" "github.com/talkkonnect/go-nmea" - //"encoding/json" // used for testing http api for flespi ) -var ( - TraccarPortOsmAnd string = "5055" // Traccar Client port 5055 for working with OsmAnd Protocol - TraccarPortT55 string = "5005" // Old Traccar Client port 5005 for working with T55 Protocol - TraccarPortOpenGTS string = "5159" // Traccar Client port 5159 for for working OpenGTS Protocol -) - -//A test http request for OsmAnd protocol and passing basic $GPRMC information to Traccar. -//http://10.8.0.1:5055?id=12345×tamp=2019-10-05%20&lat=44.000000&lon=20.000000&speed=0.000&course=0.000000&variation=0.000000 -//More info about OsmAnd for Traccar: https://www.traccar.org/osmand - -//A request example for OpenGTS protocol in Traccar... -//http://10.8.0.1:5159/?id=12345&gprmc=$GPRMC,094852,A,4446.8347,N,02030.9393,E,0.0147,69.114,041019,,*10 - -// Supported protocols for communicating with Traccar: OsmAnd, T55 and OpenGTS. -// OsmAnd and OpenGTS use http. T55 use tcp socket connection (udp is also possible). - var goodGPSRead bool = false -// GPS Serial reading. - func getGpsPosition(verbose bool) (bool, error) { if GpsEnabled { @@ -152,75 +133,23 @@ func getGpsPosition(verbose bool) (bool, error) { if err == nil { - /*if s.DataType() == nmea.TypeGGA { - g := s.(nmea.RMC) - if g.Latitude != 0 && g.Longitude != 0 { - goodGPSRead = true - fmt.Println(...) - */ - // Try to read other sentences containing useful info like $GPGGA, ... - // and print useful info, altitude, number of satellites, fix quality, etc. To Do. - if s.DataType() == nmea.TypeRMC { m := s.(nmea.RMC) if m.Latitude != 0 && m.Longitude != 0 { goodGPSRead = true - //if m.Speed != 0 && m.Course != 0 { - //isVehicleMoving = true // Report if vehicle moves or overspeeds? - //if m.Speed >> some km/h - // Send a text alert to Mumble or email? - - // Read GGA Info for FixQuality, NumSatellites, Altitude ... To Do.. - // https://github.com/adrianmo/go-nmea/blob/master/gga.go - //... - - /*if TrackEnabled == true { - if TraccarSendTo == true { - if TraccarProto == "osmand" { - TraccarServerFullURL = (fmt.Sprint(TraccarServerURL) + ":" + fmt.Sprint(TraccarPortOsmAnd) + "?" + "id=" + TraccarClientId + "&" + "timestamp=" + date2() + "%20" + time2() + "&" + "lat=" + fmt.Sprintf("%f", m.Latitude)+ "&" + "lon=" + fmt.Sprintf("%f", m.Longitude) + "&" + "speed=" + fmt.Sprintf("%f", m.Speed) + "&" + "course=" + fmt.Sprintf("%f", m.Course) + "&" + "variation=" + fmt.Sprintf("%f", m.Variation)) - } else if TraccarProto == "opengts" { - TraccarServerFullURL = fmt.Sprint(TraccarServerURL) + ":" + fmt.Sprint(TraccarPortOpenGTS) + "/?" + "id=" + TraccarClientId + "&" + "gprmc=" + fmt.Sprint(m) - //TraccarServerFullURL = fmt.Sprint(TraccarServerURL) + ":" + fmt.Sprint(TraccarPortOpenGTS) + "?" + "id=" + TraccarClientId + "&" + "timestamp=" + Date2 + "%20" + Time2 + "&" + "lat=" + fmt.Sprintf("%f", m.Latitude) + "&" + "lon=" + fmt.Sprintf("%f", m.Longitude) + "&" + "speed=" + fmt.Sprint(m.Speed) + "&" + "course=" + fmt.Sprintf("%f", m.Course) + "&" + "variation=" + fmt.Sprintf("%f", m.Variation) - } else if TraccarProto == "t55" { - TraccarServerFullURL = "" - } - } - } - } - */ - - // This is a request example for OpenGTS protocol in Traccar. Use port 5159. - // http://10.8.0.1:5159/?id=12345&gprmc=$GPRMC,094852,A,4446.8347,N,02030.9393,E,0.0147,69.114,041019,,*10 - // http://10.8.0.1:5159/?id=12345&gprmc=$GPRMC,114614.00,A,4446.82735,N,02030.94387,E,0.030,,151019,,,A*70 - FreqReport := float64(TraccarReportFrequency) // Reporting Frequency FreqReports := (time.Duration(TraccarReportFrequency) * time.Second) // Frequency of GPS Reporting. Minutes, Seconds or hours? - //FreqReportm := (FreqReports / 60) // in minutes - //FreqReport := 60 // Reporting Frequency - //FreqReports := (time.Duration(FreqReport) * time.Second) // Frequency of GPS Reporting. Minutes, Seconds or hours? - //FreqReportm := (FreqReport / 60) // minutes - //FreqReportH := (FreqReports/(60*60)) // hours - //FreqReportD := (FreqReports/(60*60*24)) // days - //Improve calc with time/ string to print reporting freq in minutes or seconds, as needed. - - // Position Reporter - - // send GPS position once immediately on start if TrackEnabled && TraccarSendTo { if TraccarProto == "t55" { go tcpSendT55Traccar2() // Initial Send GPS position to Traccar with old T55 client protocol. No keep-alive. - //tcpSendT55Traccar1() // Initial Send GPS position to Traccar with old T55 client protocol. Keep-alive. } else { go httpSendTraccar() // Initial Send GPS position to Traccar over http function for both OsmAnd or OpenGTS protocol. - //flespi() // Test flespi } log.Println("info: GPS Position Report Nr (1) Sent to Traccar Server") } - // Now, keep sending GPS position and counting how many reports were sent? - PositionReporter := time.NewTicker(FreqReports) var TraccarCounter = 1 go func() { @@ -228,10 +157,8 @@ func getGpsPosition(verbose bool) (bool, error) { if TrackEnabled && TraccarSendTo { if TraccarProto == "t55" { tcpSendT55Traccar2() // Send GPS position to Traccar with old T55 client protocol. No keep-alive. - //tcpSendT55Traccar1() // Send GPS position to Traccar with old T55 client protocol. Keep-alive. } else { httpSendTraccar() // Send GPS position to Traccar over http function for both OsmAnd or OpenGTS protocol. - //flespi() // Test flespi } } TraccarCounter++ @@ -249,8 +176,6 @@ func getGpsPosition(verbose bool) (bool, error) { } } - //Display Show GPS Position. - if TargetBoard == "rpi" { if TrackEnabled { if TrackGPSShowLCD { @@ -369,82 +294,8 @@ func getGpsPosition(verbose bool) (bool, error) { return false, errors.New("GPS Not Enabled. Or Not Connected") } -/* -GPS Reporter function. Need more work. -func gpsReporter() { -//ticker := time.NewTicker(60 * time.Second) // send every 60 seconds. -ticker := time.NewTicker(time.Duration(int64(TraccarReportFrequency)) * time.Second) // send every ... seconds. -done := make(chan bool) -go func() { -for { -select { -case <-done: -return -case t := <-ticker.C: -//httpSendTraccar() -//tcpSendT55Traccar1() -//tcpSendT55Traccar2() -log.Println("info: GPS Position Sent to Traccar Server over" + strings.Title(strings.ToLower(TraccarProto)) + "protocol", t) -//log.Println("info: OsmAnd: ", fmt.Sprintf(TraccarServerURL + ":" + TraccarPortOsmAnd + "?" + "id=" + TraccarClientId) + "&" + "timestamp=" + Date2 + "%" + "20" + Time2 + "&" + "lat=" + fmt.Sprintf("%f", m.Latitude) + "&" + "lon=" + fmt.Sprintf("%f", m.Longitude) + "&" + "speed=" + fmt.Sprint(m.Speed) + "&" + "course=" + fmt.Sprintf("%f", m.Course) + "&" + "variation=" + fmt.Sprintf("%f", m.Variation)) -//log.Println("info: GPS Position Sent to Traccar Server. Next Position Report in " + fmt.Sprintf(strconv.Itoa(FreqReportm)) + " minute(s)") -} -} -}() -} - -*/ - -/* T55 Protocol. -Info: https://www.traccar.org/traccar-client-protocol -T55 protocol is used by old version of Traccar Client. -New version use OsmAnd protocol. T55 Protocol uses TCP/IP as a transport layer. -It is more simple. Can be UDP also, but it is less reliable. Messages are separated -simply by carriage return and line feed characters (\r\n). - -How to format T55 message for sending to Traccar? - -Login (send once the TCP connection is establshed): -$PGID,12345*0F\r\n (where 12345 - IMEI or other unique id) - -Simple location report format is just a standard NMEA GPRMC sentence: -$GPRMC,225446,A,4916.45,N,12311.12,W,000.5,054.7,191194,020.3,E*68\r\n - -225446 - Time of fix 22:54:46 UTC -A - Navigation receiver warning A = OK, V = warning -4916.45,N - Latitude 49 deg. 16.45 min North -12311.12,W - Longitude 123 deg. 11.12 min West -000.5 - Speed over ground, Knots -054.7 - Course Made Good, True -191194 - Date of fix 19 November 1994 -020.3,E - Magnetic variation 20.3 deg East -*68 - Checksum - -Extended location report format: - -$TRCCR,20140111000000.000,A,60.000000,60.000000,0.00,0.00,0.00,50,*3a\r\n - -20140111000000.000 - Date and tim of fix 2014-01-11 00:00:00.000 UTC -A - Navigation receiver warning A = OK, V = warning -60.000000 - Latitude in degrees 60 deg (negative for south hemisphere) -60.000000 - Longitude in degrees 60 deg (negative for west hemisphere) -0.00 - Speed over ground, Knots -0.00 - Course Made Good, True -0.00 - Altitude in meters -50 - Battery level -*/ - -//T55(1) - -//T55(2) -//Another T55 TCP Connection with keep-alive. EOF for indicating a connection drop. -//Keep-alive. Client stays connected between sending position. - func tcpSendT55Traccar2() { - //Hard coded for testing - //pgid := "$PGID,12345*0F\r\n" // Unique Client ID (e.g. 12345). Follow with carriage return and line feed characters (\r\n). - //gprmc := "$GPRMC,114614.00,A,4446.82735,N,02030.94387,E,0.030,,151019,,,A*70\r\n" // Test sentence. Send after pgid. Follow \r\n. - pgid := "$PGID" + "," + TraccarClientId + "*0F" + "\r" + "\n" // Unique Client ID (e.g. 12345). Follow with carriage return and line feed $ gprmc := fmt.Sprint(m) + "\r" + "\n" log.Println("info: $GPRMC to send is: " + fmt.Sprint(m)) @@ -472,15 +323,8 @@ func tcpSendT55Traccar2() { return } - //log.Println("info: Sending T55 Position Report to Traccar ") - //log.Println("info: Connection established with Traccar Server :", TraccarServerIP) - //log.Println("info: Traccar Server Address :", conn.RemoteAddr().String()) - //log.Println("info: Traccar Client Address :", conn.LocalAddr().String()) - log.Println("info: Traccar Client:", conn.LocalAddr().String(), "Connected to Server:", conn.RemoteAddr().String()) - // Send a T55 position report... - fmt.Fprintf(conn, pgid) // Send ID time.Sleep(1 * time.Second) fmt.Fprintf(conn, gprmc) // send $GPRMC @@ -488,8 +332,6 @@ func tcpSendT55Traccar2() { notify := make(chan error) - // error checking for a closed connection. dispatch a goroutine to read from the connection until there's an EOF error. - go func() { buf := make([]byte, 1024) for { @@ -504,7 +346,6 @@ func tcpSendT55Traccar2() { if n > 0 { log.Printf("Unexpected Data: %s", buf[:n]) - //fmt.Println("Unexpected Data: %s", buf[:n]) } } }() @@ -513,39 +354,19 @@ func tcpSendT55Traccar2() { select { case err := <-notify: log.Println("info: Traccar Server Connection dropped message", err) - //fmt.Println("Traccar Server Connection dropped message", err) if err == io.EOF { log.Println("Connection to Traccar Server was closed") - //fmt.Println("Connection to Traccar Server was closed") return } case <-time.After(time.Second * 60): log.Println("Traccar Server Connection Timeout 60. Still Alive") - //fmt.Println("Traccar Server Connection Timeout 60. Still Alive") } } } -// T55(2) End - -// Sending over OsmAnd and OpenGTS. -// OsmAnd is primary Traccar protocol for sending position over http api. - -// OpenGTS currently not working. Need to check if format parsing is correct? -// Traccar returns 400 http error. -// A request example for OpenGTS protocol in Traccar is... -// http://10.8.0.1:5159/?id=12345&gprmc=$GPRMC,094852,A,4446.8347,N,02030.9393,E,0.0147,69.114,041019,,*10 -// This is correct format for OpenGTS. Works directly from a web browser. -// For troubleshooting this problem check /opt/traccar/logs/tracker-server.log in the Traccar server -// Message will be HEX coded. Decode with calculator -// OsmAnd is working OK. - func httpSendTraccar() { - //Date1 := fmt.Sprint(gpsdatereorder()) // Reformatted date for Tracar - //Time1 := fmt.Sprint("%s", truncateString(GPSTime, 8)) // Truncate time for Traccar - if TrackEnabled { if TraccarSendTo { if TraccarProto == "osmand" { @@ -553,21 +374,15 @@ func httpSendTraccar() { } else if TraccarProto == "opengts" { TraccarServerFullURL = fmt.Sprint(TraccarServerURL) + ":" + fmt.Sprint(TraccarPortOpenGTS) + "/" + "?" + "id=" + TraccarClientId + "&" + "gprmc=" + fmt.Sprint(m) - //gprmctest = "$GPRMC,081753.00,A,4446.82690,N,02030.95217,E,0.285,,011219,,,A*73" - //TraccarServerFullURL := `http://10.8.0.1:5055?id=tk-demo-04×tamp=2019-10-05%2011:30:00&lat=44.000000&lon=20.000000&speed=0.000&course=0.000000&variation=0.000000` - //TraccarServerFullURL := (fmt.Sprint(TraccarServerURL) + ":" + fmt.Sprint(TraccarPortOsmAnd) + "?" + "id=" + TraccarClientId + "&" + "timestamp=" + fmt.Sprint(gpsdatereorder()) + "%20" + time2() + "&" + "lat=" + fmt.Sprint(GPSLatitude) + "&" + "lon=" + fmt.Sprint(GPSLongitude) + "&" + "speed=" + fmt.Sprint(GPSSpeed) + "&" + "course=" + fmt.Sprint(GPSCourse) + "&" + "variation=" + fmt.Sprint(GPSVariation)) - //http://10.8.0.1:5159/?id=12345&gprmc=$GPRMC,094852,A,4446.8347,N,02030.9393,E,0.0147,69.114,041019,,*10 //URL for testing openGTS - } } - } // + } response, err := http.Get(TraccarServerFullURL) if err != nil { log.Println("error: Cannot Establish Connection with Traccar Server! Error ", err) - // Print to LCD "TRACK ERR 1". Error 1 for network connectivity problems with Traccar server. Check why the connectivity failed? currentTime := time.Now() if TargetBoard == "rpi" { if TrackEnabled { @@ -582,34 +397,26 @@ func httpSendTraccar() { } } } - // LCD TRACK ERR1 to screen return } else { contents, err := ioutil.ReadAll(response.Body) - // if it's no error then defer the call for closing body defer response.Body.Close() if err != nil { log.Println("error: Error Sending Data to Traccar Server!") } - // if http request response body is empty if response.ContentLength == 0 { log.Println("info: Empty Request Response Body") } else { // log.Println("info: Traccar Web Server Response -->\n" + "-------------------------------------------------------------\n" + string(contents) + "-------------------------------------------------------------") } - // Added code to read http response status code, 2xx, 4xx. log.Println("info: HTTP Response Status from Traccar:", response.StatusCode, http.StatusText(response.StatusCode)) if response.StatusCode >= 200 && response.StatusCode <= 299 { log.Println("info: HTTP Status Code from Traccar is in the 2xx range. This is OK.") - // "TRACK OK" Message To LCD. - // Print LCD message "TRACK OK" to LCD, overwrite row with "GPS OK" + timestamp to report a - // position had been successfully transferred to Traccar (after 200 OK). - // time.Sleep(1 * time.Second) currentTime := time.Now() if TargetBoard == "rpi" { if TrackEnabled { @@ -624,9 +431,7 @@ func httpSendTraccar() { } } } - // "TRACK OK" Message. } else { - // "TRACK ERR 2" Message to LCD. Error 2 means connectivity is working, but something else went wrong (Response Status 400), like data is corrupted. HEX decode Traccar Server log message. Keep trying. currentTime := time.Now() if TargetBoard == "rpi" { if TrackEnabled { @@ -642,20 +447,9 @@ func httpSendTraccar() { } } } - // "TRACK ERR2" Message. - } // - // Note: When sending over Traccar client ports 5055, 5159 response code should be 200 OK. No "body text" is visible. - // If using Trccar web port 8082 to test, code 200 OK and "body text" from Traccar server will show. + } } -// OsmAnd End - -// Some helper functons to use with GPS - -// Truncate function. Need to truncate .0000 / milliseconds time from GPSTime. Is there a more simple way? -// example: Time := fmt.Sprint(truncateString(GPSTime,8)) -> show only the first 8 characters, ending with seconds. -// Should gps time be different type? int64? - func truncateString(str string, num int) string { shortstr := str if len(str) > num { @@ -664,28 +458,16 @@ func truncateString(str string, num int) string { return shortstr } -// Or trim string like this fmt... (string[:num])... num from which character. - -// helper to reorder gps date from dd/mm/yy to yyyy/mm/dd format - func gpsdatereorder() string { GPSDate := "01/12/19" // Works with hard coded date for test. How to make date from GPS visible to helper? - //GPSDate := fmt.Sprintf("%s", m.Date) dd := GPSDate[0:2] - //fmt.Println(yy) //test - //runtime error: slice bounds out of range! But works in Go Playground. Need to fix this error. mm := GPSDate[3:5] - //fmt.Println(mm) // test yy := GPSDate[6:8] - //fmt.Println(dd) //test yyyy := "20" + yy - //fmt.Println(yyyy) //test Date1reorder := yyyy + "-" + mm + "-" + dd - //fmt.Println(Date1reorder) return Date1reorder } -// current time system stamp func time2() string { currentTime := time.Now() Time2 := fmt.Sprintf("%s", currentTime.Format("15:04:05")) diff --git a/stream.go b/stream.go index 8c5ae41..84b092f 100644 --- a/stream.go +++ b/stream.go @@ -43,15 +43,11 @@ import ( ) var ( - errState = errors.New("gumbleopenal: invalid state") - lcdtext = [4]string{"nil", "nil", "nil", ""} - now = time.Now() - LastTime = now.Unix() - debuglevel = 2 - emptyBufs = openal.NewBuffers(16) - StreamCounter = 0 - TimerTalked = time.NewTicker(time.Millisecond * 200) - RXLEDStatus = false + errState = errors.New("gumbleopenal: invalid state") + lcdtext = [4]string{"nil", "nil", "nil", ""} + now = time.Now() + debuglevel = 2 + emptyBufs = openal.NewBuffers(16) ) type Stream struct { diff --git a/xmlparser.go b/xmlparser.go index e82492b..04fac01 100644 --- a/xmlparser.go +++ b/xmlparser.go @@ -40,59 +40,76 @@ import ( "strconv" "strings" "time" + goled "github.com/talkkonnect/go-oled-i2c" "github.com/talkkonnect/go-openal/openal" + "github.com/talkkonnect/gpio" "github.com/talkkonnect/gumble/gumble" "github.com/talkkonnect/gumble/gumbleffmpeg" "golang.org/x/sys/unix" - "github.com/talkkonnect/gpio" ) //version and release date const ( - talkkonnectVersion string = "1.67.20" - talkkonnectReleased string = "Aug 29 2021" + talkkonnectVersion string = "1.67.21" + talkkonnectReleased string = "Aug 30 2021" ) // Generic Global Variables var ( - pstream *gumbleffmpeg.Stream - AccountCount int = 0 - KillHeartBeat bool = false - IsPlayStream bool = false - BackLightTime = time.NewTicker(5 * time.Second) - BackLightTimePtr = &BackLightTime - ConnectAttempts = 0 - IsConnected bool = false - source = openal.NewSource() - StartTime = time.Now() - BufferToOpenALCounter = 0 - AccountIndex int = 0 - GenericCounter int = 0 + AccountCount int + KillHeartBeat bool + IsPlayStream bool + ConnectAttempts int + IsConnected bool + BufferToOpenALCounter int + AccountIndex int + GenericCounter int IsNumlock bool + RXLEDStatus bool + BackLightTime = time.NewTicker(5 * time.Second) + BackLightTimePtr = &BackLightTime + source = openal.NewSource() + StartTime = time.Now() + LastTime = now.Unix() + StreamCounter = 0 + TimerTalked = time.NewTicker(time.Millisecond * 200) + LcdText = [4]string{"nil", "nil", "nil", "nil"} + ConfigXMLFile string + Streaming bool + ServerHop bool + HTTPServRunning bool + NowStreaming bool + MyLedStrip *LedStrip + TargetBoard string = "pc" + CancellableStream bool = true + StreamOnStart bool + StreamStartAfter uint ) -//keyboard settings +// Generic Local Variables for xmlparser var ( - USBKeyboardPath string = "/dev/input/event0" - USBKeyboardEnabled bool - NumlockScanID rune + txcounter int + isTx bool + pstream *gumbleffmpeg.Stream ) //account settings var ( - Default []bool - Name []string - Server []string - Username []string - Password []string - Insecure []bool - Register []bool - Certificate []string - Channel []string - Ident []string - Tokens []gumble.AccessTokens - VT []VTStruct + Default []bool + Name []string + Server []string + Username []string + Password []string + Insecure []bool + Register []bool + Certificate []string + Channel []string + Ident []string + Tokens []gumble.AccessTokens + VT []VTStruct + Accounts int + MaxTokensInAccounts int ) //software settings @@ -300,11 +317,6 @@ var ( TTSPlayIntoStream bool ) -// target board settings -var ( - TargetBoard string = "pc" -) - //indicator light settings var ( LedStripEnabled bool @@ -313,19 +325,19 @@ var ( TransmitLEDPin uint OnlineLEDPin uint AttentionLEDPin uint - OnlineLED gpio.Pin - ParticipantsLED gpio.Pin - TransmitLED gpio.Pin - HeartBeatLED gpio.Pin - BackLightLED gpio.Pin - VoiceActivityLED gpio.Pin - AttentionLED gpio.Pin + HeartBeatLEDPin uint + VoiceActivityLED gpio.Pin + ParticipantsLED gpio.Pin + TransmitLED gpio.Pin + OnlineLED gpio.Pin + AttentionLED gpio.Pin + HeartBeatLED gpio.Pin + BackLightLED gpio.Pin ) //heartbeat light settings var ( HeartBeatEnabled bool - HeartBeatLEDPin uint PeriodmSecs int LEDOnmSecs int LEDOffmSecs int @@ -333,32 +345,31 @@ var ( //button settings var ( - TxButtonPin uint - TxTogglePin uint - UpButtonPin uint - DownButtonPin uint - PanicButtonPin uint - StreamButtonPin uint - TxButton gpio.Pin - TxButtonState uint - TxToggle gpio.Pin - TxToggleState uint - UpButton gpio.Pin - UpButtonState uint - DownButton gpio.Pin - DownButtonState uint - PanicButton gpio.Pin - PanicButtonState uint - CommentButton gpio.Pin - CommentButtonState uint - StreamButton gpio.Pin - StreamButtonState uint - + TxButton gpio.Pin + TxToggle gpio.Pin + UpButton gpio.Pin + DownButton gpio.Pin + PanicButton gpio.Pin + CommentButton gpio.Pin + StreamButton gpio.Pin + TxButtonPin uint + TxTogglePin uint + TxButtonState uint + TxToggleState uint + UpButtonPin uint + UpButtonState uint + DownButtonPin uint + DownButtonState uint + PanicButtonPin uint + PanicButtonState uint + StreamButtonPin uint + StreamButtonState uint + CommentButtonState uint + CommentButtonPin uint ) //comment settings var ( - CommentButtonPin uint CommentMessageOff string CommentMessageOn string ) @@ -422,6 +433,7 @@ var ( GpsInfoVerbose bool ) +//traccar var ( TrackEnabled bool TraccarSendTo bool @@ -433,6 +445,16 @@ var ( TraccarServerFullURL string TrackGPSShowLCD bool TrackVerbose bool + TraccarPortT55 string = "5005" // Old Traccar Client port 5005 for working with T55 Protocol + TraccarPortOpenGTS string = "5159" // Traccar Client port 5159 for for working OpenGTS Protocol + TraccarPortOsmAnd string = "5055" // Traccar Client port 5055 for working with OsmAnd Protocol + GPSTime string + GPSDate string + GPSLatitude float64 + GPSLongitude float64 + GPSSpeed float64 + GPSCourse float64 + GPSVariation float64 ) //panic function settings @@ -450,6 +472,7 @@ var ( PLowProfile bool ) +// audio recording var ( AudioRecordEnabled bool AudioRecordOnStart bool @@ -467,19 +490,17 @@ var ( AudioRecordChunkSize string ) +//keyboard settings var ( - txcounter int - isTx bool - CancellableStream bool = true - StreamOnStart bool - StreamStartAfter uint - Accounts int - MaxTokensInAccounts int + USBKeyboardPath string = "/dev/input/event0" + USBKeyboardEnabled bool + NumlockScanID rune + TTYKeyMap = make(map[rune]TTYKBStruct) + USBKeyMap = make(map[rune]USBKBStruct) ) +//read xml config into struct var Document DocumentStruct -var TTYKeyMap = make(map[rune]TTYKBStruct) -var USBKeyMap = make(map[rune]USBKBStruct) type DocumentStruct struct { XMLName xml.Name `xml:"document"`