storage

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2018 License: MIT Imports: 26 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")
	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")
)

errors

Functions

func CreateDevice

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

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

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

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

func CreateMACCommandQueueItem(p *redis.Pool, devEUI lorawan.EUI64, block MACCommandBlock) error

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

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

DeleteDevice deletes the device matching the given DevEUI.

func DeleteDeviceProfile

func DeleteDeviceProfile(db sqlx.Execer, id string) error

DeleteDeviceProfile deletes the device-profile matching the given id.

func DeleteDeviceQueueItem

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

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

func DeleteDeviceSession

func DeleteDeviceSession(p *redis.Pool, devEUI lorawan.EUI64) error

DeleteDeviceSession deletes the device-session matching the given DevEUI.

func DeleteGateway

func DeleteGateway(db sqlx.Execer, mac lorawan.EUI64) error

DeleteGateway deletes the gateway matching the given MAC.

func DeleteGatewayProfile

func DeleteGatewayProfile(db sqlx.Execer, id string) error

DeleteGatewayProfile deletes the gateway-profile matching the given ID.

func DeleteMACCommandQueueItem

func DeleteMACCommandQueueItem(p *redis.Pool, devEUI lorawan.EUI64, block MACCommandBlock) error

DeleteMACCommandQueueItem deletes the given mac-command from the queue.

func DeletePendingMACCommand

func DeletePendingMACCommand(p *redis.Pool, devEUI lorawan.EUI64, cid lorawan.CID) error

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

func DeleteRoutingProfile

func DeleteRoutingProfile(db sqlx.Execer, id string) error

DeleteRoutingProfile deletes the routing-profile matching the given id.

func DeleteServiceProfile

func DeleteServiceProfile(db sqlx.Execer, id string) error

DeleteServiceProfile deletes the service-profile matching the given id.

func DeviceSessionExists

func DeviceSessionExists(p *redis.Pool, devEUI lorawan.EUI64) (bool, error)

DeviceSessionExists returns a bool indicating if a device session exist.

func FlushDeviceProfileCache

func FlushDeviceProfileCache(p *redis.Pool, id string) error

FlushDeviceProfileCache deletes a cached device-profile.

func FlushDeviceQueueForDevEUI

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

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

func FlushMACCommandQueue

func FlushMACCommandQueue(p *redis.Pool, devEUI lorawan.EUI64) error

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

func FlushServiceProfileCache

func FlushServiceProfileCache(p *redis.Pool, id string) error

FlushServiceProfileCache deletes a cached service-profile.

func GetGatewaysForMACs

func GetGatewaysForMACs(db sqlx.Queryer, macs []lorawan.EUI64) (map[lorawan.EUI64]Gateway, error)

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

func GetRandomDevAddr(p *redis.Pool, netID lorawan.NetID) (lorawan.DevAddr, error)

GetRandomDevAddr returns a random free DevAddr. Note that the 7 MSB will be set to the NwkID (based on the configured 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

func SetPendingMACCommand(p *redis.Pool, 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 Transaction

func Transaction(db *common.DBLogger, 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(db sqlx.Execer, d *Device) error

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

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

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.

func ValidateDevNonce

func ValidateDevNonce(db sqlx.Queryer, joinEUI, devEUI lorawan.EUI64, nonce lorawan.DevNonce) error

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

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  string        `db:"device_profile_id"`
	ServiceProfileID string        `db:"service_profile_id"`
	RoutingProfileID string        `db:"routing_profile_id"`
	SkipFCntCheck    bool          `db:"skip_fcnt_check"`
}

Device defines a LoRaWAN device.

func GetDevice

func GetDevice(db sqlx.Queryer, devEUI lorawan.EUI64) (Device, error)

GetDevice returns the device matching the given DevEUI.

func GetDevicesWithClassBOrClassCDeviceQueueItems

func GetDevicesWithClassBOrClassCDeviceQueueItems(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"`
	NwkSKey   lorawan.AES128Key `db:"nwk_s_key"`
	DevNonce  lorawan.DevNonce  `db:"dev_nonce"`
}

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"`
	backend.DeviceProfile
}

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

func GetAndCacheDeviceProfile

func GetAndCacheDeviceProfile(db sqlx.Queryer, p *redis.Pool, id string) (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(db sqlx.Queryer, id string) (DeviceProfile, error)

GetDeviceProfile returns the device-profile matching the given id.

func GetDeviceProfileCache

func GetDeviceProfileCache(p *redis.Pool, id string) (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"`
	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

func GetDeviceQueueItemsForDevEUI(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(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 string) (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.

type DeviceSession

type DeviceSession 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

	// 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
	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
}

DeviceSession defines a device-session.

func GetDeviceSession

func GetDeviceSession(p *redis.Pool, devEUI lorawan.EUI64) (DeviceSession, error)

GetDeviceSession returns the device-session for the given DevEUI.

func GetDeviceSessionForPHYPayload

func GetDeviceSessionForPHYPayload(p *redis.Pool, phy lorawan.PHYPayload) (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(p *redis.Pool, 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) 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.

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 {
	MAC              lorawan.EUI64 `db:"mac"`
	Name             string        `db:"name"`
	Description      string        `db:"description"`
	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 *string       `db:"gateway_profile_id"`
}

Gateway represents a gateway.

func GetGateway

func GetGateway(db sqlx.Queryer, mac lorawan.EUI64) (Gateway, error)

GetGateway returns the gateway for the given MAC.

func (Gateway) Validate

func (g Gateway) Validate() error

Validate validates the data of the gateway.

type GatewayProfile

type GatewayProfile struct {
	GatewayProfileID string         `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

func GetGatewayProfile(db sqlx.Queryer, id string) (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 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(p *redis.Pool, devEUI lorawan.EUI64) ([]MACCommandBlock, error)

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 RXWindow

type RXWindow int8

RXWindow defines the RX window option.

type RoutingProfile

type RoutingProfile struct {
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
	backend.RoutingProfile
	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

func GetRoutingProfile(db sqlx.Queryer, id string) (RoutingProfile, error)

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"`
	backend.ServiceProfile
}

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

func GetAndCacheServiceProfile

func GetAndCacheServiceProfile(db sqlx.Queryer, p *redis.Pool, id string) (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(db sqlx.Queryer, id string) (ServiceProfile, error)

GetServiceProfile returns the service-profile matching the given id.

func GetServiceProfileCache

func GetServiceProfileCache(p *redis.Pool, id string) (ServiceProfile, error)

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.

func GetGatewayStats

func GetGatewayStats(db *common.DBLogger, mac lorawan.EUI64, interval string, start, end time.Time) ([]Stats, error)

GetGatewayStats returns the stats for the given gateway. Note that the stats will return a record for each interval.

type UplinkHistory

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

UplinkHistory contains the meta-data of an uplink transmission.

Jump to

Keyboard shortcuts

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