storage

package
v3.16.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2023 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RX1 = iota
	RX2
)

Available RX window options.

View Source
const (
	ModulationFSK  = "FSK"
	ModulationLoRa = "LORA"
)

Modulations

View Source
const (
	DeviceProfileKeyTempl = "lora:ns:dp:%s"
)

Templates used for generating Redis keys

View Source
const (
	ServiceProfileKeyTempl = "lora:ns:sp:%s"
)

Templates used for generating Redis keys

View Source
const UplinkHistorySize = 20

UplinkHistorySize contains the number of frames to store

Variables

View Source
var (
	ErrAlreadyExists              = errors.New("object already exists")
	ErrDoesNotExist               = errors.New("object does not exist")
	ErrFrameCounterRetransmission = errors.New("frame-counter did not increment")
	ErrFrameCounterReset          = errors.New("frame-counter reset or rollover occured")
	ErrInvalidMIC                 = errors.New("invalid MIC")
	ErrInvalidAggregationInterval = errors.New("invalid aggregation interval")
	ErrInvalidName                = errors.New("invalid gateway name")
	ErrInvalidFPort               = errors.New("invalid fPort (must be > 0)")
)

errors

View Source
var File_device_session_proto protoreflect.FileDescriptor
View Source
var File_downlink_frame_proto protoreflect.FileDescriptor

Functions

func AddDeviceToMulticastGroup

func AddDeviceToMulticastGroup(ctx context.Context, db sqlx.Execer, devEUI lorawan.EUI64, multicastGroupID uuid.UUID) error

AddDeviceToMulticastGroup adds the given device to the given multicast-group.

func ClearDeviceNoncesForDevice added in v3.16.0

func ClearDeviceNoncesForDevice(ctx context.Context, db sqlx.Execer, devEUI lorawan.EUI64) error

ClearDeviceNoncesForDevice removes the device DevNonce from device-activation for the given DevEUI.

func CreateDevice

func CreateDevice(ctx context.Context, db sqlx.Execer, d *Device) error

CreateDevice creates the given device.

func CreateDeviceActivation

func CreateDeviceActivation(ctx context.Context, db sqlx.Queryer, da *DeviceActivation) error

CreateDeviceActivation creates the given device-activation.

func CreateDeviceProfile

func CreateDeviceProfile(ctx context.Context, db sqlx.Execer, dp *DeviceProfile) error

CreateDeviceProfile creates the given device-profile.

func CreateDeviceProfileCache

func CreateDeviceProfileCache(ctx context.Context, dp DeviceProfile) error

CreateDeviceProfileCache caches the given device-profile in Redis. The TTL of the device-profile is the same as that of the device-sessions.

func CreateDeviceQueueItem

func CreateDeviceQueueItem(ctx context.Context, db sqlx.Queryer, qi *DeviceQueueItem, dp DeviceProfile, ds DeviceSession) error

CreateDeviceQueueItem adds the given item to the device-queue. In case the device is operating in Class-B, this will schedule the item at the next ping-slot.

func CreateGateway

func CreateGateway(ctx context.Context, db sqlx.Execer, gw *Gateway) error

CreateGateway creates the given gateway.

func CreateGatewayMetaCache

func CreateGatewayMetaCache(ctx context.Context, gw GatewayMeta) error

CreateGatewayMetaCache caches the given gateway meta in Redis. The TTL of the gateway is the same as that of the device-sessions.

func CreateGatewayProfile

func CreateGatewayProfile(ctx context.Context, db sqlx.Execer, c *GatewayProfile) error

CreateGatewayProfile creates the given gateway-profile. As this will execute multiple SQL statements, it is recommended to perform this within a transaction.

func CreateMACCommandQueueItem

func CreateMACCommandQueueItem(ctx context.Context, devEUI lorawan.EUI64, block MACCommandBlock) error

CreateMACCommandQueueItem creates a new mac-command queue item.

func CreateMulticastGroup

func CreateMulticastGroup(ctx context.Context, db sqlx.Execer, mg *MulticastGroup) error

CreateMulticastGroup creates the given multi-cast group.

func CreateMulticastQueueItem

func CreateMulticastQueueItem(ctx context.Context, db sqlx.Queryer, qi *MulticastQueueItem) error

CreateMulticastQueueItem adds the given item to the queue.

func CreateRoutingProfile

func CreateRoutingProfile(ctx context.Context, db sqlx.Execer, rp *RoutingProfile) error

CreateRoutingProfile creates the given routing-profile.

func CreateServiceProfile

func CreateServiceProfile(ctx context.Context, db sqlx.Execer, sp *ServiceProfile) error

CreateServiceProfile creates the given service-profile.

func CreateServiceProfileCache

func CreateServiceProfileCache(ctx context.Context, sp ServiceProfile) error

CreateServiceProfileCache caches the given service-profile into the Redis. This is used for faster lookups, but also in case of roaming where we only want to store the service-profile of a roaming device for a finite duration. The TTL of the service-profile is the same as that of the device-sessions.

func DeleteDevice

func DeleteDevice(ctx context.Context, db sqlx.Execer, devEUI lorawan.EUI64) error

DeleteDevice deletes the device matching the given DevEUI.

func DeleteDeviceActivationsForDevice

func DeleteDeviceActivationsForDevice(ctx context.Context, db sqlx.Execer, devEUI lorawan.EUI64) error

DeleteDeviceActivationsForDevice removes the device-activation for the given DevEUI.

func DeleteDeviceGatewayRXInfoSet

func DeleteDeviceGatewayRXInfoSet(ctx context.Context, devEUI lorawan.EUI64) error

DeleteDeviceGatewayRXInfoSet deletes the device gateway rx-info meta-data for the given Device EUI.

func DeleteDeviceProfile

func DeleteDeviceProfile(ctx context.Context, db sqlx.Execer, id uuid.UUID) error

DeleteDeviceProfile deletes the device-profile matching the given id.

func DeleteDeviceQueueItem

func DeleteDeviceQueueItem(ctx context.Context, db sqlx.Execer, id int64) error

DeleteDeviceQueueItem deletes the device-queue item matching the given id.

func DeleteDeviceSession

func DeleteDeviceSession(ctx context.Context, devEUI lorawan.EUI64) error

DeleteDeviceSession deletes the device-session matching the given DevEUI.

func DeleteGateway

func DeleteGateway(ctx context.Context, db sqlx.Execer, id lorawan.EUI64) error

DeleteGateway deletes the gateway matching the given Gateway ID.

func DeleteGatewayProfile

func DeleteGatewayProfile(ctx context.Context, db sqlx.Execer, id uuid.UUID) error

DeleteGatewayProfile deletes the gateway-profile matching the given ID.

func DeleteMACCommandQueueItem

func DeleteMACCommandQueueItem(ctx context.Context, devEUI lorawan.EUI64, block MACCommandBlock) error

DeleteMACCommandQueueItem deletes the given mac-command from the queue.

func DeleteMulticastGroup

func DeleteMulticastGroup(ctx context.Context, db sqlx.Execer, id uuid.UUID) error

DeleteMulticastGroup deletes the multicast-group matching the given ID.

func DeleteMulticastQueueItem

func DeleteMulticastQueueItem(ctx context.Context, db sqlx.Execer, id int64) error

DeleteMulticastQueueItem deletes the queue-item given an id.

func DeletePendingMACCommand

func DeletePendingMACCommand(ctx context.Context, devEUI lorawan.EUI64, cid lorawan.CID) error

DeletePendingMACCommand removes the pending mac-command for the given CID.

func DeleteRoutingProfile

func DeleteRoutingProfile(ctx context.Context, db sqlx.Execer, id uuid.UUID) error

DeleteRoutingProfile deletes the routing-profile matching the given id.

func DeleteServiceProfile

func DeleteServiceProfile(ctx context.Context, db sqlx.Execer, id uuid.UUID) error

DeleteServiceProfile deletes the service-profile matching the given id.

func DeviceSessionExists

func DeviceSessionExists(ctx context.Context, devEUI lorawan.EUI64) (bool, error)

DeviceSessionExists returns a bool indicating if a device session exist.

func FlushDeviceProfileCache

func FlushDeviceProfileCache(ctx context.Context, id uuid.UUID) error

FlushDeviceProfileCache deletes a cached device-profile.

func FlushDeviceQueueForDevEUI

func FlushDeviceQueueForDevEUI(ctx context.Context, db sqlx.Execer, devEUI lorawan.EUI64) error

FlushDeviceQueueForDevEUI deletes all device-queue items for the given DevEUI.

func FlushGatewayMetaCache

func FlushGatewayMetaCache(ctx context.Context, gatewayID lorawan.EUI64) error

FlushGatewayMetaCache flushes the gateway meta cache.

func FlushGatewayMetaCacheForServiceProfile

func FlushGatewayMetaCacheForServiceProfile(ctx context.Context, db sqlx.Queryer, serviceProfileID uuid.UUID) error

FlushGatewayMetaCacheForServiceProfile flushes the gateway meta-cache for gateways using the given service-profile ID.

func FlushMACCommandQueue

func FlushMACCommandQueue(ctx context.Context, devEUI lorawan.EUI64) error

FlushMACCommandQueue flushes the mac-command queue for the given DevEUI.

func FlushMulticastQueueForMulticastGroup

func FlushMulticastQueueForMulticastGroup(ctx context.Context, db sqlx.Execer, multicastGroupID uuid.UUID) error

FlushMulticastQueueForMulticastGroup flushes the multicast-queue given a multicast-group id.

func FlushServiceProfileCache

func FlushServiceProfileCache(ctx context.Context, id uuid.UUID) error

FlushServiceProfileCache deletes a cached service-profile.

func GetDevEUIsForDevAddr

func GetDevEUIsForDevAddr(ctx context.Context, devAddr lorawan.DevAddr) ([]lorawan.EUI64, error)

GetDevEUIsForDevAddr returns the DevEUIs that are using the given DevAddr.

func GetDevEUIsForMulticastGroup

func GetDevEUIsForMulticastGroup(ctx context.Context, db sqlx.Queryer, multicastGroupID uuid.UUID) ([]lorawan.EUI64, error)

GetDevEUIsForMulticastGroup returns all Device EUIs within the given multicast-group id.

