storage

package
v0.0.0-...-2ac35d6 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2016 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMACPayloadToTXQueue

func AddMACPayloadToTXQueue(p *redis.Pool, pl models.MACPayload) error

AddMACPayloadToTXQueue adds the given payload to the queue of MAC commands to send to the node. Note that the queue is bound to the node-session, since all mac operations are reset after a re-join of the node.

func AddTXPayloadToQueue

func AddTXPayloadToQueue(p *redis.Pool, payload models.TXPayload) error

AddTXPayloadToQueue adds the given TXPayload to the queue.

func ClearInProcessTXPayload

func ClearInProcessTXPayload(p *redis.Pool, devEUI lorawan.EUI64) (*models.TXPayload, error)

ClearInProcessTXPayload clears the in-process TXPayload (to be called after a successful transmission). It returns the TXPayload or nil when nothing was cleared (it already expired).

func CreateApplication

func CreateApplication(db *sqlx.DB, a models.Application) error

CreateApplication creates the given Application

func CreateChannel

func CreateChannel(db *sqlx.DB, c *models.Channel) error

CreateChannel creates the given channel.

func CreateChannelList

func CreateChannelList(db *sqlx.DB, cl *models.ChannelList) error

CreateChannelList creates the given ChannelList.

func CreateNode

func CreateNode(db *sqlx.DB, n models.Node) error

CreateNode creates the given Node.

func CreateNodeSession

func CreateNodeSession(p *redis.Pool, s models.NodeSession) error

CreateNodeSession does the same as saveNodeSession except that it does not overwrite an exisitng record.

func DeleteApplication

func DeleteApplication(db *sqlx.DB, appEUI lorawan.EUI64) error

DeleteApplication deletes the Application matching the given AppEUI. Note that this will delete all related nodes too!

func DeleteChannel

func DeleteChannel(db *sqlx.DB, id int64) error

DeleteChannel deletes the Channel matching the given id.

func DeleteChannelList

func DeleteChannelList(db *sqlx.DB, id int64) error

DeleteChannelList deletes the ChannelList matching the given id.

func DeleteMACPayloadFromTXQueue

func DeleteMACPayloadFromTXQueue(p *redis.Pool, devAddr lorawan.DevAddr, pl models.MACPayload) error

DeleteMACPayloadFromTXQueue deletes the given MACPayload from the tx queue of the given device address.

func DeleteNode

func DeleteNode(db *sqlx.DB, p *redis.Pool, devEUI lorawan.EUI64) error

DeleteNode deletes the Node matching the given DevEUI.

func DeleteNodeSession

func DeleteNodeSession(p *redis.Pool, devAddr lorawan.DevAddr) error

DeleteNodeSession deletes the NodeSession matching the given DevAddr.

func FilterMACPayloads

func FilterMACPayloads(payloads []models.MACPayload, frmPayload bool, maxBytes int) []models.MACPayload

FilterMACPayloads filters the given slice of MACPayload elements based on the given criteria (FRMPayload and max-bytes).

func FlushTXPayloadQueue

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

FlushTXPayloadQueue flushes the tx payload queue for the given DevEUI.

func GetApplication

func GetApplication(db *sqlx.DB, appEUI lorawan.EUI64) (models.Application, error)

GetApplication returns the Application for the given AppEUI.

func GetApplications

func GetApplications(db *sqlx.DB, limit, offset int) ([]models.Application, error)

GetApplications returns a slice of applications.

func GetApplicationsCount

func GetApplicationsCount(db *sqlx.DB) (int, error)

GetApplicationsCount returns the number of applications.

func GetCFListForNode

func GetCFListForNode(db *sqlx.DB, node models.Node) (*lorawan.CFList, error)

GetCFListForNode returns the CFList for the given node if the used ISM band allows using a CFList.

func GetChannel

func GetChannel(db *sqlx.DB, id int64) (models.Channel, error)

GetChannel returns the Channel matching the given id.

func GetChannelList

func GetChannelList(db *sqlx.DB, id int64) (models.ChannelList, error)

GetChannelList returns the ChannelList for the given id.

