More protocols
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package aprs
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
@@ -46,6 +47,25 @@ func (a Address) Secret() int16 {
|
||||
return h & 0x7fff
|
||||
}
|
||||
|
||||
func (a Address) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(a.String())
|
||||
}
|
||||
|
||||
func (a *Address) UnmarshalJSON(b []byte) error {
|
||||
var s string
|
||||
if err := json.Unmarshal(b, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
p, err := ParseAddress(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
a.Call = p.Call
|
||||
a.SSID = p.SSID
|
||||
a.IsRepeated = p.IsRepeated
|
||||
return nil
|
||||
}
|
||||
|
||||
func ParseAddress(s string) (Address, error) {
|
||||
r := strings.HasSuffix(s, "*")
|
||||
if r {
|
||||
|
||||
Reference in New Issue
Block a user