func GetDeviceQueueItemCountForDevEUI

func GetDeviceQueueItemCountForDevEUI(ctx context.Context, db sqlx.Queryer, devEUI lorawan.EUI64) (int, error)

GetDeviceQueueItemCountForDevEUI returns the device-queue item count for the given DevEUI.

func GetFullFCntUp

func GetFullFCntUp(nextExpectedFullFCnt, truncatedFCntUp uint32) uint32

GetFullFCntUp returns the full 32bit frame-counter, given the fCntUp which has been truncated to the last 16 LSB. Notes:

  • After a succesful validation of the FCntUp and the MIC, don't forget to synchronize the device FCntUp with the packet FCnt.
  • In case of a frame-counter rollover, the returned values will be less than the given DeviceSession FCntUp. This must be validated outside this function!
  • In case of a re-transmission, the returned frame-counter equals DeviceSession.FCntUp - 1, as the FCntUp value holds the next expected frame-counter, not the FCntUp which was last seen.

func GetGatewaysForIDs

func GetGatewaysForIDs(ctx context.Context, db sqlx.Queryer, ids []lorawan.EUI64) (map[lorawan.EUI64]Gateway, error)

GetGatewaysForIDs returns a map of gateways given a slice of IDs.

func GetMaxEmitAtTimeSinceGPSEpochForDevEUI

func GetMaxEmitAtTimeSinceGPSEpochForDevEUI(ctx context.Context, db sqlx.Queryer, devEUI lorawan.EUI64) (time.Duration, error)

GetMaxEmitAtTimeSinceGPSEpochForDevEUI returns the maximum / last GPS epoch scheduling timestamp for the given DevEUI.

func GetMaxEmitAtTimeSinceGPSEpochForMulticastGroup

func GetMaxEmitAtTimeSinceGPSEpochForMulticastGroup(ctx context.Context, db sqlx.Queryer, multicastGroupID uuid.UUID) (time.Duration, error)

GetMaxEmitAtTimeSinceGPSEpochForMulticastGroup returns the maximum / last GPS epoch scheduling timestamp for the given multicast-group.

func GetMaxScheduleAtForMulticastGroup

func GetMaxScheduleAtForMulticastGroup(ctx context.Context, db sqlx.Queryer, multicastGroupID uuid.UUID) (time.Time, error)

GetMaxScheduleAtForMulticastGroup returns the maximum schedule at timestamp for the given multicast-group.

func GetMulticastGroupsForDevEUI

func GetMulticastGroupsForDevEUI(ctx context.Context, db sqlx.Queryer, devEUI lorawan.EUI64) ([]uuid.UUID, error)

GetMulticastGroupsForDevEUI returns the multicast-group ids to which the given Device EUI belongs.

func GetPassiveRoamingIDsForDevAddr

func GetPassiveRoamingIDsForDevAddr(ctx context.Context, devAddr lorawan.DevAddr) ([]uuid.UUID, error)

GetPassiveRoamingIDsForDevAddr returns the passive-roaming session IDs for the given DevAddr.

func GetRandomDevAddr

func GetRandomDevAddr(netID lorawan.NetID) (lorawan.DevAddr, error)

GetRandomDevAddr returns a random DevAddr, prefixed with NwkID based on the given NetID.

func GetRedisKey

func GetRedisKey(tmpl string, params ...interface{}) string

GetRedisKey returns the Redis key given a template and parameters.

func MigrateDown

func MigrateDown(db *sqlx.DB) error

MigrateDown configure postgres migration down

func MigrateUp

func MigrateUp(db *sqlx.DB) error

MigrateUp configure postgres migration up

func RedisClient

func RedisClient() redis.UniversalClient

RedisClient returns the Redis client.

func RemoveDeviceFromMulticastGroup

func RemoveDeviceFromMulticastGroup(ctx context.Context, db sqlx.Execer, devEUI lorawan.EUI64, multicastGroupID uuid.UUID) error

RemoveDeviceFromMulticastGroup removes the given device from the given multicast-group.

func SaveDeviceGatewayRXInfoSet

func SaveDeviceGatewayRXInfoSet(ctx context.Context, rxInfoSet DeviceGatewayRXInfoSet) error

SaveDeviceGatewayRXInfoSet saves the given DeviceGatewayRXInfoSet.

func SaveDeviceSession

func SaveDeviceSession(ctx context.Context, s DeviceSession) error

SaveDeviceSession saves the device-session. In case it doesn't exist yet it will be created.

func SaveDownlinkFrame

func SaveDownlinkFrame(ctx context.Context, frame *DownlinkFrame) error

SaveDownlinkFrame saves the given downlink-frame.

func SavePassiveRoamingDeviceSession

func SavePassiveRoamingDeviceSession(ctx context.Context, ds *PassiveRoamingDeviceSession) error

SavePassiveRoamingDeviceSession saves the passive-roaming device-session.

func SetPendingMACCommand

func SetPendingMACCommand(ctx context.Context, devEUI lorawan.EUI64, block MACCommandBlock) error

SetPendingMACCommand sets a mac-command to the pending buffer. In case an other mac-command with the same CID has been set to pending, it will be overwritten.

func SetTimeLocation

func SetTimeLocation(name string) error

SetTimeLocation sets the time location.

func Setup

func Setup(c config.Config) error

Setup configures the storage backend.

func Transaction

func Transaction(f func(tx sqlx.Ext) error) error

Transaction wraps the given function in a transaction. In case the given functions returns an error, the transaction will be rolled back.

func UpdateDevice

func UpdateDevice(ctx context.Context, db sqlx.Execer, d *Device) error

UpdateDevice updates the given device.

func UpdateDeviceProfile

func UpdateDeviceProfile(ctx context.Context, db sqlx.Execer, dp *DeviceProfile) error

UpdateDeviceProfile updates the given device-profile.

func UpdateDeviceQueueItem

func UpdateDeviceQueueItem(ctx context.Context, db sqlx.Execer, qi *DeviceQueueItem) error

UpdateDeviceQueueItem updates the given device-queue item.

func UpdateGateway

func UpdateGateway(ctx context.Context, db sqlx.Execer, gw *Gateway) error

UpdateGateway updates the given gateway.

func UpdateGatewayProfile

func UpdateGatewayProfile(ctx context.Context, db sqlx.Execer, c *GatewayProfile) error

UpdateGatewayProfile updates the given gateway-profile. As this will execute multiple SQL statements, it is recommended to perform this within a transaction.

func UpdateGatewayState

func UpdateGatewayState(ctx context.Context, db sqlx.Execer, id lorawan.EUI64, lat, lon, alt float64) error

UpdateGatewayState updates the location of the gateway and last seen ts.

func UpdateMulticastGroup

func UpdateMulticastGroup(ctx context.Context, db sqlx.Execer, mg *MulticastGroup) error

UpdateMulticastGroup updates the given multicast-grup.

func UpdateMulticastQueueItem

func UpdateMulticastQueueItem(ctx context.Context, db sqlx.Execer, qi *MulticastQueueItem) error

UpdateMulticastQueueItem updates the given multicast queue-item.

func UpdateRoutingProfile

func UpdateRoutingProfile(ctx context.Context, db sqlx.Execer, rp *RoutingProfile) error

UpdateRoutingProfile updates the given routing-profile.

func UpdateServiceProfile

func UpdateServiceProfile(ctx context.Context, db sqlx.Execer, sp *ServiceProfile) error

UpdateServiceProfile updates the given service-profile.

func ValidateDevNonce

func ValidateDevNonce(ctx context.Context, db sqlx.Queryer, joinEUI, devEUI lorawan.EUI64, nonce lorawan.DevNonce, joinType lorawan.JoinType) error

ValidateDevNonce validates the given dev-nonce for the given DevEUI / JoinEUI combination.

Types

type AggregationInterval

type AggregationInterval string

AggregationInterval defines the aggregation type.

const (
	AggregationMinute AggregationInterval = "MINUTE"
	AggregationHour   AggregationInterval = "HOUR"
	AggregationDay    AggregationInterval = "DAY"
	AggregationMonth  AggregationInterval = "MONTH"
)

Metrics aggregation intervals.

type DBLogger

type DBLogger struct {
	*sqlx.DB
}

DBLogger is a DB wrapper which logs the executed sql queries and their duration.

func DB

func DB() *DBLogger

DB returns the PostgreSQL database object.

func (*DBLogger) Beginx

func (db *DBLogger) Beginx() (*TxLogger, error)

Beginx returns a transaction with logging.

func (*DBLogger) Exec

func (db *DBLogger) Exec(query string, args ...interface{}) (sql.Result, error)

Exec logs the queries executed by the Exec method.

func (*DBLogger) Query

func (db *DBLogger) Query(query string, args ...interface{}) (*sql.Rows, error)

Query logs the queries executed by the Query method.

func (*DBLogger) QueryRowx

func (db *DBLogger) QueryRowx(query string, args ...interface{}) *sqlx.Row

QueryRowx logs the queries executed by the QueryRowx method.

func (*DBLogger) Queryx

func (db *DBLogger) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)

Queryx logs the queries executed by the Queryx method.

type Device

type Device struct {
	DevEUI            lorawan.EUI64 `db:"dev_eui"`
	CreatedAt         time.Time     `db:"created_at"`
	UpdatedAt         time.Time     `db:"updated_at"`
	DeviceProfileID   uuid.UUID     `db:"device_profile_id"`
	ServiceProfileID  uuid.UUID     `db:"service_profile_id"`
	RoutingProfileID  uuid.UUID     `db:"routing_profile_id"`
	SkipFCntCheck     bool          `db:"skip_fcnt_check"`
	ReferenceAltitude float64       `db:"reference_altitude"`
	Mode              DeviceMode    `db:"mode"`
	IsDisabled        bool          `db:"is_disabled"`
}

Device defines a LoRaWAN device.

func GetDevice

func GetDevice(ctx context.Context, db sqlx.Queryer, devEUI lorawan.EUI64, forUpdate bool) (Device, error)

GetDevice returns the device matching the given DevEUI.

func GetDevicesWithClassBOrClassCDeviceQueueItems

func GetDevicesWithClassBOrClassCDeviceQueueItems(ctx context.Context, db sqlx.Ext, count int) ([]Device, error)

