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 string) 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 string) 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 string) error
- func DeleteServiceProfile(db sqlx.Execer, id string) error
- func DeviceSessionExists(p *redis.Pool, devEUI lorawan.EUI64) (bool, error)
- func FlushDeviceProfileCache(p *redis.Pool, id string) 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 string) 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
- type ExtraChannel
- type GPSPoint
- type Gateway
- type GatewayProfile
- type MACCommandBlock
- type MACCommands
- type RXWindow
- type RoutingProfile
- type ServiceProfile
- type Stats
- 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") )
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 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 ¶
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 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 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"` 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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
GPSPoint contains a GPS point.
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 ¶
GetGateway returns the gateway for the given MAC.
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 ¶
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 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 ¶
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.