Skip to content

Commit

Permalink
disable sending data if dial is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremychase committed Mar 12, 2022
1 parent 00b4287 commit ae7bb44
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
18 changes: 11 additions & 7 deletions cmd/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,19 @@ func awpHandlerV1(opts options) http.Handler {
}
}

fmt.Printf("sending, temp(%d): %v\n", wx.Temp, wx.String())
if opts.dial != nil {
fmt.Printf("Sending, temp(%d): %v\n", wx.Temp, wx.String())

f.Text = wx.String()
f.Text = wx.String()

err := f.SendIS(opts.dial, opts.dialpass)
if err != nil {
msg := fmt.Sprintf("Upload error: %s", err)
errorHandler(w, req, msg, http.StatusServiceUnavailable)
return
err := f.SendIS(*opts.dial, opts.dialpass)
if err != nil {
msg := fmt.Sprintf("Upload error: %s", err)
errorHandler(w, req, msg, http.StatusServiceUnavailable)
return
}
} else {
fmt.Printf("Received but not sending, temp(%d): %v\n", wx.Temp, wx.String())
}

w.WriteHeader(http.StatusOK)
Expand Down
8 changes: 7 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ func parseArgs() (options, error) {
flag.Float64Var(&opts.latitude, "latitude", 0.0, "latitude (decimal)")
flag.StringVar(&opts.callsign, "callsign", "", "callsign")
flag.StringVar(&opts.comment, "comment", "", "comment")
flag.StringVar(&opts.dial, "dial", "tcp://cwop.aprs.net:14580", "dial address")

var dial string
flag.StringVar(&dial, "dial", "tcp://cwop.aprs.net:14580", "dial address (disabled if empty)")
flag.IntVar(&opts.dialpass, "dialpass", -1, "dial pass")

var rl string
Expand All @@ -61,6 +63,10 @@ func parseArgs() (options, error) {

flag.Parse()

if len(dial) > 0 {
opts.dial = &dial
}

if len(rl) > 0 {
opts.requestlog = &rl
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type options struct {
aprsSource aprs.Addr
callsign string
comment string
dial string
dial *string
ssid string
argAddress string
requestlog *string
Expand Down

0 comments on commit ae7bb44

Please sign in to comment.