GetDevicesWithClassBOrClassCDeviceQueueItems returns a slice of devices that qualify for downlink Class-C transmission. The device records will be locked for update so that multiple instances can run this query in parallel without the risk of duplicate scheduling.

type DeviceActivation

type DeviceActivation struct {
	ID          int64             `db:"id"`
	CreatedAt   time.Time         `db:"created_at"`
	DevEUI      lorawan.EUI64     `db:"dev_eui"`
	JoinEUI     lorawan.EUI64     `db:"join_eui"`
	DevAddr     lorawan.DevAddr   `db:"dev_addr"`
	FNwkSIntKey lorawan.AES128Key `db:"f_nwk_s_int_key"`
	SNwkSIntKey lorawan.AES128Key `db:"s_nwk_s_int_key"`
	NwkSEncKey  lorawan.AES128Key `db:"nwk_s_enc_key"`
	DevNonce    lorawan.DevNonce  `db:"dev_nonce"`
	JoinReqType lorawan.JoinType  `db:"join_req_type"`
}

DeviceActivation defines the device-activation for a LoRaWAN device.

func GetLastDeviceActivationForDevEUI

func GetLastDeviceActivationForDevEUI(ctx context.Context, db sqlx.Queryer, devEUI lorawan.EUI64) (DeviceActivation, error)

GetLastDeviceActivationForDevEUI returns the most recent activation for the given DevEUI.

type DeviceGatewayRXInfo

type DeviceGatewayRXInfo struct {
	GatewayID lorawan.EUI64
	RSSI      int
	LoRaSNR   float64
	Antenna   uint32
	Board     uint32
	Context   []byte
}

DeviceGatewayRXInfo holds the meta-data of a gateway receiving the last uplink message.

type DeviceGatewayRXInfoPB

type DeviceGatewayRXInfoPB struct {

	// Gateway ID.
	GatewayId []byte `protobuf:"bytes,1,opt,name=gateway_id,json=gatewayId,proto3" json:"gateway_id,omitempty"`
	// RSSI.
	Rssi int32 `protobuf:"varint,2,opt,name=rssi,proto3" json:"rssi,omitempty"`
	// LoRa SNR.
	LoraSnr float64 `protobuf:"fixed64,3,opt,name=lora_snr,json=loraSnr,proto3" json:"lora_snr,omitempty"`
	// Board.
	Board uint32 `protobuf:"varint,4,opt,name=board,proto3" json:"board,omitempty"`
	// Antenna.
	Antenna uint32 `protobuf:"varint,5,opt,name=antenna,proto3" json:"antenna,omitempty"`
	// Gateway specific context.
	Context []byte `protobuf:"bytes,6,opt,name=context,proto3" json:"context,omitempty"`
	// contains filtered or unexported fields
}

func (*DeviceGatewayRXInfoPB) Descriptor deprecated

func (*DeviceGatewayRXInfoPB) Descriptor() ([]byte, []int)

Deprecated: Use DeviceGatewayRXInfoPB.ProtoReflect.Descriptor instead.

func (*DeviceGatewayRXInfoPB) GetAntenna

func (x *DeviceGatewayRXInfoPB) GetAntenna() uint32

func (*DeviceGatewayRXInfoPB) GetBoard

func (x *DeviceGatewayRXInfoPB) GetBoard() uint32

func (*DeviceGatewayRXInfoPB) GetContext

func (x *DeviceGatewayRXInfoPB) GetContext() []byte

func (*DeviceGatewayRXInfoPB) GetGatewayId

func (x *DeviceGatewayRXInfoPB) GetGatewayId() []byte

func (*DeviceGatewayRXInfoPB) GetLoraSnr

func (x *DeviceGatewayRXInfoPB) GetLoraSnr() float64

func (*DeviceGatewayRXInfoPB) GetRssi

func (x *DeviceGatewayRXInfoPB) GetRssi() int32

func (*DeviceGatewayRXInfoPB) ProtoMessage

func (*DeviceGatewayRXInfoPB) ProtoMessage()

func (*DeviceGatewayRXInfoPB) ProtoReflect

func (x *DeviceGatewayRXInfoPB) ProtoReflect() protoreflect.Message

func (*DeviceGatewayRXInfoPB) Reset

func (x *DeviceGatewayRXInfoPB) Reset()

func (*DeviceGatewayRXInfoPB) String

func (x *DeviceGatewayRXInfoPB) String() string

type DeviceGatewayRXInfoSet

type DeviceGatewayRXInfoSet struct {
	DevEUI lorawan.EUI64
	DR     int
	Items  []DeviceGatewayRXInfo
}

DeviceGatewayRXInfoSet contains the rx-info set of the receiving gateways for the last uplink.

func GetDeviceGatewayRXInfoSet

func GetDeviceGatewayRXInfoSet(ctx context.Context, devEUI lorawan.EUI64) (DeviceGatewayRXInfoSet, error)

GetDeviceGatewayRXInfoSet returns the DeviceGatewayRXInfoSet for the given Device EUI.

func GetDeviceGatewayRXInfoSetForDevEUIs

func GetDeviceGatewayRXInfoSetForDevEUIs(ctx context.Context, devEUIs []lorawan.EUI64) ([]DeviceGatewayRXInfoSet, error)

GetDeviceGatewayRXInfoSetForDevEUIs returns the DeviceGatewayRXInfoSet objects for the given Device EUIs.

type DeviceGatewayRXInfoSetPB

type DeviceGatewayRXInfoSetPB struct {

	// Device EUI.
	DevEui []byte `protobuf:"bytes,1,opt,name=dev_eui,json=devEui,proto3" json:"dev_eui,omitempty"`
	// Data-rate.
	Dr uint32 `protobuf:"varint,2,opt,name=dr,proto3" json:"dr,omitempty"`
	// Items contains set items.
	Items []*DeviceGatewayRXInfoPB `protobuf:"bytes,3,rep,name=items,proto3" json:"items,omitempty"`
	// contains filtered or unexported fields
}

func (*DeviceGatewayRXInfoSetPB) Descriptor deprecated

func (*DeviceGatewayRXInfoSetPB) Descriptor() ([]byte, []int)

Deprecated: Use DeviceGatewayRXInfoSetPB.ProtoReflect.Descriptor instead.

func (*DeviceGatewayRXInfoSetPB) GetDevEui

func (x *DeviceGatewayRXInfoSetPB) GetDevEui() []byte

func (*DeviceGatewayRXInfoSetPB) GetDr

func (x *DeviceGatewayRXInfoSetPB) GetDr() uint32

func (*DeviceGatewayRXInfoSetPB) GetItems

func (*DeviceGatewayRXInfoSetPB) ProtoMessage

func (*DeviceGatewayRXInfoSetPB) ProtoMessage()

func (*DeviceGatewayRXInfoSetPB) ProtoReflect

func (x *DeviceGatewayRXInfoSetPB) ProtoReflect() protoreflect.Message

func (*DeviceGatewayRXInfoSetPB) Reset

func (x *DeviceGatewayRXInfoSetPB) Reset()

func (*DeviceGatewayRXInfoSetPB) String

func (x *DeviceGatewayRXInfoSetPB) String() string

type DeviceMode

type DeviceMode string

DeviceMode defines the mode in which the device operates.

const (
	DeviceModeA DeviceMode = "A"
	DeviceModeB DeviceMode = "B"
	DeviceModeC DeviceMode = "C"
)

Available device modes.

type DeviceProfile

type DeviceProfile struct {
	CreatedAt          time.Time `db:"created_at"`
	UpdatedAt          time.Time `db:"updated_at"`
	ID                 uuid.UUID `db:"device_profile_id"`
	SupportsClassB     bool      `db:"supports_class_b"`
	ClassBTimeout      int       `db:"class_b_timeout"` // Unit: seconds
	PingSlotPeriod     int       `db:"ping_slot_period"`
	PingSlotDR         int       `db:"ping_slot_dr"`
	PingSlotFreq       uint32    `db:"ping_slot_freq"` // in Hz
	SupportsClassC     bool      `db:"supports_class_c"`
	ClassCTimeout      int       `db:"class_c_timeout"`     // Unit: seconds
	MACVersion         string    `db:"mac_version"`         // Example: "1.0.2" [LW102]
	RegParamsRevision  string    `db:"reg_params_revision"` // Example: "B" [RP102B]
	RXDelay1           int       `db:"rx_delay_1"`
	RXDROffset1        int       `db:"rx_dr_offset_1"`
	RXDataRate2        int       `db:"rx_data_rate_2"`       // Unit: bits-per-second
	RXFreq2            uint32    `db:"rx_freq_2"`            // In Hz
	FactoryPresetFreqs []uint32  `db:"factory_preset_freqs"` // In Hz
	MaxEIRP            int       `db:"max_eirp"`             // In dBm
	MaxDutyCycle       int       `db:"max_duty_cycle"`       // Example: 10 indicates 10%
	SupportsJoin       bool      `db:"supports_join"`
	RFRegion           string    `db:"rf_region"`
	Supports32bitFCnt  bool      `db:"supports_32bit_fcnt"`
	ADRAlgorithmID     string    `db:"adr_algorithm_id"`
}

DeviceProfile defines the backend.DeviceProfile with some extra meta-data

func GetAndCacheDeviceProfile

func GetAndCacheDeviceProfile(ctx context.Context, db sqlx.Queryer, id uuid.UUID) (DeviceProfile, error)

GetAndCacheDeviceProfile returns the device-profile from cache in case available, else it will be retrieved from the database and then stored in cache.

func GetDeviceProfile

func GetDeviceProfile(ctx context.Context, db sqlx.Queryer, id uuid.UUID) (DeviceProfile, error)

GetDeviceProfile returns the device-profile matching the given id.

func GetDeviceProfileCache

func GetDeviceProfileCache(ctx context.Context, id uuid.UUID) (DeviceProfile, error)

GetDeviceProfileCache returns a cached device-profile.

type DeviceQueueItem

