From f1dbcb4e2b5647103b603f4561a4a4bf37e8637e Mon Sep 17 00:00:00 2001 From: Gregory Salaun Date: Tue, 22 Oct 2024 23:38:21 +0700 Subject: [PATCH] update --- config.yml | 4 ++-- database.go | 6 ++++-- flexradio.go | 27 ++++++++++----------------- spot.go | 2 +- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/config.yml b/config.yml index 9b0c30b..9f7d5a2 100644 --- a/config.yml +++ b/config.yml @@ -1,7 +1,7 @@ general: delete_log_file_at_start: true log_to_file: true - log_level: DEBUG + log_level: INFO httpserver: true telnetserver: true flexradiospot: true @@ -11,7 +11,7 @@ sqlite: cluster: server: dxc.k0xm.net port: 7300 - login: xv9q-2 + login: xv9q skimmer: true ft8: false ft4: false diff --git a/database.go b/database.go index c888f26..af77bf6 100644 --- a/database.go +++ b/database.go @@ -289,12 +289,13 @@ func (r *FlexDXClusterRepository) CreateSpot(spot FlexSpot) { query := "INSERT INTO `spots` (`commandNumber`, `flexSpotNumber`, `dx`, `freqMhz`, `freqHz`, `band`, `mode`, `spotter`, `flexMode`, `source`, `time`, `timestamp`, `lifeTime`, `priority`, `comment`, `color`, `backgroundColor`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" insertResult, err := r.db.ExecContext(context.Background(), query, spot.CommandNumber, spot.CommandNumber, spot.DX, spot.FrequencyMhz, spot.FrequencyHz, spot.Band, spot.Mode, spot.SpotterCallsign, spot.FlexMode, spot.Source, spot.UTCTime, time.Now().Unix(), spot.LifeTime, spot.Priority, spot.Comment, spot.Color, spot.BackgroundColor) if err != nil { - log.Errorf("cannot insert spot in database: %s", err) + Log.Errorf("cannot insert spot in database: %s", err) } _, err = insertResult.LastInsertId() + Log.Debugf("Adding to database spot for: %s", spot.DX) if err != nil { - log.Errorf("impossible to retrieve last inserted id: %s", err) + Log.Errorf("impossible to retrieve last inserted id: %s", err) } } @@ -306,6 +307,7 @@ func (r *FlexDXClusterRepository) UpdateSpotSameBand(spot FlexSpot) error { r.Log.Errorf("could not update database: %s", err) return err } + Log.Debugf("Updating spot to database: %s", spot.DX) return nil } diff --git a/flexradio.go b/flexradio.go index f849d2a..e1cb93d 100644 --- a/flexradio.go +++ b/flexradio.go @@ -142,11 +142,14 @@ func (fc *FlexClient) SendSpottoFlex(spot TelnetSpot) { Worked: spot.CallsignWorked, } + flexSpot.Comment = flexSpot.Comment + " [" + flexSpot.Mode + "] [" + flexSpot.SpotterCallsign + "]" + // If new DXCC if spot.NewDXCC { flexSpot.Color = "#3bf908" flexSpot.Priority = "1" flexSpot.BackgroundColor = "#000000" + flexSpot.Comment = flexSpot.Comment + " [ New DXCC ]" } else if spot.DX == Cfg.SQLite.Callsign { flexSpot.Color = "#ff0000" flexSpot.Priority = "1" @@ -155,25 +158,28 @@ func (fc *FlexClient) SendSpottoFlex(spot TelnetSpot) { flexSpot.Color = "#000000" flexSpot.BackgroundColor = "#00c0c0" flexSpot.Priority = "5" + flexSpot.Comment = flexSpot.Comment + " [ Worked ]" } else if spot.NewMode && spot.NewBand { flexSpot.Color = "#c603fc" flexSpot.Priority = "1" flexSpot.BackgroundColor = "#000000" + flexSpot.Comment = flexSpot.Comment + " [ New Band & Mode ]" } else if spot.NewMode && !spot.NewBand { flexSpot.Color = "#f9a908" flexSpot.Priority = "2" flexSpot.BackgroundColor = "#000000" + flexSpot.Comment = flexSpot.Comment + " [ New Mode ]" } else if spot.NewBand && !spot.NewMode { flexSpot.Color = "#f9f508" flexSpot.Priority = "3" flexSpot.BackgroundColor = "#000000" + flexSpot.Comment = flexSpot.Comment + " [ New Band ]" } else if !spot.NewBand && !spot.NewMode && !spot.NewDXCC && !spot.CallsignWorked { flexSpot.Color = "#eaeaea" flexSpot.Priority = "5" flexSpot.BackgroundColor = "#000000" } - flexSpot.Comment = flexSpot.Comment + " [" + flexSpot.Mode + "] [" + flexSpot.SpotterCallsign + "]" flexSpot.Comment = strings.ReplaceAll(flexSpot.Comment, " ", "\u00A0") srcFlexSpot, err := fc.Repo.FindDXSameBand(flexSpot) @@ -204,10 +210,10 @@ func (fc *FlexClient) SendSpottoFlex(spot TelnetSpot) { stringSpot = fmt.Sprintf("C%v|spot add rx_freq=%v callsign=%s mode=%s source=%s spotter_callsign=%s timestamp=%v lifetime_seconds=%s comment=%s color=%s background_color=%s priority=%s", flexSpot.CommandNumber, flexSpot.FrequencyMhz, flexSpot.DX, flexSpot.Mode, flexSpot.Source, flexSpot.SpotterCallsign, flexSpot.TimeStamp, flexSpot.LifeTime, flexSpot.Comment, flexSpot.Color, flexSpot.BackgroundColor, flexSpot.Priority) CommandNumber++ - } fc.SendSpot(stringSpot) + Log.Debugf("Sending spot to FlexRadio: %s", stringSpot) } func (fc *FlexClient) SendSpot(stringSpot string) { @@ -223,6 +229,8 @@ func (fc *FlexClient) ReadLine() { os.Exit(1) } + Log.Debugf("Received message from FlexRadio: %s", strings.Trim(message, "\n")) + regRespSpot := *regexp.MustCompile(`R(\d+)\|0\|(\d+)\n`) respSpot := regRespSpot.FindStringSubmatch(message) @@ -271,18 +279,3 @@ func (fc *FlexClient) Write(data string) (n int, err error) { } return } - -func (fc *FlexClient) parseMessage(message string) { - msgType := string(message[0]) - - switch msgType { - case "R": - // reply - case "S": - // status - case "V": - // Version - case "M": - // Message - } -} diff --git a/spot.go b/spot.go index 1aaa8c8..35b11f3 100644 --- a/spot.go +++ b/spot.go @@ -104,7 +104,7 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChan chan TelnetSp spot.DX, spot.Spotter, spot.Frequency, spot.Band, spot.Mode, spot.Comment, spot.Time, spot.DXCC) } } else { - Log.Infof("Could not decode: %s", strings.Trim(spotRaw, "\n")) + Log.Errorf("Could not decode: %s", strings.Trim(spotRaw, "\n")) } }