Documentation ¶
Index ¶
- Constants
- Variables
- func CreateDevice(db sqlx.Execer, d *Device) error
- func CreateDeviceActivation(db sqlx.Queryer, da *DeviceActivation) error
- func CreateDeviceProfile(db sqlx.Execer, dp *DeviceProfile) error
- func CreateDeviceProfileCache(p *redis.Pool, dp DeviceProfile) error
- func CreateDeviceQueueItem(db sqlx.Queryer, qi *DeviceQueueItem) error
- func CreateGateway(db sqlx.Execer, gw *Gateway) error
- func CreateGatewayProfile(db sqlx.Execer, c *GatewayProfile) error
- func CreateMACCommandQueueItem(p *redis.Pool, devEUI lorawan.EUI64, block MACCommandBlock) error
- func CreateRoutingProfile(db sqlx.Execer, rp *RoutingProfile) error
- func CreateServiceProfile(db sqlx.Execer, sp *ServiceProfile) error
- func CreateServiceProfileCache(p *redis.Pool, sp ServiceProfile) error
- func DeleteDevice(db sqlx.Execer, devEUI lorawan.EUI64) error
- func DeleteDeviceProfile(db sqlx.Execer, id uuid.UUID) error
- func DeleteDeviceQueueItem(db sqlx.Execer, id int64) error
- func DeleteDeviceSession(p *redis.Pool, devEUI lorawan.EUI64) error
- func DeleteGateway(db sqlx.Execer, mac lorawan.EUI64) error
- func DeleteGatewayProfile(db sqlx.Execer, id uuid.UUID) error
- func DeleteMACCommandQueueItem(p *redis.Pool, devEUI lorawan.EUI64, block MACCommandBlock) error
- func DeletePendingMACCommand(p *redis.Pool, devEUI lorawan.EUI64, cid lorawan.CID) error
- func DeleteRoutingProfile(db sqlx.Execer, id uuid.UUID) error
- func DeleteServiceProfile(db sqlx.Execer, id uuid.UUID) error
- func DeviceSessionExists(p *redis.Pool, devEUI lorawan.EUI64) (bool, error)
- func FlushDeviceProfileCache(p *redis.Pool, id uuid.UUID) error
- func FlushDeviceQueueForDevEUI(db sqlx.Execer, devEUI lorawan.EUI64) error
- func FlushMACCommandQueue(p *redis.Pool, devEUI lorawan.EUI64) error
- func FlushServiceProfileCache(p *redis.Pool, id uuid.UUID) error
- func GetGatewaysForMACs(db sqlx.Queryer, macs []lorawan.EUI64) (map[lorawan.EUI64]Gateway, error)
- func GetMaxEmitAtTimeSinceGPSEpochForDevEUI(db sqlx.Queryer, devEUI lorawan.EUI64) (time.Duration, error)
- func GetRandomDevAddr(p *redis.Pool, netID lorawan.NetID) (lorawan.DevAddr, error)
- func HandleGatewayStatsPacket(db *common.DBLogger, stats gw.GatewayStatsPacket) error
- func MustSetStatsAggregationIntervals(levels []string)
- func SaveDeviceSession(p *redis.Pool, s DeviceSession) error
- func SetPendingMACCommand(p *redis.Pool, devEUI lorawan.EUI64, block MACCommandBlock) error
- func Transaction(db *common.DBLogger, f func(tx sqlx.Ext) error) error
- func UpdateDevice(db sqlx.Execer, d *Device) error
- func UpdateDeviceProfile(db sqlx.Execer, dp *DeviceProfile) error
- func UpdateDeviceQueueItem(db sqlx.Execer, qi *DeviceQueueItem) error
- func UpdateGateway(db sqlx.Execer, gw *Gateway) error
- func UpdateGatewayProfile(db sqlx.Execer, c *GatewayProfile) error
- func UpdateRoutingProfile(db sqlx.Execer, rp *RoutingProfile) error
- func UpdateServiceProfile(db sqlx.Execer, sp *ServiceProfile) error
- func ValidateAndGetFullFCntUp(s DeviceSession, fCntUp uint32) (uint32, bool)
- func ValidateDevNonce(db sqlx.Queryer, joinEUI, devEUI lorawan.EUI64, nonce lorawan.DevNonce, ...) error
- type Device
- type DeviceActivation
- type DeviceProfile
- type DeviceQueueItem
- func GetDeviceQueueItem(db sqlx.Queryer, id int64) (DeviceQueueItem, error)
- func GetDeviceQueueItemsForDevEUI(db sqlx.Queryer, devEUI lorawan.EUI64) ([]DeviceQueueItem, error)
- func GetNextDeviceQueueItemForDevEUI(db sqlx.Queryer, devEUI lorawan.EUI64) (DeviceQueueItem, error)
- func GetNextDeviceQueueItemForDevEUIMaxPayloadSizeAndFCnt(db sqlx.Ext, devEUI lorawan.EUI64, maxPayloadSize int, fCnt uint32, ...) (DeviceQueueItem, error)
- func GetPendingDeviceQueueItemForDevEUI(db sqlx.Queryer, devEUI lorawan.EUI64) (DeviceQueueItem, error)
- type DeviceSession
- func (s *DeviceSession) AppendUplinkHistory(up UplinkHistory)
- func (s DeviceSession) GetDownlinkGatewayMAC() (lorawan.EUI64, error)
- func (s DeviceSession) GetMACVersion() lorawan.MACVersion
- func (s DeviceSession) GetPacketLossPercentage() float64
- func (s *DeviceSession) ResetToBootParameters(dp DeviceProfile)
- type DeviceSessionOld
- type DeviceSessionPB
- func (*DeviceSessionPB) Descriptor() ([]byte, []int)
- func (m *DeviceSessionPB) GetAFCntDown() uint32
- func (m *DeviceSessionPB) GetAdr() bool
- func (m *DeviceSessionPB) GetAppSKeyEnvelope() *common.KeyEnvelope
- func (m *DeviceSessionPB) GetBeaconLocked() bool
- func (m *DeviceSessionPB) GetChannelFrequencies() []uint32
- func (m *DeviceSessionPB) GetConfFCnt() uint32
- func (m *DeviceSessionPB) GetDevAddr() []byte
- func (m *DeviceSessionPB) GetDevEui() []byte
- func (m *DeviceSessionPB) GetDeviceProfileId() string
- func (m *DeviceSessionPB) GetDr() uint32
- func (m *DeviceSessionPB) GetEnabledUplinkChannels() []uint32
- func (m *DeviceSessionPB) GetExtraUplinkChannels() map[uint32]*DeviceSessionPBChannel
- func (m *DeviceSessionPB) GetFCntUp() uint32
- func (m *DeviceSessionPB) GetFNwkSIntKey() []byte
- func (m *DeviceSessionPB) GetJoinEui() []byte
- func (m *DeviceSessionPB) GetLastDeviceStatusRequestTimeUnixNs() int64
- func (m *DeviceSessionPB) GetLastDownlinkTxTimestampUnixNs() int64
- func (m *DeviceSessionPB) GetMacVersion() string
- func (m *DeviceSessionPB) GetMaxSupportedDr() uint32
- func (m *DeviceSessionPB) GetMaxSupportedTxPowerIndex() uint32
- func (m *DeviceSessionPB) GetMinSupportedTxPowerIndex() uint32
- func (m *DeviceSessionPB) GetNFCntDown() uint32
- func (m *DeviceSessionPB) GetNbTrans() uint32
- func (m *DeviceSessionPB) GetNwkSEncKey() []byte
- func (m *DeviceSessionPB) GetPendingRejoinDeviceSession() []byte
- func (m *DeviceSessionPB) GetPingSlotDr() uint32
- func (m *DeviceSessionPB) GetPingSlotFrequency() uint32
- func (m *DeviceSessionPB) GetPingSlotNb() uint32
- func (m *DeviceSessionPB) GetRejoinCount_0() uint32
- func (m *DeviceSessionPB) GetRejoinRequestEnabled() bool
- func (m *DeviceSessionPB) GetRejoinRequestMaxCountN() uint32
- func (m *DeviceSessionPB) GetRejoinRequestMaxTimeN() uint32
- func (m *DeviceSessionPB) GetRoutingProfileId() string
- func (m *DeviceSessionPB) GetRx1DrOffset() uint32
- func (m *DeviceSessionPB) GetRx2Dr() uint32
- func (m *DeviceSessionPB) GetRx2Frequency() uint32
- func (m *DeviceSessionPB) GetRxDelay() uint32
- func (m *DeviceSessionPB) GetSNwkSIntKey() []byte
- func (m *DeviceSessionPB) GetServiceProfileId() string
- func (m *DeviceSessionPB) GetSkipFCntCheck() bool
- func (m *DeviceSessionPB) GetTxPowerIndex() uint32
- func (m *DeviceSessionPB) GetUplinkAdrHistory() []*DeviceSessionPBUplinkADRHistory
- func (m *DeviceSessionPB) GetUplinkGatewayHistory() map[string]*DeviceSessionPBUplinkGatewayHistory
- func (*DeviceSessionPB) ProtoMessage()
- func (m *DeviceSessionPB) Reset()
- func (m *DeviceSessionPB) String() string
- func (m *DeviceSessionPB) XXX_DiscardUnknown()
- func (m *DeviceSessionPB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *DeviceSessionPB) XXX_Merge(src proto.Message)
- func (m *DeviceSessionPB) XXX_Size() int
- func (m *DeviceSessionPB) XXX_Unmarshal(b []byte) error
- type DeviceSessionPBChannel
- func (*DeviceSessionPBChannel) Descriptor() ([]byte, []int)
- func (m *DeviceSessionPBChannel) GetFrequency() uint32
- func (m *DeviceSessionPBChannel) GetMaxDr() uint32
- func (m *DeviceSessionPBChannel) GetMinDr() uint32
- func (*DeviceSessionPBChannel) ProtoMessage()
- func (m *DeviceSessionPBChannel) Reset()
- func (m *DeviceSessionPBChannel) String() string
- func (m *DeviceSessionPBChannel) XXX_DiscardUnknown()
- func (m *DeviceSessionPBChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *DeviceSessionPBChannel) XXX_Merge(src proto.Message)
- func (m *DeviceSessionPBChannel) XXX_Size() int
- func (m *DeviceSessionPBChannel) XXX_Unmarshal(b []byte) error
- type DeviceSessionPBUplinkADRHistory
- func (*DeviceSessionPBUplinkADRHistory) Descriptor() ([]byte, []int)
- func (m *DeviceSessionPBUplinkADRHistory) GetFCnt() uint32
- func (m *DeviceSessionPBUplinkADRHistory) GetGatewayCount() uint32
- func (m *DeviceSessionPBUplinkADRHistory) GetMaxSnr() float32
- func (m *DeviceSessionPBUplinkADRHistory) GetTxPowerIndex() uint32
- func (*DeviceSessionPBUplinkADRHistory) ProtoMessage()
- func (m *DeviceSessionPBUplinkADRHistory) Reset()
- func (m *DeviceSessionPBUplinkADRHistory) String() string
- func (m *DeviceSessionPBUplinkADRHistory) XXX_DiscardUnknown()
- func (m *DeviceSessionPBUplinkADRHistory) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *DeviceSessionPBUplinkADRHistory) XXX_Merge(src proto.Message)
- func (m *DeviceSessionPBUplinkADRHistory) XXX_Size() int
- func (m *DeviceSessionPBUplinkADRHistory) XXX_Unmarshal(b []byte) error
- type DeviceSessionPBUplinkGatewayHistory
- func (*DeviceSessionPBUplinkGatewayHistory) Descriptor() ([]byte, []int)
- func (*DeviceSessionPBUplinkGatewayHistory) ProtoMessage()
- func (m *DeviceSessionPBUplinkGatewayHistory) Reset()
- func (m *DeviceSessionPBUplinkGatewayHistory) String() string
- func (m *DeviceSessionPBUplinkGatewayHistory) XXX_DiscardUnknown()
- func (m *DeviceSessionPBUplinkGatewayHistory) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *DeviceSessionPBUplinkGatewayHistory) XXX_Merge(src proto.Message)
- func (m *DeviceSessionPBUplinkGatewayHistory) XXX_Size() int
- func (m *DeviceSessionPBUplinkGatewayHistory) XXX_Unmarshal(b []byte) error
- type ExtraChannel
- type GPSPoint
- type Gateway
- type GatewayProfile
- type KeyEnvelope
- type MACCommandBlock
- type MACCommands
- type RXWindow
- type RatePolicy
- type RoutingProfile
- type ServiceProfile
- type Stats
- type UplinkGatewayHistory
- type UplinkHistory
Constants ¶
const ( RX1 = iota RX2 )
Available RX window options.
const ( ModulationFSK = "FSK" ModulationLoRa = "LORA" )
Modulations
const (
DeviceProfileKeyTempl = "lora:ns:dp:%s"
)
Templates used for generating Redis keys
const (
ServiceProfileKeyTempl = "lora:ns:sp:%s"
)
Templates used for generating Redis keys
const UplinkHistorySize = 20
UplinkHistorySize contains the number of frames to store
Variables ¶
var ( ErrAlreadyExists = errors.New("object already exists") ErrDoesNotExist = errors.New("object does not exist") ErrDoesNotExistOrFCntOrMICInvalid = errors.New("device-session does not exist or invalid fcnt or mic") ErrInvalidAggregationInterval = errors.New("invalid aggregation interval") ErrInvalidName = errors.New("invalid gateway name") ErrInvalidFPort = errors.New("invalid fPort (must be > 0)") )
errors
Functions ¶
func CreateDevice ¶
CreateDevice creates the given device.
func CreateDeviceActivation ¶
func CreateDeviceActivation(db sqlx.Queryer, da *DeviceActivation) error
CreateDeviceActivation creates the given device-activation.
func CreateDeviceProfile ¶
func CreateDeviceProfile(db sqlx.Execer, dp *DeviceProfile) error
CreateDeviceProfile creates the given device-profile.
func CreateDeviceProfileCache ¶
func CreateDeviceProfileCache(p *redis.Pool, dp DeviceProfile) error
CreateDeviceProfileCache caches the given device-profile into Redis. This is used for faster lookups, but also in case of roaming where we only want to store the device-profile of a roaming device for a finite duration. the TTL of the device-profile is the same as that of the device-sessions.
func CreateDeviceQueueItem ¶
func CreateDeviceQueueItem(db sqlx.Queryer, qi *DeviceQueueItem) error
CreateDeviceQueueItem adds the given item to the device queue.
func CreateGateway ¶
CreateGateway creates the given gateway.
func CreateGatewayProfile ¶
func CreateGatewayProfile(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 ¶
CreateMACCommandQueueItem creates a new mac-command queue item.
func CreateRoutingProfile ¶
func CreateRoutingProfile(db sqlx.Execer, rp *RoutingProfile) error
CreateRoutingProfile creates the given routing-profile.
func CreateServiceProfile ¶
func CreateServiceProfile(db sqlx.Execer, sp *ServiceProfile) error
CreateServiceProfile creates the given service-profile.
func CreateServiceProfileCache ¶
func CreateServiceProfileCache(p *redis.Pool, 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 ¶
DeleteDevice deletes the device matching the given DevEUI.
func DeleteDeviceProfile ¶
DeleteDeviceProfile deletes the device-profile matching the given id.
func DeleteDeviceQueueItem ¶
DeleteDeviceQueueItem deletes the device-queue item matching the given id.
func DeleteDeviceSession ¶
DeleteDeviceSession deletes the device-session matching the given DevEUI.
func DeleteGateway ¶
DeleteGateway deletes the gateway matching the given MAC.
func DeleteGatewayProfile ¶
DeleteGatewayProfile deletes the gateway-profile matching the given ID.
func DeleteMACCommandQueueItem ¶
DeleteMACCommandQueueItem deletes the given mac-command from the queue.
func DeletePendingMACCommand ¶
DeletePendingMACCommand removes the pending mac-command for the given CID.
func DeleteRoutingProfile ¶
DeleteRoutingProfile deletes the routing-profile matching the given id.
func DeleteServiceProfile ¶
DeleteServiceProfile deletes the service-profile matching the given id.
func DeviceSessionExists ¶
DeviceSessionExists returns a bool indicating if a device session exist.
func FlushDeviceProfileCache ¶
FlushDeviceProfileCache deletes a cached device-profile.
func FlushDeviceQueueForDevEUI ¶
FlushDeviceQueueForDevEUI deletes all device-queue items for the given DevEUI.
func FlushMACCommandQueue ¶
FlushMACCommandQueue flushes the mac-command queue for the given DevEUI.
func FlushServiceProfileCache ¶
FlushServiceProfileCache deletes a cached service-profile.
func GetGatewaysForMACs ¶
GetGatewaysForMACs returns a map of gateways given a slice of MACs.
func GetMaxEmitAtTimeSinceGPSEpochForDevEUI ¶
func GetMaxEmitAtTimeSinceGPSEpochForDevEUI(db sqlx.Queryer, devEUI lorawan.EUI64) (time.Duration, error)
GetMaxEmitAtTimeSinceGPSEpochForDevEUI returns the maximum / last GPS epoch scheduling timestamp for the given DevEUI.
func GetRandomDevAddr ¶
GetRandomDevAddr returns a random DevAddr, prefixed with NwkID based on the given NetID.
func HandleGatewayStatsPacket ¶
func HandleGatewayStatsPacket(db *common.DBLogger, stats gw.GatewayStatsPacket) error
HandleGatewayStatsPacket handles a received stats packet by the gateway.
func MustSetStatsAggregationIntervals ¶
func MustSetStatsAggregationIntervals(levels []string)
MustSetStatsAggregationIntervals sets the aggregation intervals to use. Valid levels are: SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR.
func SaveDeviceSession ¶
func SaveDeviceSession(p *redis.Pool, s DeviceSession) error
SaveDeviceSession saves the device-session. In case it doesn't exist yet it will be created.
func SetPendingMACCommand ¶
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 Transaction ¶
Transaction wraps the given function in a transaction. In case the given functions returns an error, the transaction will be rolled back.
func UpdateDevice ¶
UpdateDevice updates the given device.
func UpdateDeviceProfile ¶
func UpdateDeviceProfile(db sqlx.Execer, dp *DeviceProfile) error
UpdateDeviceProfile updates the given device-profile.
func UpdateDeviceQueueItem ¶
func UpdateDeviceQueueItem(db sqlx.Execer, qi *DeviceQueueItem) error
UpdateDeviceQueueItem updates the given device-queue item.
func UpdateGateway ¶
UpdateGateway updates the given gateway.
func UpdateGatewayProfile ¶
func UpdateGatewayProfile(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 UpdateRoutingProfile ¶
func UpdateRoutingProfile(db sqlx.Execer, rp *RoutingProfile) error
UpdateRoutingProfile updates the given routing-profile.
func UpdateServiceProfile ¶
func UpdateServiceProfile(db sqlx.Execer, sp *ServiceProfile) error
UpdateServiceProfile updates the given service-profile.
func ValidateAndGetFullFCntUp ¶
func ValidateAndGetFullFCntUp(s DeviceSession, fCntUp uint32) (uint32, bool)
ValidateAndGetFullFCntUp validates if the given fCntUp is valid and returns the full 32 bit frame-counter. Note that the LoRaWAN packet only contains the 16 LSB, so in order to validate the MIC, the full 32 bit frame-counter needs to be set. After a succesful validation of the FCntUp and the MIC, don't forget to synchronize the Node FCntUp with the packet FCnt.
Types ¶
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"` }
Device defines a LoRaWAN device.
func GetDevicesWithClassBOrClassCDeviceQueueItems ¶
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(db sqlx.Queryer, devEUI lorawan.EUI64) (DeviceActivation, error)
GetLastDeviceActivationForDevEUI returns the most recent activation for the given DevEUI.
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 int `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 int `db:"rx_freq_2"` // In Hz FactoryPresetFreqs []int `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"` }
DeviceProfile defines the backend.DeviceProfile with some extra meta-data
func GetAndCacheDeviceProfile ¶
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 ¶
GetDeviceProfile returns the device-profile matching the given id.
func GetDeviceProfileCache ¶
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"` 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"` }
DeviceQueueItem represents an item in the device queue (downlink).
func GetDeviceQueueItem ¶
func GetDeviceQueueItem(db sqlx.Queryer, id int64) (DeviceQueueItem, error)
GetDeviceQueueItem returns the device-queue item matching the given id.
func GetDeviceQueueItemsForDevEUI ¶
GetDeviceQueueItemsForDevEUI returns all device-queue items for the given DevEUI, ordered by id (keep in mind FCnt rollover).
func GetNextDeviceQueueItemForDevEUI ¶
func GetNextDeviceQueueItemForDevEUI(db sqlx.Queryer, devEUI lorawan.EUI64) (DeviceQueueItem, error)
GetNextDeviceQueueItemForDevEUI returns the next device-queue item for the given DevEUI, ordered by f_cnt (note that the f_cnt should never roll over).
func GetNextDeviceQueueItemForDevEUIMaxPayloadSizeAndFCnt ¶
func GetNextDeviceQueueItemForDevEUIMaxPayloadSizeAndFCnt(db sqlx.Ext, devEUI lorawan.EUI64, maxPayloadSize int, fCnt uint32, routingProfileID uuid.UUID) (DeviceQueueItem, error)
GetNextDeviceQueueItemForDevEUIMaxPayloadSizeAndFCnt returns the next device-queue for the given DevEUI item respecting: * maxPayloadSize: the maximum payload size * fCnt: the current expected frame-counter In case the payload exceeds the max payload size or when the payload frame-counter is behind the actual frame-counter, the payload will be removed from the queue and the next one will be retrieved. In such a case, the application-server will be notified.
func GetPendingDeviceQueueItemForDevEUI ¶
func GetPendingDeviceQueueItemForDevEUI(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 int // 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 // MaxSupportedDR defines the maximum supported DR index by the node, // or 0 when not set. MaxSupportedDR 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]band.Channel // extra uplink channels, configured by the user ChannelFrequencies []int // frequency of each channel UplinkHistory []UplinkHistory // contains the last 20 transmissions UplinkGatewayHistory map[lorawan.EUI64]UplinkGatewayHistory // LastDevStatusRequest contains the timestamp when the last device-status // request was made. LastDevStatusRequested time.Time // LastDownlinkTX contains the timestamp of the last downlink. LastDownlinkTX time.Time // Class-B related configuration. BeaconLocked bool PingSlotNb int PingSlotDR int PingSlotFrequency int // 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 }
DeviceSession defines a device-session.
func GetDeviceSession ¶
GetDeviceSession returns the device-session for the given DevEUI.
func GetDeviceSessionForPHYPayload ¶
func GetDeviceSessionForPHYPayload(p *redis.Pool, 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 ¶
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) GetDownlinkGatewayMAC ¶
func (s DeviceSession) GetDownlinkGatewayMAC() (lorawan.EUI64, error)
GetDownlinkGatewayMAC returns the gateway MAC of the gateway close to the device.
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 DeviceSessionOld ¶
type DeviceSessionOld struct { // profile ids DeviceProfileID string ServiceProfileID string RoutingProfileID string // session data DevAddr lorawan.DevAddr DevEUI lorawan.EUI64 JoinEUI lorawan.EUI64 // TODO: remove? NwkSKey lorawan.AES128Key FCntUp uint32 FCntDown uint32 // Only used by ABP activation SkipFCntValidation bool RXWindow RXWindow RXDelay uint8 RX1DROffset uint8 RX2DR uint8 RX2Frequency int // 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 // MaxSupportedTXPowerIndex defines the maximum supported tx-power index // by the node, or 0 when not set. MaxSupportedTXPowerIndex int // MaxSupportedDR defines the maximum supported DR index by the node, // or 0 when not set. MaxSupportedDR 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]band.Channel // extra uplink channels, configured by the user ChannelFrequencies []int // frequency of each channel UplinkHistory []UplinkHistory // contains the last 20 transmissions LastRXInfoSet models.RXInfoSet // sorted set (best at index 0) // LastDevStatusRequest contains the timestamp when the last device-status // request was made. LastDevStatusRequested time.Time // LastDevStatusBattery contains the last received battery status. LastDevStatusBattery uint8 // LastDevStatusMargin contains the last received margin status. LastDevStatusMargin int8 // LastDownlinkTX contains the timestamp of the last downlink. LastDownlinkTX time.Time // Class-B related configuration. BeaconLocked bool PingSlotNb int PingSlotDR int PingSlotFrequency int }
DeviceSessionOld defines the "old" device-session struct. This struct is needed to gob decode "old" device-sessions.
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 */ // MaxSupportedDR defines the maximum supported DR index by the node, // or 0 when not set. MaxSupportedDr uint32 `protobuf:"varint,22,opt,name=max_supported_dr,json=maxSupportedDr,proto3" json:"max_supported_dr,omitempty"` // 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"` // Uplink gateway history (for Class B / C). // Note that as bytes are not supported in a Protobuf map, the gateway ID is HEX encoded. UplinkGatewayHistory map[string]*DeviceSessionPBUplinkGatewayHistory `` /* 212-byte string literal not displayed */ // Last device-status requested timestamp (Unix ns) LastDeviceStatusRequestTimeUnixNs int64 `` /* 172-byte string literal not displayed */ // Last downlink timestamp (Unix ns). LastDownlinkTxTimestampUnixNs int64 `` /* 158-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 */ XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*DeviceSessionPB) Descriptor ¶
func (*DeviceSessionPB) Descriptor() ([]byte, []int)
func (*DeviceSessionPB) GetAFCntDown ¶
func (m *DeviceSessionPB) GetAFCntDown() uint32
func (*DeviceSessionPB) GetAdr ¶
func (m *DeviceSessionPB) GetAdr() bool
func (*DeviceSessionPB) GetAppSKeyEnvelope ¶
func (m *DeviceSessionPB) GetAppSKeyEnvelope() *common.KeyEnvelope
func (*DeviceSessionPB) GetBeaconLocked ¶
func (m *DeviceSessionPB) GetBeaconLocked() bool
func (*DeviceSessionPB) GetChannelFrequencies ¶
func (m *DeviceSessionPB) GetChannelFrequencies() []uint32
func (*DeviceSessionPB) GetConfFCnt ¶
func (m *DeviceSessionPB) GetConfFCnt() uint32
func (*DeviceSessionPB) GetDevAddr ¶
func (m *DeviceSessionPB) GetDevAddr() []byte
func (*DeviceSessionPB) GetDevEui ¶
func (m *DeviceSessionPB) GetDevEui() []byte
func (*DeviceSessionPB) GetDeviceProfileId ¶
func (m *DeviceSessionPB) GetDeviceProfileId() string
func (*DeviceSessionPB) GetDr ¶
func (m *DeviceSessionPB) GetDr() uint32
func (*DeviceSessionPB) GetEnabledUplinkChannels ¶
func (m *DeviceSessionPB) GetEnabledUplinkChannels() []uint32
func (*DeviceSessionPB) GetExtraUplinkChannels ¶
func (m *DeviceSessionPB) GetExtraUplinkChannels() map[uint32]*DeviceSessionPBChannel
func (*DeviceSessionPB) GetFCntUp ¶
func (m *DeviceSessionPB) GetFCntUp() uint32
func (*DeviceSessionPB) GetFNwkSIntKey ¶
func (m *DeviceSessionPB) GetFNwkSIntKey() []byte
func (*DeviceSessionPB) GetJoinEui ¶
func (m *DeviceSessionPB) GetJoinEui() []byte
func (*DeviceSessionPB) GetLastDeviceStatusRequestTimeUnixNs ¶
func (m *DeviceSessionPB) GetLastDeviceStatusRequestTimeUnixNs() int64
func (*DeviceSessionPB) GetLastDownlinkTxTimestampUnixNs ¶
func (m *DeviceSessionPB) GetLastDownlinkTxTimestampUnixNs() int64
func (*DeviceSessionPB) GetMacVersion ¶
func (m *DeviceSessionPB) GetMacVersion() string
func (*DeviceSessionPB) GetMaxSupportedDr ¶
func (m *DeviceSessionPB) GetMaxSupportedDr() uint32
func (*DeviceSessionPB) GetMaxSupportedTxPowerIndex ¶
func (m *DeviceSessionPB) GetMaxSupportedTxPowerIndex() uint32
func (*DeviceSessionPB) GetMinSupportedTxPowerIndex ¶
func (m *DeviceSessionPB) GetMinSupportedTxPowerIndex() uint32
func (*DeviceSessionPB) GetNFCntDown ¶
func (m *DeviceSessionPB) GetNFCntDown() uint32
func (*DeviceSessionPB) GetNbTrans ¶
func (m *DeviceSessionPB) GetNbTrans() uint32
func (*DeviceSessionPB) GetNwkSEncKey ¶
func (m *DeviceSessionPB) GetNwkSEncKey() []byte
func (*DeviceSessionPB) GetPendingRejoinDeviceSession ¶
func (m *DeviceSessionPB) GetPendingRejoinDeviceSession() []byte
func (*DeviceSessionPB) GetPingSlotDr ¶
func (m *DeviceSessionPB) GetPingSlotDr() uint32
func (*DeviceSessionPB) GetPingSlotFrequency ¶
func (m *DeviceSessionPB) GetPingSlotFrequency() uint32
func (*DeviceSessionPB) GetPingSlotNb ¶
func (m *DeviceSessionPB) GetPingSlotNb() uint32
func (*DeviceSessionPB) GetRejoinCount_0 ¶
func (m *DeviceSessionPB) GetRejoinCount_0() uint32
func (*DeviceSessionPB) GetRejoinRequestEnabled ¶
func (m *DeviceSessionPB) GetRejoinRequestEnabled() bool
func (*DeviceSessionPB) GetRejoinRequestMaxCountN ¶
func (m *DeviceSessionPB) GetRejoinRequestMaxCountN() uint32
func (*DeviceSessionPB) GetRejoinRequestMaxTimeN ¶
func (m *DeviceSessionPB) GetRejoinRequestMaxTimeN() uint32
func (*DeviceSessionPB) GetRoutingProfileId ¶
func (m *DeviceSessionPB) GetRoutingProfileId() string
func (*DeviceSessionPB) GetRx1DrOffset ¶
func (m *DeviceSessionPB) GetRx1DrOffset() uint32
func (*DeviceSessionPB) GetRx2Dr ¶
func (m *DeviceSessionPB) GetRx2Dr() uint32
func (*DeviceSessionPB) GetRx2Frequency ¶
func (m *DeviceSessionPB) GetRx2Frequency() uint32
func (*DeviceSessionPB) GetRxDelay ¶
func (m *DeviceSessionPB) GetRxDelay() uint32
func (*DeviceSessionPB) GetSNwkSIntKey ¶
func (m *DeviceSessionPB) GetSNwkSIntKey() []byte
func (*DeviceSessionPB) GetServiceProfileId ¶
func (m *DeviceSessionPB) GetServiceProfileId() string
func (*DeviceSessionPB) GetSkipFCntCheck ¶
func (m *DeviceSessionPB) GetSkipFCntCheck() bool
func (*DeviceSessionPB) GetTxPowerIndex ¶
func (m *DeviceSessionPB) GetTxPowerIndex() uint32
func (*DeviceSessionPB) GetUplinkAdrHistory ¶
func (m *DeviceSessionPB) GetUplinkAdrHistory() []*DeviceSessionPBUplinkADRHistory
func (*DeviceSessionPB) GetUplinkGatewayHistory ¶
func (m *DeviceSessionPB) GetUplinkGatewayHistory() map[string]*DeviceSessionPBUplinkGatewayHistory
func (*DeviceSessionPB) ProtoMessage ¶
func (*DeviceSessionPB) ProtoMessage()
func (*DeviceSessionPB) Reset ¶
func (m *DeviceSessionPB) Reset()
func (*DeviceSessionPB) String ¶
func (m *DeviceSessionPB) String() string
func (*DeviceSessionPB) XXX_DiscardUnknown ¶
func (m *DeviceSessionPB) XXX_DiscardUnknown()
func (*DeviceSessionPB) XXX_Marshal ¶
func (m *DeviceSessionPB) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*DeviceSessionPB) XXX_Merge ¶
func (dst *DeviceSessionPB) XXX_Merge(src proto.Message)
func (*DeviceSessionPB) XXX_Size ¶
func (m *DeviceSessionPB) XXX_Size() int
func (*DeviceSessionPB) XXX_Unmarshal ¶
func (m *DeviceSessionPB) XXX_Unmarshal(b []byte) error
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"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*DeviceSessionPBChannel) Descriptor ¶
func (*DeviceSessionPBChannel) Descriptor() ([]byte, []int)
func (*DeviceSessionPBChannel) GetFrequency ¶
func (m *DeviceSessionPBChannel) GetFrequency() uint32
func (*DeviceSessionPBChannel) GetMaxDr ¶
func (m *DeviceSessionPBChannel) GetMaxDr() uint32
func (*DeviceSessionPBChannel) GetMinDr ¶
func (m *DeviceSessionPBChannel) GetMinDr() uint32
func (*DeviceSessionPBChannel) ProtoMessage ¶
func (*DeviceSessionPBChannel) ProtoMessage()
func (*DeviceSessionPBChannel) Reset ¶
func (m *DeviceSessionPBChannel) Reset()
func (*DeviceSessionPBChannel) String ¶
func (m *DeviceSessionPBChannel) String() string
func (*DeviceSessionPBChannel) XXX_DiscardUnknown ¶
func (m *DeviceSessionPBChannel) XXX_DiscardUnknown()
func (*DeviceSessionPBChannel) XXX_Marshal ¶
func (m *DeviceSessionPBChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*DeviceSessionPBChannel) XXX_Merge ¶
func (dst *DeviceSessionPBChannel) XXX_Merge(src proto.Message)
func (*DeviceSessionPBChannel) XXX_Size ¶
func (m *DeviceSessionPBChannel) XXX_Size() int
func (*DeviceSessionPBChannel) XXX_Unmarshal ¶
func (m *DeviceSessionPBChannel) XXX_Unmarshal(b []byte) error
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"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*DeviceSessionPBUplinkADRHistory) Descriptor ¶
func (*DeviceSessionPBUplinkADRHistory) Descriptor() ([]byte, []int)
func (*DeviceSessionPBUplinkADRHistory) GetFCnt ¶
func (m *DeviceSessionPBUplinkADRHistory) GetFCnt() uint32
func (*DeviceSessionPBUplinkADRHistory) GetGatewayCount ¶
func (m *DeviceSessionPBUplinkADRHistory) GetGatewayCount() uint32
func (*DeviceSessionPBUplinkADRHistory) GetMaxSnr ¶
func (m *DeviceSessionPBUplinkADRHistory) GetMaxSnr() float32
func (*DeviceSessionPBUplinkADRHistory) GetTxPowerIndex ¶
func (m *DeviceSessionPBUplinkADRHistory) GetTxPowerIndex() uint32
func (*DeviceSessionPBUplinkADRHistory) ProtoMessage ¶
func (*DeviceSessionPBUplinkADRHistory) ProtoMessage()
func (*DeviceSessionPBUplinkADRHistory) Reset ¶
func (m *DeviceSessionPBUplinkADRHistory) Reset()
func (*DeviceSessionPBUplinkADRHistory) String ¶
func (m *DeviceSessionPBUplinkADRHistory) String() string
func (*DeviceSessionPBUplinkADRHistory) XXX_DiscardUnknown ¶
func (m *DeviceSessionPBUplinkADRHistory) XXX_DiscardUnknown()
func (*DeviceSessionPBUplinkADRHistory) XXX_Marshal ¶
func (m *DeviceSessionPBUplinkADRHistory) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*DeviceSessionPBUplinkADRHistory) XXX_Merge ¶
func (dst *DeviceSessionPBUplinkADRHistory) XXX_Merge(src proto.Message)
func (*DeviceSessionPBUplinkADRHistory) XXX_Size ¶
func (m *DeviceSessionPBUplinkADRHistory) XXX_Size() int
func (*DeviceSessionPBUplinkADRHistory) XXX_Unmarshal ¶
func (m *DeviceSessionPBUplinkADRHistory) XXX_Unmarshal(b []byte) error
type DeviceSessionPBUplinkGatewayHistory ¶
type DeviceSessionPBUplinkGatewayHistory struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*DeviceSessionPBUplinkGatewayHistory) Descriptor ¶
func (*DeviceSessionPBUplinkGatewayHistory) Descriptor() ([]byte, []int)
func (*DeviceSessionPBUplinkGatewayHistory) ProtoMessage ¶
func (*DeviceSessionPBUplinkGatewayHistory) ProtoMessage()
func (*DeviceSessionPBUplinkGatewayHistory) Reset ¶
func (m *DeviceSessionPBUplinkGatewayHistory) Reset()
func (*DeviceSessionPBUplinkGatewayHistory) String ¶
func (m *DeviceSessionPBUplinkGatewayHistory) String() string
func (*DeviceSessionPBUplinkGatewayHistory) XXX_DiscardUnknown ¶
func (m *DeviceSessionPBUplinkGatewayHistory) XXX_DiscardUnknown()
func (*DeviceSessionPBUplinkGatewayHistory) XXX_Marshal ¶
func (m *DeviceSessionPBUplinkGatewayHistory) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*DeviceSessionPBUplinkGatewayHistory) XXX_Merge ¶
func (dst *DeviceSessionPBUplinkGatewayHistory) XXX_Merge(src proto.Message)
func (*DeviceSessionPBUplinkGatewayHistory) XXX_Size ¶
func (m *DeviceSessionPBUplinkGatewayHistory) XXX_Size() int
func (*DeviceSessionPBUplinkGatewayHistory) XXX_Unmarshal ¶
func (m *DeviceSessionPBUplinkGatewayHistory) XXX_Unmarshal(b []byte) error
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 ¶
GPSPoint contains a GPS point.
type Gateway ¶
type Gateway struct { MAC lorawan.EUI64 `db:"mac"` 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"` GatewayProfileID *uuid.UUID `db:"gateway_profile_id"` }
Gateway represents a gateway.
func GetGateway ¶
GetGateway returns the gateway for the given MAC.
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"` ExtraChannels []ExtraChannel `db:"-"` }
GatewayProfile defines a gateway-profile.
func GetGatewayProfile ¶
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 ¶
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 ¶
GetMACCommandQueueItems returns the mac-command queue items for the given DevEUI.
func GetPendingMACCommand ¶
func GetPendingMACCommand(p *redis.Pool, 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 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(db sqlx.Queryer) ([]RoutingProfile, error)
GetAllRoutingProfiles returns all the available routing-profiles.
func GetRoutingProfile ¶
GetRoutingProfile returns the routing-profile matching the given id.
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"` }
ServiceProfile defines the backend.ServiceProfile with some extra meta-data.
func GetAndCacheServiceProfile ¶
func GetAndCacheServiceProfile(db sqlx.Queryer, p *redis.Pool, 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 ¶
GetServiceProfile returns the service-profile matching the given id.
func GetServiceProfileCache ¶
GetServiceProfileCache returns a cached service-profile.
type Stats ¶
type Stats struct { MAC lorawan.EUI64 `db:"mac"` Timestamp time.Time `db:"timestamp"` Interval string `db:"interval"` RXPacketsReceived int `db:"rx_packets_received"` RXPacketsReceivedOK int `db:"rx_packets_received_ok"` TXPacketsReceived int `db:"tx_packets_received"` TXPacketsEmitted int `db:"tx_packets_emitted"` }
Stats represents a single gateway stats record.
type UplinkGatewayHistory ¶
type UplinkGatewayHistory struct{}
UplinkGatewayHistory contains the uplink gateway history meta-data. This is used for Class-B and Class-C downlinks.