type DeviceQueueItem struct {
	ID                      int64           `db:"id"`
	CreatedAt               time.Time       `db:"created_at"`
	UpdatedAt               time.Time       `db:"updated_at"`
	DevAddr                 lorawan.DevAddr `db:"dev_addr"`
	DevEUI                  lorawan.EUI64   `db:"dev_eui"`
	FRMPayload              []byte          `db:"frm_payload"`
	FCnt                    uint32          `db:"f_cnt"`
	FPort                   uint8           `db:"f_port"`
	Confirmed               bool            `db:"confirmed"`
	IsPending               bool            `db:"is_pending"`
	EmitAtTimeSinceGPSEpoch *time.Duration  `db:"emit_at_time_since_gps_epoch"`
	TimeoutAfter            *time.Time      `db:"timeout_after"`
	RetryAfter              *time.Time      `db:"retry_after"`
}

DeviceQueueItem represents an item in the device queue (downlink).

func GetDeviceQueueItem

func GetDeviceQueueItem(ctx context.Context, db sqlx.Queryer, id int64) (DeviceQueueItem, error)

GetDeviceQueueItem returns the device-queue item matching the given id.

func GetDeviceQueueItemsForDevEUI

func GetDeviceQueueItemsForDevEUI(ctx context.Context, db sqlx.Queryer, devEUI lorawan.EUI64) ([]DeviceQueueItem, error)

GetDeviceQueueItemsForDevEUI returns all device-queue items for the given DevEUI, ordered by id (keep in mind FCnt rollover).

func GetNextDeviceQueueItemForDevEUI

func GetNextDeviceQueueItemForDevEUI(ctx context.Context, db sqlx.Queryer, devEUI lorawan.EUI64) (DeviceQueueItem, bool, error)

GetNextDeviceQueueItemForDevEUI returns the next device-queue item for the given DevEUI, ordered by f_cnt and a bool indicating if more items exist in the queue (note that the f_cnt should never roll over).

func GetPendingDeviceQueueItemForDevEUI

func GetPendingDeviceQueueItemForDevEUI(ctx context.Context, db sqlx.Queryer, devEUI lorawan.EUI64) (DeviceQueueItem, error)

GetPendingDeviceQueueItemForDevEUI returns the pending device-queue item for the given DevEUI.

func (DeviceQueueItem) Validate

func (d DeviceQueueItem) Validate() error

Validate validates the DeviceQueueItem.

type DeviceSession

type DeviceSession struct {
	// MAC version
	MACVersion string

	// profile ids
	DeviceProfileID  uuid.UUID
	ServiceProfileID uuid.UUID
	RoutingProfileID uuid.UUID

	// session data
	DevAddr        lorawan.DevAddr
	DevEUI         lorawan.EUI64
	JoinEUI        lorawan.EUI64
	FNwkSIntKey    lorawan.AES128Key
	SNwkSIntKey    lorawan.AES128Key
	NwkSEncKey     lorawan.AES128Key
	AppSKeyEvelope *KeyEnvelope
	FCntUp         uint32
	NFCntDown      uint32
	AFCntDown      uint32
	ConfFCnt       uint32

	// Only used by ABP activation
	SkipFCntValidation bool

	RXWindow     RXWindow
	RXDelay      uint8
	RX1DROffset  uint8
	RX2DR        uint8
	RX2Frequency uint32

	// TXPowerIndex which the node is using. The possible values are defined
	// by the lorawan/band package and are region specific. By default it is
	// assumed that the node is using TXPower 0. This value is controlled by
	// the ADR engine.
	TXPowerIndex int

	// DR defines the (last known) data-rate at which the node is operating.
	// This value is controlled by the ADR engine.
	DR int

	// ADR defines if the device has ADR enabled.
	ADR bool

	// MinSupportedTXPowerIndex defines the minimum supported tx-power index
	// by the node (default 0).
	MinSupportedTXPowerIndex int

	// MaxSupportedTXPowerIndex defines the maximum supported tx-power index
	// by the node, or 0 when not set.
	MaxSupportedTXPowerIndex int

	// NbTrans defines the number of transmissions for each unconfirmed uplink
	// frame. In case of 0, the default value is used.
	// This value is controlled by the ADR engine.
	NbTrans uint8

	EnabledChannels       []int                    // deprecated, migrated by GetDeviceSession
	EnabledUplinkChannels []int                    // channels that are activated on the node
	ExtraUplinkChannels   map[int]loraband.Channel // extra uplink channels, configured by the user
	ChannelFrequencies    []uint32                 // frequency of each channel
	UplinkHistory         []UplinkHistory          // contains the last 20 transmissions

	// LastDevStatusRequest contains the timestamp when the last device-status
	// request was made.
	LastDevStatusRequested time.Time

	// Class-B related configuration.
	BeaconLocked      bool
	PingSlotNb        int
	PingSlotDR        int
	PingSlotFrequency uint32

	// RejoinRequestEnabled defines if the rejoin-request is enabled on the
	// device.
	RejoinRequestEnabled bool

	// RejoinRequestMaxCountN defines the 2^(C+4) uplink message interval for
	// the rejoin-request.
	RejoinRequestMaxCountN int

	// RejoinRequestMaxTimeN defines the 2^(T+10) time interval (seconds)
	// for the rejoin-request.
	RejoinRequestMaxTimeN int

	RejoinCount0               uint16
	PendingRejoinDeviceSession *DeviceSession

	// ReferenceAltitude holds the device reference altitude used for
	// geolocation.
	ReferenceAltitude float64

	// Uplink and Downlink dwell time limitations.
	UplinkDwellTime400ms   bool
	DownlinkDwellTime400ms bool

	// Max uplink EIRP limitation.
	UplinkMaxEIRPIndex uint8

	// Delayed mac-commands.
	MACCommandErrorCount map[lorawan.CID]int

	// Device is disabled.
	IsDisabled bool
}

DeviceSession defines a device-session.

func GetDeviceSession

func GetDeviceSession(ctx context.Context, devEUI lorawan.EUI64) (DeviceSession, error)

GetDeviceSession returns the device-session for the given DevEUI.

func GetDeviceSessionForPHYPayload

func GetDeviceSessionForPHYPayload(ctx context.Context, phy lorawan.PHYPayload, txDR, txCh int) (DeviceSession, error)

GetDeviceSessionForPHYPayload returns the device-session matching the given PHYPayload. This will fetch all device-sessions associated with the used DevAddr and based on FCnt and MIC decide which one to use.

func GetDeviceSessionsForDevAddr

func GetDeviceSessionsForDevAddr(ctx context.Context, devAddr lorawan.DevAddr) ([]DeviceSession, error)

GetDeviceSessionsForDevAddr returns a slice of device-sessions using the given DevAddr. When no device-session is using the given DevAddr, this returns an empty slice.

func (*DeviceSession) AppendUplinkHistory

func (s *DeviceSession) AppendUplinkHistory(up UplinkHistory)

AppendUplinkHistory appends an UplinkHistory item and makes sure the list never exceeds 20 records. In case more records are present, only the most recent ones will be preserved. In case of a re-transmission, the record with the best MaxSNR is stored.

func (DeviceSession) GetMACVersion

func (s DeviceSession) GetMACVersion() lorawan.MACVersion

GetMACVersion returns the LoRaWAN mac version.

func (DeviceSession) GetPacketLossPercentage

func (s DeviceSession) GetPacketLossPercentage() float64

GetPacketLossPercentage returns the percentage of packet-loss over the records stored in UplinkHistory. Note it returns 0 when the uplink history table hasn't been filled yet to avoid reporting 33% for example when one of the first three uplinks was lost.

func (*DeviceSession) ResetToBootParameters

func (s *DeviceSession) ResetToBootParameters(dp DeviceProfile)

ResetToBootParameters resets the device-session to the device boo parameters as defined by the given device-profile.

type DeviceSessionPB

