util

package
v2.3.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2017 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPayload = errors.New("Invalid payload (Should be hexadecimal)")

Functions

func ForceRefreshToken

func ForceRefreshToken(ctx ttnlog.Interface)

ForceRefreshToken forces a refresh of the access token

func GetAccount

func GetAccount(ctx ttnlog.Interface) *account.Account

GetAccount gets a new Account server client for ttnctl

func GetAppEUI

func GetAppEUI(ctx ttnlog.Interface) types.AppEUI

GetAppEUI returns the AppEUI that must be set in the command options or config

func GetAppID

func GetAppID(ctx ttnlog.Interface) string

GetAppID returns the AppID that must be set in the command options or config

func GetConfigFile

func GetConfigFile() string

GetConfigFile returns the location of the configuration file. It checks the following (in this order): the --config flag $XDG_CONFIG_HOME/ttnctl/config.yml (if $XDG_CONFIG_HOME is set) $HOME/.ttnctl.yml

func GetContext

func GetContext(ctx ttnlog.Interface, extraPairs ...string) context.Context

GetContext returns a new context

func GetDataDir

func GetDataDir() string

GetDataDir returns the location of the data directory used for sotring data. It checks the following (in this order): the --data flag $XDG_DATA_HOME/ttnctl (if $XDG_DATA_HOME is set) $XDG_CACHE_HOME/ttnctl (if $XDG_CACHE_HOME is set) $HOME/.ttnctl

func GetDiscovery

GetDiscovery gets the Discovery client for ttnctl

func GetGatewayMetadata

func GetGatewayMetadata(id string, freq uint64) *gateway.RxMetadata

GetGatewayMetadata returns gateway metadata for the given gateway ID and frequency

func GetHandlerManager

func GetHandlerManager(ctx ttnlog.Interface, appID string) (*grpc.ClientConn, *handler.ManagerClient)

GetHandlerManager gets a new HandlerManager for ttnctl

func GetID

func GetID() string

GetID retrns the ID of this ttnctl

func GetMQTT

func GetMQTT(ctx ttnlog.Interface) mqtt.Client

GetMQTT connects a new MQTT clients with the specified credentials

func GetProtocolMetadata

func GetProtocolMetadata(dataRate string) *protocol.RxMetadata

GetProtocolMetadata returns protocol metadata for the given datarate

func GetRouter

GetRouter starts a connection with the router

func GetRouterManager

func GetRouterManager(ctx ttnlog.Interface) (*grpc.ClientConn, router.RouterManagerClient)

GetRouterManager starts a management connection with the router

func GetTokenCache

func GetTokenCache() cache.Cache

GetCache get's the cache that will store our tokens

func GetTokenManager

func GetTokenManager(accessToken string) tokens.Manager

func GetTokenSource

func GetTokenSource(ctx ttnlog.Interface) oauth2.TokenSource

GetTokenSource builds a new oauth2.TokenSource that uses the ttnctl config to store the token

func GetUserAgent

func GetUserAgent() string

func IsErrOutOfRange

func IsErrOutOfRange(err error) bool

func Login

func Login(ctx ttnlog.Interface, code string) (*oauth2.Token, error)

Login does a login to the Account server with the given username and password

func Logout

func Logout() error

func ParseLocation

func ParseLocation(locationStr string) (*account.Location, error)

func PrintConfig

func PrintConfig(ctx ttnlog.Interface, debug bool)

func ReadFields

func ReadFields() (map[string]interface{}, error)

func ReadInput

func ReadInput(reader *bufio.Reader) (string, error)

ReadInput allows to read an input line from the user

func ReadPayload

func ReadPayload() ([]byte, error)

func ReadPort

func ReadPort() (uint8, error)

func SetApp

func SetApp(ctx ttnlog.Interface, appID string, appEUI types.AppEUI)

SetApp stores the app ID and app EUI preferences

func SetAppEUI

func SetAppEUI(ctx ttnlog.Interface, appEUI types.AppEUI)

SetApp stores the app EUI preference

func TokenForScope

func TokenForScope(ctx ttnlog.Interface, scope string) string

Types

type Message

type Message struct {
	FCnt  int
	FPort int

	Payload []byte
	// contains filtered or unexported fields
}

Message struct is used to construct an uplink message

func (*Message) Bytes

func (m *Message) Bytes() []byte

Bytes returns the bytes

func (*Message) SetDevice

func (m *Message) SetDevice(devAddr types.DevAddr, nwkSKey types.NwkSKey, appSKey types.AppSKey)

SetDevice with the LoRaWAN options

func (*Message) SetMessage

func (m *Message) SetMessage(confirmed bool, fCnt int, payload []byte)

SetMessage with some options

func (*Message) Unmarshal

func (m *Message) Unmarshal(bytes []byte) error

Unmarshal a byte slice into a Message

Jump to

Keyboard shortcuts

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