Skip to content

Commit

Permalink
qrg: Rename ttigpro1 symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlad Vitan committed Sep 10, 2024
1 parent ce0d840 commit 76ed694
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pkg/qrcodegenerator/qrcode/gateways/gateways.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func New(_ context.Context) *Server {
// preferentially match with those first.
gatewayFormats: []gatewayFormat{
{
id: formatIDTTIGPRO1,
id: ttigpro1FormatID,
format: new(TTIGPRO1Format),
},
},
Expand Down
21 changes: 10 additions & 11 deletions pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,21 @@ import (
)

const (
formatIDTTIGPRO1 = "ttigpro1"

euiLength = 16
ownerTokenLength = 12
ttigpro1FormatID = "ttigpro1"
ttigpro1EUILength = 16
ttigpro1OwnerTokenLength = 12
)

// ttigpro1Regex is the regular expression to match the TTIGPRO1 format.
// The format is as follows: https://ttig.pro/c/{16 lowercase base16 chars}/{12 base62 chars}.
var ttigpro1Regex = regexp.MustCompile(`^https://ttig\.pro/c/([a-f0-9]{16})/([a-z0-9]{12})$`)

// TTIGPRO1 is a format for gateway identification QR codes.
type ttigpro1 struct {
gatewayEUI types.EUI64
ownerToken string
}

// ttigpro1Regex is the regular expression to match the TTIGPRO1 format.
// The format is as follows: https://ttig.pro/c/{16 lowercase base16 chars}/{12 base62 chars}.
var ttigpro1Regex = regexp.MustCompile(`^https://ttig\.pro/c/([a-f0-9]{16})/([a-z0-9]{12})$`)

// UnmarshalText implements the TextUnmarshaler interface.
func (m *ttigpro1) UnmarshalText(text []byte) error {
// Match the URL against the pattern
Expand All @@ -52,7 +51,7 @@ func (m *ttigpro1) UnmarshalText(text []byte) error {

m.ownerToken = matches[2]

if len(m.ownerToken) != ownerTokenLength {
if len(m.ownerToken) != ttigpro1OwnerTokenLength {
return errInvalidLength
}

Expand All @@ -61,7 +60,7 @@ func (m *ttigpro1) UnmarshalText(text []byte) error {

// FormatID implements the Data interface.
func (*ttigpro1) FormatID() string {
return formatIDTTIGPRO1
return ttigpro1FormatID
}

func (m *ttigpro1) GatewayEUI() types.EUI64 {
Expand Down Expand Up @@ -89,7 +88,7 @@ func (TTIGPRO1Format) Format() *ttnpb.QRCodeFormat {

// ID is the identifier of the format as a string.
func (TTIGPRO1Format) ID() string {
return formatIDTTIGPRO1
return ttigpro1FormatID
}

// New implements the Format interface.
Expand Down

0 comments on commit 76ed694

Please sign in to comment.