type DeviceSessionPB struct {

	// ID of the device-profile.
	DeviceProfileId string `protobuf:"bytes,1,opt,name=device_profile_id,json=deviceProfileId,proto3" json:"device_profile_id,omitempty"`
	// ID of the service-profile.
	ServiceProfileId string `protobuf:"bytes,2,opt,name=service_profile_id,json=serviceProfileId,proto3" json:"service_profile_id,omitempty"`
	// ID of the routing-profile.
	RoutingProfileId string `protobuf:"bytes,3,opt,name=routing_profile_id,json=routingProfileId,proto3" json:"routing_profile_id,omitempty"`
	// Device address.
	DevAddr []byte `protobuf:"bytes,4,opt,name=dev_addr,json=devAddr,proto3" json:"dev_addr,omitempty"`
	// Device EUI.
	DevEui []byte `protobuf:"bytes,5,opt,name=dev_eui,json=devEui,proto3" json:"dev_eui,omitempty"`
	// Join EUI.
	JoinEui []byte `protobuf:"bytes,6,opt,name=join_eui,json=joinEui,proto3" json:"join_eui,omitempty"`
	// FNwkSIntKey.
	FNwkSIntKey []byte `protobuf:"bytes,7,opt,name=f_nwk_s_int_key,json=fNwkSIntKey,proto3" json:"f_nwk_s_int_key,omitempty"`
	// SNwkSIntKey.
	SNwkSIntKey []byte `protobuf:"bytes,8,opt,name=s_nwk_s_int_key,json=sNwkSIntKey,proto3" json:"s_nwk_s_int_key,omitempty"`
	// NwkSEncKey.
	NwkSEncKey []byte `protobuf:"bytes,9,opt,name=nwk_s_enc_key,json=nwkSEncKey,proto3" json:"nwk_s_enc_key,omitempty"`
	// AppSKeyEnvelope contains the (encrypted) AppSKey key-envelope.
	AppSKeyEnvelope *common.KeyEnvelope `protobuf:"bytes,45,opt,name=app_s_key_envelope,json=appSKeyEnvelope,proto3" json:"app_s_key_envelope,omitempty"`
	// Uplink frame-counter.
	FCntUp uint32 `protobuf:"varint,10,opt,name=f_cnt_up,json=fCntUp,proto3" json:"f_cnt_up,omitempty"`
	// Downlink frame-counter (network-server).
	NFCntDown uint32 `protobuf:"varint,11,opt,name=n_f_cnt_down,json=nFCntDown,proto3" json:"n_f_cnt_down,omitempty"`
	// Uplink frame-counter (application-server).
	// Note: this frame-counter is managed by the application-server.
	AFCntDown uint32 `protobuf:"varint,12,opt,name=a_f_cnt_down,json=aFCntDown,proto3" json:"a_f_cnt_down,omitempty"`
	// Frame-counter holding the last confirmed downlink frame (n_f_cnt_down or a_f_cnt_down).
	ConfFCnt uint32 `protobuf:"varint,39,opt,name=conf_f_cnt,json=confFCnt,proto3" json:"conf_f_cnt,omitempty"`
	// Skip uplink frame-counter validation.
	SkipFCntCheck bool `protobuf:"varint,13,opt,name=skip_f_cnt_check,json=skipFCntCheck,proto3" json:"skip_f_cnt_check,omitempty"`
	// RX Delay.
	RxDelay uint32 `protobuf:"varint,14,opt,name=rx_delay,json=rxDelay,proto3" json:"rx_delay,omitempty"`
	// RX1 data-rate offset.
	Rx1DrOffset uint32 `protobuf:"varint,15,opt,name=rx1_dr_offset,json=rx1DrOffset,proto3" json:"rx1_dr_offset,omitempty"`
	// RX2 data-rate.
	Rx2Dr uint32 `protobuf:"varint,16,opt,name=rx2_dr,json=rx2Dr,proto3" json:"rx2_dr,omitempty"`
	// RX2 frequency.
	Rx2Frequency uint32 `protobuf:"varint,17,opt,name=rx2_frequency,json=rx2Frequency,proto3" json:"rx2_frequency,omitempty"`
	// TXPowerIndex which the node is using. The possible values are defined
	// by the lorawan/band package and are region specific. By default it is
	// assumed that the node is using TXPower 0. This value is controlled by
	// the ADR engine.
	TxPowerIndex uint32 `protobuf:"varint,18,opt,name=tx_power_index,json=txPowerIndex,proto3" json:"tx_power_index,omitempty"`
	// DR defines the (last known) data-rate at which the node is operating.
	// This value is controlled by the ADR engine.
	Dr uint32 `protobuf:"varint,19,opt,name=dr,proto3" json:"dr,omitempty"`
	// ADR defines if the device has ADR enabled.
	Adr bool `protobuf:"varint,20,opt,name=adr,proto3" json:"adr,omitempty"`
	// MaxSupportedTXPowerIndex defines the maximum supported tx-power index
	// by the node, or 0 when not set.
	MaxSupportedTxPowerIndex uint32 `` /* 141-byte string literal not displayed */
	// NbTrans defines the number of transmissions for each unconfirmed uplink
	// frame. In case of 0, the default value is used.
	// This value is controlled by the ADR engine.
	NbTrans uint32 `protobuf:"varint,23,opt,name=nb_trans,json=nbTrans,proto3" json:"nb_trans,omitempty"`
	// Channels that are activated on the device.
	EnabledUplinkChannels []uint32 `` /* 135-byte string literal not displayed */
	// Extra uplink channels, configured by the user.
	ExtraUplinkChannels map[uint32]*DeviceSessionPBChannel `` /* 210-byte string literal not displayed */
	// Frequency of each channel.
	ChannelFrequencies []uint32 `protobuf:"varint,26,rep,packed,name=channel_frequencies,json=channelFrequencies,proto3" json:"channel_frequencies,omitempty"`
	// Uplink history for ADR (last 20 uplink transmissions).
	UplinkAdrHistory []*DeviceSessionPBUplinkADRHistory `protobuf:"bytes,27,rep,name=uplink_adr_history,json=uplinkAdrHistory,proto3" json:"uplink_adr_history,omitempty"`
	// Last device-status requested timestamp (Unix ns)
	LastDeviceStatusRequestTimeUnixNs int64 `` /* 172-byte string literal not displayed */
	// Class-B beacon is locked.
	BeaconLocked bool `protobuf:"varint,33,opt,name=beacon_locked,json=beaconLocked,proto3" json:"beacon_locked,omitempty"`
	// Class-B ping-slot nb.
	PingSlotNb uint32 `protobuf:"varint,34,opt,name=ping_slot_nb,json=pingSlotNb,proto3" json:"ping_slot_nb,omitempty"`
	// Class-B ping-slot data-rate.
	PingSlotDr uint32 `protobuf:"varint,35,opt,name=ping_slot_dr,json=pingSlotDr,proto3" json:"ping_slot_dr,omitempty"`
	// Class-B ping-slot tx frequency.
	PingSlotFrequency uint32 `protobuf:"varint,36,opt,name=ping_slot_frequency,json=pingSlotFrequency,proto3" json:"ping_slot_frequency,omitempty"`
	// LoRaWAN mac-version.
	MacVersion string `protobuf:"bytes,37,opt,name=mac_version,json=macVersion,proto3" json:"mac_version,omitempty"`
	// MinSupportedTXPowerIndex defines the minimum supported tx-power index
	// by the node (default 0).
	MinSupportedTxPowerIndex uint32 `` /* 141-byte string literal not displayed */
	// RejoinRequestEnabled defines if the rejoin-request is enabled on the
	// device.
	RejoinRequestEnabled bool `protobuf:"varint,44,opt,name=rejoin_request_enabled,json=rejoinRequestEnabled,proto3" json:"rejoin_request_enabled,omitempty"`
	// RejoinRequestMaxCountN defines the 2^(C+4) uplink message interval for
	// the rejoin-request.
	RejoinRequestMaxCountN uint32 `` /* 135-byte string literal not displayed */
	// RejoinRequestMaxTimeN defines the 2^(T+10) time interval (seconds)
	// for the rejoin-request.
	RejoinRequestMaxTimeN uint32 `` /* 132-byte string literal not displayed */
	// Rejoin counter (RJCount0).
	// This counter is reset to 0 after each successful join-accept.
	RejoinCount_0 uint32 `protobuf:"varint,42,opt,name=rejoin_count_0,json=rejoinCount0,proto3" json:"rejoin_count_0,omitempty"`
	// Pending rejoin device-session contains a device-session which has not
	// yet been activated by the device (by sending a first uplink).
	PendingRejoinDeviceSession []byte `` /* 144-byte string literal not displayed */
	// Device reference altitude for geolocation.
	ReferenceAltitude float64 `protobuf:"fixed64,46,opt,name=reference_altitude,json=referenceAltitude,proto3" json:"reference_altitude,omitempty"`
	// UplinkDwellTime.
	UplinkDwellTime_400Ms bool `` /* 127-byte string literal not displayed */
	// DownlinkDwellTime.
	DownlinkDwellTime_400Ms bool `` /* 133-byte string literal not displayed */
	// Uplink max. EIRP index.
	UplinkMaxEirpIndex uint32 `protobuf:"varint,49,opt,name=uplink_max_eirp_index,json=uplinkMaxEirpIndex,proto3" json:"uplink_max_eirp_index,omitempty"`
	// Mac-command error counter.
	MacCommandErrorCount map[uint32]uint32 `` /* 216-byte string literal not displayed */
	// Device is disabled.
	IsDisabled bool `protobuf:"varint,51,opt,name=is_disabled,json=isDisabled,proto3" json:"is_disabled,omitempty"`
	// contains filtered or unexported fields
}

func (*DeviceSessionPB) Descriptor deprecated

func (*DeviceSessionPB) Descriptor() ([]byte, []int)

Deprecated: Use DeviceSessionPB.ProtoReflect.Descriptor instead.

func (*DeviceSessionPB) GetAFCntDown

func (x *DeviceSessionPB) GetAFCntDown() uint32

func (*DeviceSessionPB) GetAdr

func (x *DeviceSessionPB) GetAdr() bool

func (*DeviceSessionPB) GetAppSKeyEnvelope

func (x *DeviceSessionPB) GetAppSKeyEnvelope() *common.KeyEnvelope

func (*DeviceSessionPB) GetBeaconLocked

func (x *DeviceSessionPB) GetBeaconLocked() bool

func (*DeviceSessionPB) GetChannelFrequencies

func (x *DeviceSessionPB) GetChannelFrequencies() []uint32

func (*DeviceSessionPB) GetConfFCnt

func (x *DeviceSessionPB) GetConfFCnt() uint32

func (*DeviceSessionPB) GetDevAddr

func (x *DeviceSessionPB) GetDevAddr() []byte

func (*DeviceSessionPB) GetDevEui

func (x *DeviceSessionPB) GetDevEui() []byte

func (*DeviceSessionPB) GetDeviceProfileId

func (x *DeviceSessionPB) GetDeviceProfileId() string

func (*DeviceSessionPB) GetDownlinkDwellTime_400Ms

func (x *DeviceSessionPB) GetDownlinkDwellTime_400Ms() bool

func (*DeviceSessionPB) GetDr

func (x *DeviceSessionPB) GetDr() uint32

func (*DeviceSessionPB) GetEnabledUplinkChannels

func (x *DeviceSessionPB) GetEnabledUplinkChannels() []uint32

func (*DeviceSessionPB) GetExtraUplinkChannels

func (x *DeviceSessionPB) GetExtraUplinkChannels() map[uint32]*DeviceSessionPBChannel

func (*DeviceSessionPB) GetFCntUp

func (x *DeviceSessionPB) GetFCntUp() uint32

func (*DeviceSessionPB) GetFNwkSIntKey

func (x *DeviceSessionPB) GetFNwkSIntKey() []byte

func (*DeviceSessionPB) GetIsDisabled

func (x *DeviceSessionPB) GetIsDisabled() bool

func (*DeviceSessionPB) GetJoinEui

func (x *DeviceSessionPB) GetJoinEui() []byte

func (*DeviceSessionPB) GetLastDeviceStatusRequestTimeUnixNs

func (x *DeviceSessionPB) GetLastDeviceStatusRequestTimeUnixNs() int64

func (*DeviceSessionPB) GetMacCommandErrorCount

func (x *DeviceSessionPB) GetMacCommandErrorCount() map[uint32]uint32

func (*DeviceSessionPB) GetMacVersion

func (x *DeviceSessionPB) GetMacVersion() string

func (*DeviceSessionPB) GetMaxSupportedTxPowerIndex

func (x *DeviceSessionPB) GetMaxSupportedTxPowerIndex() uint32

func (*DeviceSessionPB) GetMinSupportedTxPowerIndex

