protocol/aprs: refactored
Some checks failed
Run tests / test (1.25) (push) Failing after 1m37s
Run tests / test (stable) (push) Failing after 1m37s

This commit is contained in:
2026-03-02 22:28:17 +01:00
parent 452f521866
commit 63040a44b3
24 changed files with 3506 additions and 1533 deletions

56
protocol/aprs/util.go Normal file
View File

@@ -0,0 +1,56 @@
package aprs
import (
"strconv"
"strings"
)
func isDigit(b byte) bool {
return b >= '0' && b <= '9'
}
func feetToMeters(v float64) float64 {
return v * 0.3048
}
func knotsToMetersPerSecond(v float64) float64 {
return v * 0.514444444
}
func milesToMeters(v float64) float64 {
return v * 1609.344
}
func fahrenheitToCelcius(v float64) float64 {
return (v - 32) / 1.8
}
func fillZeros(s string) string {
s = strings.Replace(s, " ", "0", -1)
s = strings.Replace(s, ".", "0", -1)
return s
}
func pow(n, exp int) int {
if n <= 0 {
return 1
}
result := 1
for i := 0; i < exp; i++ {
result *= n
}
return result
}
func parseBytesWithSpaces(b []byte) (int, error) {
for i := len(b) - 1; i >= 0; i-- {
if b[i] == ' ' {
b[i] = '0'
} else {
break
}
}
return strconv.Atoi(string(b))
}