Skip to content

Commit 9da9d8f

Browse files
committed
Accept prefixed callsigns, e.g. SP/N1ADJ
1 parent 0a18a25 commit 9da9d8f

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

encoding.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var EncodedDestinationAllBytes = [6]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
2020

2121
const m17Chars = " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-/."
2222

23-
var callsignRegex = regexp.MustCompile(`^[0-9]?[A-Z]{1,2}[0-9]{1,2}[A-Z]{1,4}([ -/\.][A-Z0-9 -/\.]*)?$`)
23+
var callsignRegex = regexp.MustCompile(`^([0-9]?[A-Z]{1,2}[0-9]{0,2}/)?[0-9]?[A-Z]{1,2}[0-9]{1,2}[A-Z]{1,4}([ -/\.][A-Z0-9 -/\.]*)?$`)
2424
var roomRegex = regexp.MustCompile(`^#[A-Z0-9 -/\.]+$`)
2525

2626
func EncodeCallsign(callsign string) (*[6]byte, error) {

encoding_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ func TestEncodeCallsign(t *testing.T) {
2525
want: &[6]byte{0, 17, 44, 18, 146, 174},
2626
wantErr: false,
2727
},
28+
{name: "SP/N1ADJ",
29+
args: args{callsign: "SP/N1ADJ"},
30+
want: &[6]byte{1, 129, 83, 62, 220, 19},
31+
wantErr: false,
32+
},
33+
{name: "SP5/N1ADJ",
34+
args: args{callsign: "SP5/N1ADJ"},
35+
want: &[6]byte{60, 53, 1, 210, 198, 147},
36+
wantErr: false,
37+
},
2838
{name: "n1adj",
2939
args: args{callsign: "N1ADJ"},
3040
want: &[6]byte{0, 0, 1, 138, 146, 174},

0 commit comments

Comments
 (0)