func (x *DeviceSessionPB) GetMinSupportedTxPowerIndex() uint32

func (*DeviceSessionPB) GetNFCntDown

func (x *DeviceSessionPB) GetNFCntDown() uint32

func (*DeviceSessionPB) GetNbTrans

func (x *DeviceSessionPB) GetNbTrans() uint32

func (*DeviceSessionPB) GetNwkSEncKey

func (x *DeviceSessionPB) GetNwkSEncKey() []byte

func (*DeviceSessionPB) GetPendingRejoinDeviceSession

func (x *DeviceSessionPB) GetPendingRejoinDeviceSession() []byte

func (*DeviceSessionPB) GetPingSlotDr

func (x *DeviceSessionPB) GetPingSlotDr() uint32

func (*DeviceSessionPB) GetPingSlotFrequency

func (x *DeviceSessionPB) GetPingSlotFrequency() uint32

func (*DeviceSessionPB) GetPingSlotNb

func (x *DeviceSessionPB) GetPingSlotNb() uint32

func (*DeviceSessionPB) GetReferenceAltitude

func (x *DeviceSessionPB) GetReferenceAltitude() float64

func (*DeviceSessionPB) GetRejoinCount_0

func (x *DeviceSessionPB) GetRejoinCount_0() uint32

func (*DeviceSessionPB) GetRejoinRequestEnabled

func (x *DeviceSessionPB) GetRejoinRequestEnabled() bool

func (*DeviceSessionPB) GetRejoinRequestMaxCountN

func (x *DeviceSessionPB) GetRejoinRequestMaxCountN() uint32

func (*DeviceSessionPB) GetRejoinRequestMaxTimeN

func (x *DeviceSessionPB) GetRejoinRequestMaxTimeN() uint32

func (*DeviceSessionPB) GetRoutingProfileId

func (x *DeviceSessionPB) GetRoutingProfileId() string

func (*DeviceSessionPB) GetRx1DrOffset

func (x *DeviceSessionPB) GetRx1DrOffset() uint32

func (*DeviceSessionPB) GetRx2Dr

func (x *DeviceSessionPB) GetRx2Dr() uint32

func (*DeviceSessionPB) GetRx2Frequency

func (x *DeviceSessionPB) GetRx2Frequency() uint32

func (*DeviceSessionPB) GetRxDelay

func (x *DeviceSessionPB) GetRxDelay() uint32

func (*DeviceSessionPB) GetSNwkSIntKey

func (x *DeviceSessionPB) GetSNwkSIntKey() []byte

func (*DeviceSessionPB) GetServiceProfileId

func (x *DeviceSessionPB) GetServiceProfileId() string

func (*DeviceSessionPB) GetSkipFCntCheck

func (x *DeviceSessionPB) GetSkipFCntCheck() bool

func (*DeviceSessionPB) GetTxPowerIndex

func (x *DeviceSessionPB) GetTxPowerIndex() uint32

func (*DeviceSessionPB) GetUplinkAdrHistory

func (x *DeviceSessionPB) GetUplinkAdrHistory() []*DeviceSessionPBUplinkADRHistory

func (*DeviceSessionPB) GetUplinkDwellTime_400Ms

func (x *DeviceSessionPB) GetUplinkDwellTime_400Ms() bool

func (*DeviceSessionPB) GetUplinkMaxEirpIndex

func (x *DeviceSessionPB) GetUplinkMaxEirpIndex() uint32

func (*DeviceSessionPB) ProtoMessage

func (*DeviceSessionPB) ProtoMessage()

func (*DeviceSessionPB) ProtoReflect

func (x *DeviceSessionPB) ProtoReflect() protoreflect.Message

func (*DeviceSessionPB) Reset

func (x *DeviceSessionPB) Reset()

func (*DeviceSessionPB) String

func (x *DeviceSessionPB) String() string

type DeviceSessionPBChannel

type DeviceSessionPBChannel struct {

	// Frequency (Hz).
	Frequency uint32 `protobuf:"varint,1,opt,name=frequency,proto3" json:"frequency,omitempty"`
	// Min. data-rate.
	MinDr uint32 `protobuf:"varint,2,opt,name=min_dr,json=minDr,proto3" json:"min_dr,omitempty"`
	// Max. data-rate.
	MaxDr uint32 `protobuf:"varint,3,opt,name=max_dr,json=maxDr,proto3" json:"max_dr,omitempty"`
	// contains filtered or unexported fields
}

func (*DeviceSessionPBChannel) Descriptor deprecated

func (*DeviceSessionPBChannel) Descriptor() ([]byte, []int)

Deprecated: Use DeviceSessionPBChannel.ProtoReflect.Descriptor instead.

func (*DeviceSessionPBChannel) GetFrequency

func (x *DeviceSessionPBChannel) GetFrequency() uint32

func (*DeviceSessionPBChannel) GetMaxDr

func (x *DeviceSessionPBChannel) GetMaxDr() uint32

func (*DeviceSessionPBChannel) GetMinDr

func (x *DeviceSessionPBChannel) GetMinDr() uint32

func (*DeviceSessionPBChannel) ProtoMessage

func (*DeviceSessionPBChannel) ProtoMessage()

func (*DeviceSessionPBChannel) ProtoReflect

func (x *DeviceSessionPBChannel) ProtoReflect() protoreflect.Message

func (*DeviceSessionPBChannel) Reset

func (x *DeviceSessionPBChannel) Reset()

func (*DeviceSessionPBChannel) String

func (x *DeviceSessionPBChannel) String() string

type DeviceSessionPBUplinkADRHistory

type DeviceSessionPBUplinkADRHistory struct {

	// Uplink frame-counter.
	FCnt uint32 `protobuf:"varint,1,opt,name=f_cnt,json=fCnt,proto3" json:"f_cnt,omitempty"`
	// Max SNR (of deduplicated frames received by one or multiple gateways).
	MaxSnr float32 `protobuf:"fixed32,2,opt,name=max_snr,json=maxSnr,proto3" json:"max_snr,omitempty"`
	// TX Power (as known by the network-server).
	TxPowerIndex uint32 `protobuf:"varint,3,opt,name=tx_power_index,json=txPowerIndex,proto3" json:"tx_power_index,omitempty"`
	// Number of receiving gateways.
	GatewayCount uint32 `protobuf:"varint,4,opt,name=gateway_count,json=gatewayCount,proto3" json:"gateway_count,omitempty"`
	// Max RSSI (of deduplicated frames received by one or multiple gateways).
	MaxRssi int32 `protobuf:"varint,5,opt,name=max_rssi,json=maxRssi,proto3" json:"max_rssi,omitempty"`
	// contains filtered or unexported fields
}

func (*DeviceSessionPBUplinkADRHistory) Descriptor deprecated

func (*DeviceSessionPBUplinkADRHistory) Descriptor() ([]byte, []int)

Deprecated: Use DeviceSessionPBUplinkADRHistory.ProtoReflect.Descriptor instead.

func (*DeviceSessionPBUplinkADRHistory) GetFCnt

func (*DeviceSessionPBUplinkADRHistory) GetGatewayCount

func (x *DeviceSessionPBUplinkADRHistory) GetGatewayCount() uint32

func (*DeviceSessionPBUplinkADRHistory) GetMaxRssi added in v3.16.0

func (x *DeviceSessionPBUplinkADRHistory) GetMaxRssi() int32

func (*DeviceSessionPBUplinkADRHistory) GetMaxSnr

func (*DeviceSessionPBUplinkADRHistory) GetTxPowerIndex

func (x *DeviceSessionPBUplinkADRHistory) GetTxPowerIndex() uint32

func (*DeviceSessionPBUplinkADRHistory) ProtoMessage

func (*DeviceSessionPBUplinkADRHistory) ProtoMessage()

func (*DeviceSessionPBUplinkADRHistory) ProtoReflect

func (*DeviceSessionPBUplinkADRHistory) Reset

func (*DeviceSessionPBUplinkADRHistory) String

type DownlinkFrame

type DownlinkFrame struct {

	// Token.
	Token uint32 `protobuf:"varint,1,opt,name=token,proto3" json:"token,omitempty"`
	// DevEUI.
	DevEui []byte `protobuf:"bytes,2,opt,name=dev_eui,json=devEui,proto3" json:"dev_eui,omitempty"`
	// Device queue item ID.
	DeviceQueueItemId int64 `protobuf:"varint,3,opt,name=device_queue_item_id,json=deviceQueueItemId,proto3" json:"device_queue_item_id,omitempty"`
	// Multicast Group ID.
	MulticastGroupId []byte `protobuf:"bytes,4,opt,name=multicast_group_id,json=multicastGroupId,proto3" json:"multicast_group_id,omitempty"`
	// Multicast queue item ID.
	MulticastQueueItemId int64 `` /* 126-byte string literal not displayed */
	// Downlink frames.
	DownlinkFrame *gw.DownlinkFrame `protobuf:"bytes,6,opt,name=downlink_frame,json=downlinkFrame,proto3" json:"downlink_frame,omitempty"`
	// Routing Profile ID.
	RoutingProfileId []byte `protobuf:"bytes,7,opt,name=routing_profile_id,json=routingProfileId,proto3" json:"routing_profile_id,omitempty"`
	// Encrypted FOpts (LoRaWAN 1.1).
	EncryptedFopts bool `protobuf:"varint,8,opt,name=encrypted_fopts,json=encryptedFopts,proto3" json:"encrypted_fopts,omitempty"`
	// Network session encryption key (for FOpts).
	NwkSEncKey []byte `protobuf:"bytes,9,opt,name=nwk_s_enc_key,json=nwkSEncKey,proto3" json:"nwk_s_enc_key,omitempty"`
	// contains filtered or unexported fields
}

func GetDownlinkFrame

func GetDownlinkFrame(ctx context.Context, token uint16) (*DownlinkFrame, error)

GetDownlinkFrame returns the downlink-frame matching the given token.

func (*DownlinkFrame) Descriptor deprecated

func (*DownlinkFrame) Descriptor() ([]byte, []int)

Deprecated: Use DownlinkFrame.ProtoReflect.Descriptor instead.

func (*DownlinkFrame) GetDevEui

func (x *DownlinkFrame) GetDevEui() []byte

func (*DownlinkFrame) GetDeviceQueueItemId

