func (v TxSchedulePriority) MarshalText() ([]byte, error) {
	return []byte(v.String()), nil
}
MarshalText implements encoding.TextMarshaler interface.
package ttnpb
import (
	"encoding/json"
	"fmt"
	"strconv"
	"time"
	"github.com/blang/semver"
	"github.com/gogo/protobuf/jsonpb"
	"github.com/vmihailenco/msgpack/v5"
	"go.thethings.network/lorawan-stack/v3/pkg/errors"
	"go.thethings.network/lorawan-stack/v3/pkg/types"
)
var PHYVersionCompatibleName = map[int32]string{}
func init() {
	for i := range PHYVersion_name {
		PHYVersion_value[PHYVersion(i).String()] = i
	}
	for name, version := range map[string]PHYVersion{
		"1.0":   TS001_V1_0,        
		"1.0.2": RP001_V1_0_2,      
		"1.1-a": RP001_V1_1_REV_A,  
		"1.1-b": RP001_V1_1_REV_B,  
	} {
		PHYVersion_value[name] = int32(version)
	}
	for version, name := range PHYVersion_name {
		PHYVersionCompatibleName[version] = name
	}
	for name, version := range map[string]PHYVersion{
		"PHY_V1_0":         TS001_V1_0,
		"PHY_V1_0_1":       TS001_V1_0_1,
		"PHY_V1_0_2_REV_A": RP001_V1_0_2,
		"PHY_V1_0_2_REV_B": RP001_V1_0_2_REV_B,
		"PHY_V1_1_REV_A":   RP001_V1_1_REV_A,
		"PHY_V1_1_REV_B":   RP001_V1_1_REV_B,
		"PHY_V1_0_3_REV_A": RP001_V1_0_3_REV_A,
	} {
		PHYVersion_value[name] = int32(version)
		PHYVersionCompatibleName[int32(version)] = name
	}
}
func (v MType) MarshalBinary() ([]byte, error) {
	return marshalBinaryEnum(int32(v)), nil
}
func (v MType) MarshalText() ([]byte, error) {
	return []byte(v.String()), nil
}
func (v MType) MarshalJSON() ([]byte, error) {
	return marshalJSONEnum(MType_name, int32(v))
}
func (v *MType) UnmarshalBinary(b []byte) error {
	i, err := unmarshalEnumFromBinary("MType", MType_name, b)
	if err != nil {
		return err
	}
	*v = MType(i)
	return nil
}
func (v *MType) UnmarshalText(b []byte) error {
	i, err := unmarshalEnumFromText("MType", MType_value, b)
	if err != nil {
		return err
	}
	*v = MType(i)
	return nil
}
func (v *MType) UnmarshalJSON(b []byte) error {
	if bt, ok := unmarshalJSONString(b); ok {
		return v.UnmarshalText(bt)
	}
	i, err := unmarshalEnumFromNumber("MType", MType_name, b)
	if err != nil {
		return err
	}
	*v = MType(i)
	return nil
}
func (v Major) MarshalBinary() ([]byte, error) {
	return marshalBinaryEnum(int32(v)), nil
}
func (v Major) MarshalText() ([]byte, error) {
	return []byte(v.String()), nil
}
func (v Major) MarshalJSON() ([]byte, error) {
	return marshalJSONEnum(Major_name, int32(v))
}
func (v *Major) UnmarshalBinary(b []byte) error {
	i, err := unmarshalEnumFromBinary("Major", Major_name, b)
	if err != nil {
		return err
	}
	*v = Major(i)
	return nil
}
func (v *Major) UnmarshalText(b []byte) error {
	i, err := unmarshalEnumFromTextPrefix("Major", Major_value, "LORAWAN_", b)
	if err != nil {
		return err
	}
	*v = Major(i)
	return nil
}
func (v *Major) UnmarshalJSON(b []byte) error {
	if bt, ok := unmarshalJSONString(b); ok {
		return v.UnmarshalText(bt)
	}
	i, err := unmarshalEnumFromNumber("Major", Major_name, b)
	if err != nil {
		return err
	}
	*v = Major(i)
	return nil
}
func (v MACVersion) MarshalBinary() ([]byte, error) {
	return marshalBinaryEnum(int32(v)), nil
}
func (v MACVersion) MarshalText() ([]byte, error) {
	return []byte(v.String()), nil
}
func (v MACVersion) MarshalJSON() ([]byte, error) {
	return marshalJSONEnum(MACVersion_name, int32(v))
}
func (v MACVersion) EncodeMsgpack(enc *msgpack.Encoder) error {
	if v > 255 {
		panic(fmt.Errorf("MACVersion enum exceeds 255"))
	}
	return enc.EncodeUint8(uint8(v))
}
func (v *MACVersion) UnmarshalBinary(b []byte) error {
	i, err := unmarshalEnumFromBinary("MACVersion", MACVersion_name, b)
	if err != nil {
		return err
	}
	*v = MACVersion(i)
	return nil
}
func (v *MACVersion) UnmarshalText(b []byte) error {
	i, err := unmarshalEnumFromTextPrefix("MACVersion", MACVersion_value, "MAC_", b)
	if err != nil {
		return err
	}
	*v = MACVersion(i)
	return nil
}
func (v *MACVersion) UnmarshalJSON(b []byte) error {
	if bt, ok := unmarshalJSONString(b); ok {
		return v.UnmarshalText(bt)
	}
	i, err := unmarshalEnumFromNumber("MACVersion", MACVersion_name, b)
	if err != nil {
		return err
	}
	*v = MACVersion(i)
	return nil
}
func (v *MACVersion) DecodeMsgpack(dec *msgpack.Decoder) error {
	i, err := dec.DecodeInt32()
	if err != nil {
		return err
	}
	*v = MACVersion(i)
	return nil
}
func (v PHYVersion) MarshalBinary() ([]byte, error) {
	return marshalBinaryEnum(int32(v)), nil
}
func (v PHYVersion) MarshalText() ([]byte, error) {
	return []byte(v.String()), nil
}
func (v PHYVersion) MarshalJSON() ([]byte, error) {
	return marshalJSONEnum(PHYVersionCompatibleName, int32(v))
}
func (v *PHYVersion) UnmarshalBinary(b []byte) error {
	i, err := unmarshalEnumFromBinary("PHYVersion", PHYVersion_name, b)
	if err != nil {
		return err
	}
	*v = PHYVersion(i)
	return nil
}
func (v *PHYVersion) UnmarshalText(b []byte) error {
	i, err := unmarshalEnumFromTextPrefix("PHYVersion", PHYVersion_value, "PHY_", b)
	if err != nil {
		return err
	}
	*v = PHYVersion(i)
	return nil
}
func (v *PHYVersion) UnmarshalJSON(b []byte) error {
	if bt, ok := unmarshalJSONString(b); ok {
		return v.UnmarshalText(bt)
	}
	i, err := unmarshalEnumFromNumber("PHYVersion", PHYVersion_name, b)
	if err != nil {
		return err
	}
	*v = PHYVersion(i)
	return nil
}
func (v DataRateIndex) String() string {
	return strconv.Itoa(int(v))
}
func (v DataRateIndex) MarshalBinary() ([]byte, error) {
	return marshalBinaryEnum(int32(v)), nil
}
func (v DataRateIndex) MarshalText() ([]byte, error) {
	return []byte(v.String()), nil
}
func (v DataRateIndex) MarshalJSON() ([]byte, error) {
	return json.Marshal(int32(v))
}
func (v DataRateIndex) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error) {
	return v.MarshalJSON()
}
func (v *DataRateIndex) UnmarshalBinary(b []byte) error {
	i, err := unmarshalEnumFromBinary("DataRateIndex", DataRateIndex_name, b)
	if err != nil {
		return err
	}
	*v = DataRateIndex(i)
	return nil
}
func (v *DataRateIndex) UnmarshalText(b []byte) error {
	i, err := unmarshalEnumFromTextPrefix("DataRateIndex", DataRateIndex_value, "DATA_RATE_", b)
	if err != nil {
		return err
	}
	*v = DataRateIndex(i)
	return nil
}
func (v *DataRateIndex) UnmarshalJSON(b []byte) error {
	if bt, ok := unmarshalJSONString(b); ok {
		return v.UnmarshalText(bt)
	}
	i, err := unmarshalEnumFromNumber("DataRateIndex", DataRateIndex_name, b)
	if err != nil {
		return err
	}
	*v = DataRateIndex(i)
	return nil
}
func (v *DataRateIndex) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, b []byte) error {
	return v.UnmarshalJSON(b)
}
func (v DataRateIndexValue) MarshalBinary() ([]byte, error) {
	return v.Value.MarshalBinary()
}
func (v DataRateIndexValue) MarshalText() ([]byte, error) {
	return v.Value.MarshalText()
}
func (v DataRateIndexValue) MarshalJSON() ([]byte, error) {
	return v.Value.MarshalJSON()
}
func (v DataRateIndexValue) MarshalJSONPB(m *jsonpb.Marshaler) ([]byte, error) {
	return v.Value.MarshalJSONPB(m)
}
func (v *DataRateIndexValue) UnmarshalBinary(b []byte) error {
	var vv DataRateIndex
	if err := vv.UnmarshalBinary(b); err != nil {
		return err
	}
	*v = DataRateIndexValue{
		Value: vv,
	}
	return nil
}
func (v *DataRateIndexValue) UnmarshalText(b []byte) error {
	var vv DataRateIndex
	if err := vv.UnmarshalText(b); err != nil {
		return err
	}
	*v = DataRateIndexValue{
		Value: vv,
	}
	return nil
}
func (v *DataRateIndexValue) UnmarshalJSON(b []byte) error {
	var vv DataRateIndex
	if err := vv.UnmarshalJSON(b); err != nil {
		return err
	}
	*v = DataRateIndexValue{
		Value: vv,
	}
	return nil
}
func (v *DataRateIndexValue) UnmarshalJSONPB(u *jsonpb.Unmarshaler, b []byte) error {
	var vv DataRateIndex
	if err := vv.UnmarshalJSONPB(u, b); err != nil {
		return err
	}
	*v = DataRateIndexValue{
		Value: vv,
	}
	return nil
}
func (v *DataRateIndexValue) FieldIsZero(p string) bool {
	if v == nil {
		return true
	}
	switch p {
	case "value":
		return v.Value == 0
	}
	panic(fmt.Sprintf("unknown path '%s'", p))
}
func (v DataRateOffset) String() string {
	return strconv.Itoa(int(v))
}
func (v DataRateOffset) MarshalBinary() ([]byte, error) {
	return marshalBinaryEnum(int32(v)), nil
}
func (v DataRateOffset) MarshalText() ([]byte, error) {
	return []byte(v.String()), nil
}
func (v DataRateOffset) MarshalJSON() ([]byte, error) {
	return json.Marshal(int32(v))
}
func (v DataRateOffset) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error) {
	return v.MarshalJSON()
}
func (v *DataRateOffset) UnmarshalBinary(b []byte) error {
	i, err := unmarshalEnumFromBinary("DataRateOffset", DataRateOffset_name, b)
	if err != nil {
		return err
	}
	*v = DataRateOffset(i)
	return nil
}
func (v *DataRateOffset) UnmarshalText(b []byte) error {
	i, err := unmarshalEnumFromTextPrefix("DataRateOffset", DataRateOffset_value, "DATA_RATE_OFFSET_", b)
	if err != nil {
		return err
	}
	*v = DataRateOffset(i)
	return nil
}
func (v *DataRateOffset) UnmarshalJSON(b []byte) error {
	if bt, ok := unmarshalJSONString(b); ok {
		return v.UnmarshalText(bt)
	}
	i, err := unmarshalEnumFromNumber("DataRateOffset", DataRateOffset_name, b)
	if err != nil {
		return err
	}
	*v = DataRateOffset(i)
	return nil
}
func (v *DataRateOffset) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, b []byte) error {
	return v.UnmarshalJSON(b)
}
func (v DataRateOffsetValue) MarshalBinary() ([]byte, error) {
	return v.Value.MarshalBinary()
}
func (v DataRateOffsetValue) MarshalText() ([]byte, error) {
	return v.Value.MarshalText()
}
func (v DataRateOffsetValue) MarshalJSON() ([]byte, error) {
	return v.Value.MarshalJSON()
}
func (v DataRateOffsetValue) MarshalJSONPB(m *jsonpb.Marshaler) ([]byte, error) {
	return v.Value.MarshalJSONPB(m)
}
func (v *DataRateOffsetValue) UnmarshalBinary(b []byte) error {
	var vv DataRateOffset
	if err := vv.UnmarshalBinary(b); err != nil {
		return err
	}
	*v = DataRateOffsetValue{
		Value: vv,
	}
	return nil
}
func (v *DataRateOffsetValue) UnmarshalText(b []byte) error {
	var vv DataRateOffset
	if err := vv.UnmarshalText(b); err != nil {
		return err
	}
	*v = DataRateOffsetValue{
		Value: vv,
	}
	return nil
}
func (v *DataRateOffsetValue) UnmarshalJSON(b []byte) error {
	var vv DataRateOffset
	if err := vv.UnmarshalJSON(b); err != nil {
		return err
	}
	*v = DataRateOffsetValue{
		Value: vv,
	}
	return nil
}
func (v *DataRateOffsetValue) UnmarshalJSONPB(u *jsonpb.Unmarshaler, b []byte) error {
	var vv DataRateOffset
	if err := vv.UnmarshalJSONPB(u, b); err != nil {
		return err
	}
	*v = DataRateOffsetValue{
		Value: vv,
	}
	return nil
}
func (v *DataRateOffsetValue) FieldIsZero(p string) bool {
	if v == nil {
		return true
	}
	switch p {
	case "value":
		return v.Value == 0
	}
	panic(fmt.Sprintf("unknown path '%s'", p))
}
func (v FrequencyValue) MarshalText() ([]byte, error) {
	return []byte(strconv.FormatUint(v.Value, 10)), nil
}
func (v FrequencyValue) MarshalJSON() ([]byte, error) {
	b, err := v.MarshalText()
	if err != nil {
		return nil, err
	}
	return json.Marshal(string(b))
}
func (v FrequencyValue) MarshalJSONPB(m *jsonpb.Marshaler) ([]byte, error) {
	return v.MarshalJSON()
}
func (v *FrequencyValue) UnmarshalText(b []byte) error {
	var vv uint64
	vv, err := strconv.ParseUint(string(b), 10, 64)
	if err != nil {
		return err
	}
	*v = FrequencyValue{
		Value: vv,
	}
	return nil
}
func (v *FrequencyValue) UnmarshalJSON(b []byte) error {
	if bt, ok := unmarshalJSONString(b); ok {
		return v.UnmarshalText(bt)
	}
	return v.UnmarshalText(b)
}
func (v *FrequencyValue) UnmarshalJSONPB(_ *jsonpb.Unmarshaler, b []byte) error {
	return v.UnmarshalJSON(b)
}
func (v *FrequencyValue) FieldIsZero(p string) bool {
	if v == nil {
		return true
	}
	switch p {
	case "value":
		return v.Value == 0
	}
	panic(fmt.Sprintf("unknown path '%s'", p))
}
func (v JoinRequestType) MarshalBinary() ([]byte, error) {
	return marshalBinaryEnum(int32(v)), nil
}
func (v JoinRequestType) MarshalText() ([]byte, error) {
	return []byte(v.String()), nil
}
func (v JoinRequestType) MarshalJSON() ([]byte, error) {
	return marshalJSONEnum(JoinRequestType_name, int32(v))
}
func (v *JoinRequestType) UnmarshalBinary(b []byte) error {
	i, err := unmarshalEnumFromBinary("JoinRequestType", JoinRequestType_name, b)
	if err != nil {
		return err
	}
	*v = JoinRequestType(i)
	return nil
}
func (v *JoinRequestType) UnmarshalText(b []byte) error {
	i, err := unmarshalEnumFromText("JoinRequestType", JoinRequestType_value, b)
	if err != nil {
		return err
	}
	*v = JoinRequestType(i)
	return nil
}
func (v *JoinRequestType) UnmarshalJSON(b []byte) error {
	if bt, ok := unmarshalJSONString(b); ok {
		return v.UnmarshalText(bt)
	}
	i, err := unmarshalEnumFromNumber("JoinRequestType", JoinRequestType_name, b)
	if err != nil {
		return err
	}
	*v = JoinRequestType(i)
	return nil
}
func (v RejoinRequestType) MarshalBinary() ([]byte, error) {
	return marshalBinaryEnum(int32(v)), nil
}
func (v RejoinRequestType) MarshalText() ([]byte, error) {
	return []byte(v.String()), nil
}
func (v RejoinRequestType) MarshalJSON() ([]byte, error) {
	return marshalJSONEnum(RejoinRequestType_name, int32(v))
}
func (v *RejoinRequestType) UnmarshalBinary(b []byte) error {
	i, err := unmarshalEnumFromBinary("RejoinRequestType", RejoinRequestType_name, b)
	if err != nil {
		return err
	}
	*v = RejoinRequestType(i)
	return nil
}
func (v *RejoinRequestType) UnmarshalText(b []byte) error {
	i, err := unmarshalEnumFromText("RejoinRequestType", RejoinRequestType_value, b)
	if err != nil {
		return err
	}
	*v = RejoinRequestType(i)
	return nil
}
func (v *RejoinRequestType) UnmarshalJSON(b []byte) error {
	if bt, ok := unmarshalJSONString(b); ok {
		return v.UnmarshalText(bt)
	}
	i, err := unmarshalEnumFromNumber("RejoinRequestType", RejoinRequestType_name, b)
	if err != nil {
		return err
	}
	*v = RejoinRequestType(i)
	return nil
}
func (v CFListType) MarshalBinary() ([]byte, error) {
	return marshalBinaryEnum(int32(v)), nil
}
func (v CFListType) MarshalText() ([]byte, error) {
	return []byte(v.String()), nil
}
func (v CFListType) MarshalJSON() ([]byte, error) {
	return marshalJSONEnum(CFListType_name, int32(v))
}
func (v *CFListType) UnmarshalBinary(b []byte) error {
	i, err := unmarshalEnumFromBinary("CFListType", CFListType_name, b)
	if err != nil {
		return err
	}
	*v = CFListType(i)
	return nil
}
func (v *CFListType) UnmarshalText(b []byte) error {
	i, err := unmarshalEnumFromText("CFListType", CFListType_value, b)
	if err != nil {
		return err
	}
	*v = CFListType(i)
	return nil
}
func (v *CFListType) UnmarshalJSON(b []byte) error {
	if bt, ok := unmarshalJSONString(b); ok {
		return v.UnmarshalText(bt)
	}
	i, err := unmarshalEnumFromNumber("CFListType", CFListType_name, b)
	if err != nil {
		return err
	}
	*v = CFListType(i)
	return nil
}
func (v Class) MarshalBinary() ([]byte, error) {
	return marshalBinaryEnum(int32(v)), nil
}
func (v Class) MarshalText() ([]byte, error) {
	return []byte(v.String()), nil
}
func (v Class) MarshalJSON() ([]byte, error) {
	return marshalJSONEnum(Class_name, int32(v))
}
func (v *Class) UnmarshalBinary(b []byte) error {
	i, err := unmarshalEnumFromBinary("Class", Class_name, b)
	if err != nil {
		return err
	}
	*v = Class(i)
	return nil
}
func (v *Class) UnmarshalText(b []byte) error {
	i, err := unmarshalEnumFromTextPrefix("Class", Class_value, "CLASS_", b)
	if err != nil {
		return err
	}
	*v = Class(i)
	return nil
}
func (v *Class) UnmarshalJSON(b []byte) error {
	if bt, ok := unmarshalJSONString(b); ok {
		return v.UnmarshalText(bt)
	}
	i, err := unmarshalEnumFromNumber("Class", Class_name, b)
	if err != nil {
		return err
	}
	*v = Class(i)
	return nil
}
func (v TxSchedulePriority) MarshalBinary() ([]byte, error) {
	return marshalBinaryEnum(int32(v)), nil
}