MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / ToDeviceID

Function ToDeviceID

pkg/unique/unique.go:73–87  ·  view source on GitHub ↗

ToDeviceID returns the end device identifier of the specified unique ID.

(uid string)

Source from the content-addressed store, hash-verified

71
72// ToDeviceID returns the end device identifier of the specified unique ID.
73func ToDeviceID(uid string) (id *ttnpb.EndDeviceIdentifiers, err error) {
74 id = &ttnpb.EndDeviceIdentifiers{}
75 before, after, ok := strings.Cut(uid, ".")
76 if !ok {
77 return nil, errFormat.WithAttributes("value", uid)
78 }
79 id.ApplicationIds = &ttnpb.ApplicationIdentifiers{
80 ApplicationId: before,
81 }
82 id.DeviceId = after
83 if err := id.ValidateFields("device_id", "application_ids"); err != nil {
84 return nil, errUniqueIdentifier.WithCause(err).WithAttributes("uid", uid)
85 }
86 return id, nil
87}
88
89// ToGatewayID returns the gateway identifier of the specified unique ID.
90func ToGatewayID(uid string) (id *ttnpb.GatewayIdentifiers, err error) {

Callers 12

DeleteDeviceDataMethod · 0.92
PopMethod · 0.92
addToBatchFunction · 0.92
RangeByUplinkMatchesMethod · 0.92
UniqueEUIViolationErrFunction · 0.92
decodeEventMetaFunction · 0.92
DeleteDeviceDataMethod · 0.92
clearMethod · 0.92
TestRoundtripFunction · 0.85

Calls 3

WithAttributesMethod · 0.45
ValidateFieldsMethod · 0.45
WithCauseMethod · 0.45

Tested by 2

TestRoundtripFunction · 0.68