func (x *DownlinkFrame) GetDeviceQueueItemId() int64

func (*DownlinkFrame) GetDownlinkFrame

func (x *DownlinkFrame) GetDownlinkFrame() *gw.DownlinkFrame

func (*DownlinkFrame) GetEncryptedFopts

func (x *DownlinkFrame) GetEncryptedFopts() bool

func (*DownlinkFrame) GetMulticastGroupId

func (x *DownlinkFrame) GetMulticastGroupId() []byte

func (*DownlinkFrame) GetMulticastQueueItemId

func (x *DownlinkFrame) GetMulticastQueueItemId() int64

func (*DownlinkFrame) GetNwkSEncKey

func (x *DownlinkFrame) GetNwkSEncKey() []byte

func (*DownlinkFrame) GetRoutingProfileId

func (x *DownlinkFrame) GetRoutingProfileId() []byte

func (*DownlinkFrame) GetToken

func (x *DownlinkFrame) GetToken() uint32

func (*DownlinkFrame) ProtoMessage

func (*DownlinkFrame) ProtoMessage()

func (*DownlinkFrame) ProtoReflect

func (x *DownlinkFrame) ProtoReflect() protoreflect.Message

func (*DownlinkFrame) Reset

func (x *DownlinkFrame) Reset()

func (*DownlinkFrame) String

func (x *DownlinkFrame) String() string

type ExtraChannel

type ExtraChannel struct {
	Modulation       string  `db:"modulation"`
	Frequency        int     `db:"frequency"`
	Bandwidth        int     `db:"bandwidth"`
	Bitrate          int     `db:"bitrate"`
	SpreadingFactors []int64 `db:"spreading_factors"`
}

ExtraChannel defines an extra channel for the gateway-profile.

type GPSPoint

type GPSPoint struct {
	Latitude  float64
	Longitude float64
}

GPSPoint contains a GPS point.

func (*GPSPoint) Scan

func (l *GPSPoint) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (GPSPoint) Value

func (l GPSPoint) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Gateway

type Gateway struct {
	GatewayID        lorawan.EUI64  `db:"gateway_id"`
	RoutingProfileID uuid.UUID      `db:"routing_profile_id"`
	ServiceProfileID *uuid.UUID     `db:"service_profile_id"`
	GatewayProfileID *uuid.UUID     `db:"gateway_profile_id"`
	CreatedAt        time.Time      `db:"created_at"`
	UpdatedAt        time.Time      `db:"updated_at"`
	FirstSeenAt      *time.Time     `db:"first_seen_at"`
	LastSeenAt       *time.Time     `db:"last_seen_at"`
	Location         GPSPoint       `db:"location"`
	Altitude         float64        `db:"altitude"`
	TLSCert          []byte         `db:"tls_cert"`
	Boards           []GatewayBoard `db:"-"`
}

Gateway represents a gateway.

func GetGateway

func GetGateway(ctx context.Context, db sqlx.Queryer, id lorawan.EUI64) (Gateway, error)

GetGateway returns the gateway for the given Gateway ID.

type GatewayBoard

type GatewayBoard struct {
	FPGAID           *lorawan.EUI64     `db:"fpga_id"`
	FineTimestampKey *lorawan.AES128Key `db:"fine_timestamp_key"`
}

GatewayBoard holds the gateway board configuration.

type GatewayMeta

type GatewayMeta struct {
	GatewayID        lorawan.EUI64  `db:"gateway_id"`
	RoutingProfileID uuid.UUID      `db:"routing_profile_id"`
	GatewayProfileID *uuid.UUID     `db:"gateway_profile_id"`
	ServiceProfileID *uuid.UUID     `db:"service_profile_id"`
	Location         GPSPoint       `db:"location"`
	Altitude         float64        `db:"altitude"`
	IsPrivate        bool           `db:"is_private"`
	Boards           []GatewayBoard `db:"-"`
}

GatewayMeta represents the gateway meta-data. This is used for adding additional context to received uplinks.

func GetAndCacheGatewayMeta

func GetAndCacheGatewayMeta(ctx context.Context, db sqlx.Queryer, gatewayID lorawan.EUI64) (GatewayMeta, error)

GetAndCacheGatewayMeta returns a gateway meta from the cache in case it is available. In case the gateway meta is not cached, it will be retrieved from the database and then cached.

func GetGatewayMeta

func GetGatewayMeta(ctx context.Context, db sqlx.Queryer, id lorawan.EUI64) (GatewayMeta, error)

GetGatewayMeta returns the GatewayMeta object for the given gateway ID.

func GetGatewayMetaCache

func GetGatewayMetaCache(ctx context.Context, gatewayID lorawan.EUI64) (GatewayMeta, error)

GetGatewayMetaCache returns a cached gateway meta.

type GatewayProfile

type GatewayProfile struct {
	ID            uuid.UUID      `db:"gateway_profile_id"`
	CreatedAt     time.Time      `db:"created_at"`
	UpdatedAt     time.Time      `db:"updated_at"`
	Channels      []int64        `db:"channels"`
	StatsInterval time.Duration  `db:"stats_interval"`
	ExtraChannels []ExtraChannel `db:"-"`
}

GatewayProfile defines a gateway-profile.

func GetGatewayProfile

func GetGatewayProfile(ctx context.Context, db sqlx.Queryer, id uuid.UUID) (GatewayProfile, error)

GetGatewayProfile returns the gateway-profile matching the given ID.

func (GatewayProfile) GetVersion

func (p GatewayProfile) GetVersion() string

GetVersion returns the gateway-profile version.

type KeyEnvelope

type KeyEnvelope struct {
	KEKLabel string
	AESKey   []byte
}

KeyEnvelope defined a key-envelope.

type MACCommandBlock

type MACCommandBlock struct {
	CID         lorawan.CID
	External    bool // command was enqueued by an external service
	MACCommands MACCommands
}

MACCommandBlock defines a block of MAC commands that must be handled together.

func GetMACCommandQueueItems

func GetMACCommandQueueItems(ctx context.Context, devEUI lorawan.EUI64) ([]MACCommandBlock, error)

GetMACCommandQueueItems returns the mac-command queue items for the given DevEUI.

func GetPendingMACCommand

func GetPendingMACCommand(ctx context.Context, devEUI lorawan.EUI64, cid lorawan.CID) (*MACCommandBlock, error)

GetPendingMACCommand returns the pending mac-command for the given CID. In case no items are pending, nil is returned.

func (*MACCommandBlock) Size

func (m *MACCommandBlock) Size() (int, error)

Size returns the size (in bytes) of the mac-commands within this block.

type MACCommands

type MACCommands []lorawan.MACCommand

MACCommands holds a slice of MACCommand items.

func (MACCommands) MarshalBinary

func (m MACCommands) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*MACCommands) UnmarshalBinary

func (m *MACCommands) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

type MetricsRecord

type MetricsRecord struct {
	Time    time.Time
	Metrics map[string]float64
}

MetricsRecord holds a single metrics record.

func GetMetrics

func GetMetrics(ctx context.Context, agg AggregationInterval, name string, start, end time.Time) ([]MetricsRecord, error)

GetMetrics returns the metrics for the requested aggregation interval.

type MulticastGroup

type MulticastGroup struct {
	ID               uuid.UUID          `db:"id"`
	CreatedAt        time.Time          `db:"created_at"`
	UpdatedAt        time.Time          `db:"updated_at"`
	MCAddr           lorawan.DevAddr    `db:"mc_addr"`
	MCNwkSKey        lorawan.AES128Key  `db:"mc_nwk_s_key"`
	FCnt             uint32             `db:"f_cnt"`
	GroupType        MulticastGroupType `db:"group_type"`
	DR               int                `db:"dr"`
	Frequency        uint32             `db:"frequency"`
	PingSlotPeriod   int                `db:"ping_slot_period"`
	RoutingProfileID uuid.UUID          `db:"routing_profile_id"` // there is no downlink data, but it can be used for future error reporting
	ServiceProfileID uuid.UUID          `db:"service_profile_id"`
}

MulticastGroup defines a multicast-group.

func GetMulticastGroup

func GetMulticastGroup(ctx context.Context, db sqlx.Queryer, id uuid.UUID, forUpdate bool) (MulticastGroup, error)

GetMulticastGroup returns the multicast-group for the given ID.

type MulticastGroupType

type MulticastGroupType string

MulticastGroupType type defines the multicast-group type.

const (
	MulticastGroupB MulticastGroupType = "B"
	MulticastGroupC MulticastGroupType = "C"
)

Possible multicast-group types.

type MulticastQueueItem

type MulticastQueueItem struct {
	ID                      int64          `db:"id"`
	CreatedAt               time.Time      `db:"created_at"`
	UpdatedAt               time.Time      `db:"updated_at"`
	ScheduleAt              time.Time      `db:"schedule_at"`
	EmitAtTimeSinceGPSEpoch *time.Duration `db:"emit_at_time_since_gps_epoch"`
	MulticastGroupID        uuid.UUID      `db:"multicast_group_id"`
	GatewayID               lorawan.EUI64  `db:"gateway_id"`
	FCnt                    uint32         `db:"f_cnt"`
	FPort                   uint8          `db:"f_port"`
	FRMPayload              []byte         `db:"frm_payload"`
	RetryAfter              *time.Time     `db:"retry_after"`
}

MulticastQueueItem defines a multicast queue-item.

func GetMulticastQueueItem

func GetMulticastQueueItem(ctx context.Context, db sqlx.Queryer, id int64) (MulticastQueueItem, error)

GetMulticastQueueItem returns the multicast queue-item for the given ID.

func GetMulticastQueueItemsForMulticastGroup

func GetMulticastQueueItemsForMulticastGroup(ctx context.Context, db sqlx.Queryer, multicastGroupID uuid.UUID) ([]MulticastQueueItem, error)

GetMulticastQueueItemsForMulticastGroup returns all queue-items given a multicast-group id.

func GetSchedulableMulticastQueueItems

func GetSchedulableMulticastQueueItems(ctx context.Context, db sqlx.Ext, count int) ([]MulticastQueueItem, error)

GetSchedulableMulticastQueueItems returns a slice of multicast-queue items for scheduling. The returned queue-items will be locked for update so that this query can be executed in parallel.