func GetChannelLists

func GetChannelLists(db *sqlx.DB, limit, offset int) ([]models.ChannelList, error)

GetChannelLists returns a list of ChannelList items.

func GetChannelListsCount

func GetChannelListsCount(db *sqlx.DB) (int, error)

GetChannelListsCount returns the total number of channel-lists.

func GetChannelsForChannelList

func GetChannelsForChannelList(db *sqlx.DB, channelListID int64) ([]models.Channel, error)

GetChannelsForChannelList returns the Channels for the given ChannelList id.

func GetNode

func GetNode(db *sqlx.DB, devEUI lorawan.EUI64) (models.Node, error)

GetNode returns the Node for the given DevEUI.

func GetNodeSession

func GetNodeSession(p *redis.Pool, devAddr lorawan.DevAddr) (models.NodeSession, error)

GetNodeSession returns the NodeSession for the given DevAddr.

func GetNodeSessionByDevEUI

func GetNodeSessionByDevEUI(p *redis.Pool, devEUI lorawan.EUI64) (models.NodeSession, error)

GetNodeSessionByDevEUI returns the NodeSession for the given DevEUI.

func GetNodes

func GetNodes(db *sqlx.DB, limit, offset int) ([]models.Node, error)

GetNodes returns a slice of nodes, sorted by DevEUI.

func GetNodesCount

func GetNodesCount(db *sqlx.DB) (int, error)

GetNodesCount returns the total number of nodes.

func GetNodesForAppEUI

func GetNodesForAppEUI(db *sqlx.DB, appEUI lorawan.EUI64, limit, offset int) ([]models.Node, error)

GetNodesForAppEUI returns a slice of nodes, sorted by DevEUI, for the given AppEUI.

func GetNodesForAppEUICount

func GetNodesForAppEUICount(db *sqlx.DB, appEUI lorawan.EUI64) (int, error)

GetNodesForAppEUICount returns the total number of nodes given an AppEUI.

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). TODO: handle collission with retry?

func GetTXPayloadFromQueue

func GetTXPayloadFromQueue(p *redis.Pool, devEUI lorawan.EUI64) (models.TXPayload, error)

GetTXPayloadFromQueue returns the first TXPayload to send to the node. The TXPayload either is a payload that is still in-process (e.g. a payload that needs to be re-transmitted) or an item from the queue. After a successful transmission, don't forget to call clearInProcessTXPayload. errEmptyQueue is returned when the queue is empty / does not exist.

func GetTXPayloadQueueSize

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

GetTXPayloadQueueSize returns the total TXPayload elements in the queue (including the in-process queue).

func NewRedisPool

func NewRedisPool(redisURL string) *redis.Pool

NewRedisPool returns a new Redis connection pool.

func OpenDatabase

func OpenDatabase(dsn string) (*sqlx.DB, error)

OpenDatabase opens the database and performs a ping to make sure the database is up.

func ReadMACPayloadTXQueue

func ReadMACPayloadTXQueue(p *redis.Pool, devAddr lorawan.DevAddr) ([]models.MACPayload, error)

ReadMACPayloadTXQueue reads the full MACPayload tx queue for the given device address.

func SaveNodeSession

func SaveNodeSession(p *redis.Pool, s models.NodeSession) error

SaveNodeSession saves the node session. Note that the session will automatically expire after NodeSessionTTL.

func UpdateApplication

func UpdateApplication(db *sqlx.DB, a models.Application) error

UpdateApplication updates the given Application.

func UpdateChannel

func UpdateChannel(db *sqlx.DB, c models.Channel) error

UpdateChannel updates the given Channel.

func UpdateChannelList

func UpdateChannelList(db *sqlx.DB, cl models.ChannelList) error

UpdateChannelList updates the given ChannelList.

func UpdateNode

func UpdateNode(db *sqlx.DB, n models.Node) error

UpdateNode updates the given Node.

func ValidateAndGetFullFCntUp

func ValidateAndGetFullFCntUp(n models.NodeSession, 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

This section is empty.

Jump to

Keyboard shortcuts

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