diff --git a/pkg/qrcodegenerator/qrcode/gateways/gateways.go b/pkg/qrcodegenerator/qrcode/gateways/gateways.go index b50d3d4ddd1..c721e39f5c0 100644 --- a/pkg/qrcodegenerator/qrcode/gateways/gateways.go +++ b/pkg/qrcodegenerator/qrcode/gateways/gateways.go @@ -62,7 +62,7 @@ func New(_ context.Context) *Server { // preferentially match with those first. gatewayFormats: []gatewayFormat{ { - id: formatIDTTIGPRO1, + id: ttigpro1FormatID, format: new(TTIGPRO1Format), }, }, diff --git a/pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go b/pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go index e42284121f3..51bc796306a 100644 --- a/pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go +++ b/pkg/qrcodegenerator/qrcode/gateways/ttigpro1.go @@ -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 @@ -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 } @@ -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 { @@ -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.