func (MulticastQueueItem) Validate

func (m MulticastQueueItem) Validate() error

Validate validates the MulticastQueueItem.

type PassiveRoamingDeviceSession

type PassiveRoamingDeviceSession struct {
	SessionID   uuid.UUID
	NetID       lorawan.NetID
	DevAddr     lorawan.DevAddr
	DevEUI      lorawan.EUI64
	LoRaWAN11   bool
	FNwkSIntKey lorawan.AES128Key
	Lifetime    time.Time
	FCntUp      uint32
	ValidateMIC bool
}

PassiveRoamingDeviceSession defines the passive-roaming session.

func GetPassiveRoamingDeviceSession

func GetPassiveRoamingDeviceSession(ctx context.Context, id uuid.UUID) (PassiveRoamingDeviceSession, error)

GetPassiveRoamingDeviceSession returns the passive-roaming device-session.

func GetPassiveRoamingDeviceSessionsForDevAddr

func GetPassiveRoamingDeviceSessionsForDevAddr(ctx context.Context, devAddr lorawan.DevAddr) ([]PassiveRoamingDeviceSession, error)

GetPassiveRoamingDeviceSessionsForDevAddr returns a slice of passive-roaming device-session matching the given DevAddr. When no sessions match, an empty slice is returned.

func GetPassiveRoamingDeviceSessionsForPHYPayload

func GetPassiveRoamingDeviceSessionsForPHYPayload(ctx context.Context, phy lorawan.PHYPayload) ([]PassiveRoamingDeviceSession, error)

GetPassiveRoamingDeviceSessionsForPHYPayload returns the passive-roaming device-sessions matching the given PHYPayload.

type PassiveRoamingDeviceSessionPB

type PassiveRoamingDeviceSessionPB struct {

	// Session ID (UUID).
	// Unfortunately we can not use the DevEUI as unique identifier
	// as the PRStartAns DevEUI field is optional.
	SessionId []byte `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
	// NetID of the hNS.
	NetId []byte `protobuf:"bytes,2,opt,name=net_id,json=netId,proto3" json:"net_id,omitempty"`
	// DevAddr of the device.
	DevAddr []byte `protobuf:"bytes,3,opt,name=dev_addr,json=devAddr,proto3" json:"dev_addr,omitempty"`
	// DevEUI of the device (optional).
	DevEui []byte `protobuf:"bytes,4,opt,name=dev_eui,json=devEui,proto3" json:"dev_eui,omitempty"`
	// LoRaWAN 1.1 frame.
	Lorawan_1_1 bool `protobuf:"varint,5,opt,name=lorawan_1_1,json=lorawan11,proto3" json:"lorawan_1_1,omitempty"`
	// LoRaWAN 1.0 NwkSKey / LoRaWAN 1.1 FNwkSIntKey.
	FNwkSIntKey []byte `protobuf:"bytes,6,opt,name=f_nwk_s_int_key,json=fNwkSIntKey,proto3" json:"f_nwk_s_int_key,omitempty"`
	// Lifetime.
	Lifetime *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=lifetime,proto3" json:"lifetime,omitempty"`
	// Uplink frame-counter.
	FCntUp uint32 `protobuf:"varint,8,opt,name=f_cnt_up,json=fCntUp,proto3" json:"f_cnt_up,omitempty"`
	// Validate MIC.
	ValidateMic bool `protobuf:"varint,9,opt,name=validate_mic,json=validateMic,proto3" json:"validate_mic,omitempty"`
	// contains filtered or unexported fields
}

func (*PassiveRoamingDeviceSessionPB) Descriptor deprecated

func (*PassiveRoamingDeviceSessionPB) Descriptor() ([]byte, []int)

Deprecated: Use PassiveRoamingDeviceSessionPB.ProtoReflect.Descriptor instead.

func (*PassiveRoamingDeviceSessionPB) GetDevAddr

func (x *PassiveRoamingDeviceSessionPB) GetDevAddr() []byte

func (*PassiveRoamingDeviceSessionPB) GetDevEui

func (x *PassiveRoamingDeviceSessionPB) GetDevEui() []byte

func (*PassiveRoamingDeviceSessionPB) GetFCntUp

func (x *PassiveRoamingDeviceSessionPB) GetFCntUp() uint32

func (*PassiveRoamingDeviceSessionPB) GetFNwkSIntKey

func (x *PassiveRoamingDeviceSessionPB) GetFNwkSIntKey() []byte

func (*PassiveRoamingDeviceSessionPB) GetLifetime

func (*PassiveRoamingDeviceSessionPB) GetLorawan_1_1

func (x *PassiveRoamingDeviceSessionPB) GetLorawan_1_1() bool

func (*PassiveRoamingDeviceSessionPB) GetNetId

func (x *PassiveRoamingDeviceSessionPB) GetNetId() []byte

func (*PassiveRoamingDeviceSessionPB) GetSessionId

func (x *PassiveRoamingDeviceSessionPB) GetSessionId() []byte

func (*PassiveRoamingDeviceSessionPB) GetValidateMic

func (x *PassiveRoamingDeviceSessionPB) GetValidateMic() bool

func (*PassiveRoamingDeviceSessionPB) ProtoMessage

func (*PassiveRoamingDeviceSessionPB) ProtoMessage()

func (*PassiveRoamingDeviceSessionPB) ProtoReflect

func (*PassiveRoamingDeviceSessionPB) Reset

func (x *PassiveRoamingDeviceSessionPB) Reset()

func (*PassiveRoamingDeviceSessionPB) String

type RXWindow

type RXWindow int8

RXWindow defines the RX window option.

type RatePolicy

type RatePolicy string

RatePolicy defines the RatePolicy type.

const (
	Drop RatePolicy = "Drop"
	Mark RatePolicy = "Mark"
)

Available rate policies.

type RoutingProfile

type RoutingProfile struct {
	ID        uuid.UUID `json:"RoutingProfileID" db:"routing_profile_id"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
	ASID      string    `json:"AS-ID" db:"as_id"` // Value can be IP address, DNS name, etc.
	CACert    string    `db:"ca_cert"`
	TLSCert   string    `db:"tls_cert"`
	TLSKey    string    `db:"tls_key"`
}

RoutingProfile defines the backend.RoutingProfile with some extra meta-data.

func GetAllRoutingProfiles

func GetAllRoutingProfiles(ctx context.Context, db sqlx.Queryer) ([]RoutingProfile, error)

GetAllRoutingProfiles returns all the available routing-profiles.

func GetRoutingProfile

func GetRoutingProfile(ctx context.Context, db sqlx.Queryer, id uuid.UUID) (RoutingProfile, error)

GetRoutingProfile returns the routing-profile matching the given id.

func (RoutingProfile) GetApplicationServerClient

func (rp RoutingProfile) GetApplicationServerClient() (as.ApplicationServerServiceClient, error)

GetApplicationServerClient returns the application-server client.

type ServiceProfile

type ServiceProfile struct {
	CreatedAt              time.Time  `db:"created_at"`
	UpdatedAt              time.Time  `db:"updated_at"`
	ID                     uuid.UUID  `db:"service_profile_id"`
	ULRate                 int        `db:"ul_rate"`
	ULBucketSize           int        `db:"ul_bucket_size"`
	ULRatePolicy           RatePolicy `db:"ul_rate_policy"`
	DLRate                 int        `db:"dl_rate"`
	DLBucketSize           int        `db:"dl_bucket_size"`
	DLRatePolicy           RatePolicy `db:"dl_rate_policy"`
	AddGWMetadata          bool       `db:"add_gw_metadata"`
	DevStatusReqFreq       int        `db:"dev_status_req_freq"` // Unit: requests-per-day
	ReportDevStatusBattery bool       `db:"report_dev_status_battery"`
	ReportDevStatusMargin  bool       `db:"report_dev_status_margin"`
	DRMin                  int        `db:"dr_min"`
	DRMax                  int        `db:"dr_max"`
	ChannelMask            []byte     `db:"channel_mask"`
	PRAllowed              bool       `db:"pr_allowed"`
	HRAllowed              bool       `db:"hr_allowed"`
	RAAllowed              bool       `db:"ra_allowed"`
	NwkGeoLoc              bool       `db:"nwk_geo_loc"`
	TargetPER              int        `db:"target_per"` // Example: 10 indicates 10%
	MinGWDiversity         int        `db:"min_gw_diversity"`
	GwsPrivate             bool       `db:"gws_private"`
}

ServiceProfile defines the backend.ServiceProfile with some extra meta-data.

func GetAndCacheServiceProfile

func GetAndCacheServiceProfile(ctx context.Context, db sqlx.Queryer, id uuid.UUID) (ServiceProfile, error)

GetAndCacheServiceProfile returns the service-profile from cache in case available, else it will be retrieved from the database and then stored in cache.

func GetServiceProfile

func GetServiceProfile(ctx context.Context, db sqlx.Queryer, id uuid.UUID) (ServiceProfile, error)

GetServiceProfile returns the service-profile matching the given id.

func GetServiceProfileCache

func GetServiceProfileCache(ctx context.Context, id uuid.UUID) (ServiceProfile, error)

GetServiceProfileCache returns a cached service-profile.

type TxLogger

type TxLogger struct {
	*sqlx.Tx
}

TxLogger logs the executed sql queries and their duration.

func (*TxLogger) Exec

func (q *TxLogger) Exec(query string, args ...interface{}) (sql.Result, error)

Exec logs the queries executed by the Exec method.

func (*TxLogger) Query

func (q *TxLogger) Query(query string, args ...interface{}) (*sql.Rows, error)

Query logs the queries executed by the Query method.

func (*TxLogger) QueryRowx

func (q *TxLogger) QueryRowx(query string, args ...interface{}) *sqlx.Row

QueryRowx logs the queries executed by the QueryRowx method.

func (*TxLogger) Queryx

func (q *TxLogger) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)

Queryx logs the queries executed by the Queryx method.

type UplinkHistory

type UplinkHistory struct {
	FCnt         uint32
	MaxSNR       float64
	MaxRSSI      int32
	TXPowerIndex int
	GatewayCount int
}

UplinkHistory contains the meta-data of an uplink transmission.

Directories

Path Synopsis
migrations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL