Documentation ¶
Index ¶
- Constants
- func ConcentratorTimeFromXTime(xTime int64) scheduling.ConcentratorTime
- func ConcentratorTimeToXTime(id int32, t scheduling.ConcentratorTime) int64
- func NewFormatter(maxRoundTripDelay time.Duration) ws.Formatter
- func SessionIDFromXTime(xTime int64) int32
- func TimeFromGPSTime(t int64) time.Time
- func TimeFromUnixSeconds(tf float64) time.Time
- func TimePtrFromGPSTime(t int64) *time.Time
- func TimePtrFromUnixSeconds(tf float64) *time.Time
- func TimePtrFromUpInfo(gpsTime int64, rxTime float64, referenceTime time.Time) *time.Time
- func TimePtrToUpInfoTime(t *time.Time) (float64, int64)
- func TimeToGPSTime(t time.Time) int64
- func TimeToUnixSeconds(t time.Time) float64
- func TimestampFromXTime(xTime int64) uint32
- func Type(data []byte) (string, error)
- type DiscoverQuery
- type DiscoverResponse
- type DownlinkMessage
- type JoinRequest
- type MessageType
- type RadioMetaData
- type TimeSyncRequest
- type TimeSyncResponse
- type TxConfirmation
- type UpInfo
- type UplinkDataFrame
- type Version
Constants ¶
const ( // Upstream types for messages from the Gateway. TypeUpstreamVersion = "version" TypeUpstreamJoinRequest = "jreq" TypeUpstreamUplinkDataFrame = "updf" TypeUpstreamProprietaryDataFrame = "propdf" TypeUpstreamTxConfirmation = "dntxed" TypeUpstreamTimeSync = "timesync" TypeUpstreamRemoteShell = "rmtsh" // Downstream types for messages from the Network TypeDownstreamDownlinkMessage = "dnmsg" TypeDownstreamDownlinkMulticastSchedule = "dnsched" TypeDownstreamTimeSync = "timesync" TypeDownstreamRemoteCommand = "runcmd" TypeDownstreamRemoteShell = "rmtsh" )
Definition of LoRa Basic Station message types.
Variables ¶
This section is empty.
Functions ¶
func ConcentratorTimeFromXTime ¶ added in v3.16.0
func ConcentratorTimeFromXTime(xTime int64) scheduling.ConcentratorTime
ConcentratorTimeFromXTime constructs the scheduling.ConcentratorTime associated with the provided XTime.
func ConcentratorTimeToXTime ¶ added in v3.16.0
func ConcentratorTimeToXTime(id int32, t scheduling.ConcentratorTime) int64
ConcentratorTimeToXTime contructs the XTime associated with the provided session ID and concentrator timestamp.
func NewFormatter ¶
NewFormatter returns a new LoRa Basic Station LNS formatter.
func SessionIDFromXTime ¶ added in v3.16.0
SessionIDFromXTime constructs the session ID associated with the provided XTime.
func TimeFromGPSTime ¶ added in v3.16.0
TimeFromGPSTime constructs a time.Time from the provided GPS time in microseconds.
func TimeFromUnixSeconds ¶ added in v3.16.0
TimeFromUnixSeconds constructs a time.Time from the provided UNIX fractional timestamp.
func TimePtrFromGPSTime ¶ added in v3.16.0
TimePtrFromGPSTime constructs a *time.Time from the provided GPS time in microseconds. If the timestamp is 0, this function returns nil.
func TimePtrFromUnixSeconds ¶ added in v3.16.0
TimeFromUnixSeconds constructs a *time.Time from the provided UNIX fractional timestamp. If the timestamp is 0, this function returns nil.
func TimePtrFromUpInfo ¶ added in v3.16.0
TimePtrFromUpInfo contructs a *time.Time from the provided uplink metadata information. The GPS timestamp is used if present, then the RxTime. The function returns nil if both timestamps are unavailable. The implementation will attempt to correct GPS time precision errors caused by faulty implementations. In cases in which such errors occur, the timestamp which is closer to the provided reference time is considered correct. TODO: Remove precision errors accounting (use TimePtrFromGPSTime directly). https://github.com/TheThingsNetwork/lorawan-stack/issues/4907
func TimePtrToUpInfoTime ¶ added in v3.16.0
TimePtrToUpInfoTime constructs the RxTime and GPSTime from the provided *time.Time. If the time is nil, this function returns (0.0, 0).
func TimeToGPSTime ¶ added in v3.16.0
TimeToGPSTime contructs a GPS timestamp from the provided time.Time.
func TimeToUnixSeconds ¶ added in v3.16.0
TimeToUnixSeconds constructs a UNIX fractional timestamp from the provided time.Time.
func TimestampFromXTime ¶ added in v3.16.0
TimestampFromXTime constructs the concentrator timestamp associated with the provided XTime.
Types ¶
type DiscoverQuery ¶
type DiscoverQuery struct {
EUI basicstation.EUI `json:"router"`
}
DiscoverQuery contains the unique identifier of the gateway. This message is sent by the gateway.
type DiscoverResponse ¶
type DiscoverResponse struct { EUI basicstation.EUI `json:"router"` Muxs basicstation.EUI `json:"muxs,omitempty"` URI string `json:"uri,omitempty"` Error string `json:"error,omitempty"` }
DiscoverResponse contains the response to the discover query. This message is sent by the Gateway Server.
type DownlinkMessage ¶
type DownlinkMessage struct { DevEUI string `json:"DevEui"` DeviceClass uint `json:"dC"` Diid int64 `json:"diid"` Pdu string `json:"pdu"` RxDelay int `json:"RxDelay"` Rx1DR int `json:"RX1DR"` Rx1Freq int `json:"RX1Freq"` Priority int `json:"priority"` XTime int64 `json:"xtime"` RCtx int64 `json:"rctx"` MuxTime float64 `json:"MuxTime"` }
DownlinkMessage is the LoRaWAN downlink message sent to the LoRa Basics Station.
func (*DownlinkMessage) ToDownlinkMessage ¶
func (dnmsg *DownlinkMessage) ToDownlinkMessage(bandID string) (*ttnpb.DownlinkMessage, error)
ToDownlinkMessage translates the LNS DownlinkMessage "dnmsg" to ttnpb.DownlinkMessage.
type JoinRequest ¶
type JoinRequest struct { MHdr uint `json:"MHdr"` JoinEUI basicstation.EUI `json:"JoinEui"` DevEUI basicstation.EUI `json:"DevEui"` DevNonce uint `json:"DevNonce"` MIC int32 `json:"MIC"` RefTime float64 `json:"RefTime"` RadioMetaData }
JoinRequest is the LoRaWAN Join Request message from LoRa Basics Station protocol.
func (*JoinRequest) FromUplinkMessage ¶
func (req *JoinRequest) FromUplinkMessage(up *ttnpb.UplinkMessage, bandID string) error
FromUplinkMessage extracts fields from ttnpb.UplinkMessage and creates the LoRa Basics Station Join Request Frame.
func (JoinRequest) MarshalJSON ¶
func (req JoinRequest) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
type RadioMetaData ¶
type RadioMetaData struct { DataRate int `json:"DR"` Frequency uint64 `json:"Freq"` UpInfo UpInfo `json:"upinfo"` }
RadioMetaData is a the metadata that is received as part of all upstream messages (except Tx Confirmation).
type TimeSyncRequest ¶ added in v3.16.0
type TimeSyncRequest struct {
TxTime float64 `json:"txtime"`
}
TimeSyncRequest is the time synchronization request from the BasicStation.
func (TimeSyncRequest) MarshalJSON ¶ added in v3.16.0
func (tsr TimeSyncRequest) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (TimeSyncRequest) Response ¶ added in v3.16.0
func (tsr TimeSyncRequest) Response(t time.Time) TimeSyncResponse
Response generates a TimeSyncResponse for this request.
type TimeSyncResponse ¶ added in v3.16.0
type TimeSyncResponse struct { TxTime float64 `json:"txtime,omitempty"` XTime int64 `json:"xtime,omitempty"` GPSTime int64 `json:"gpstime"` MuxTime float64 `json:"MuxTime,omitempty"` }
TimeSyncResponse is the time synchronization response to the BasicStation.
func (TimeSyncResponse) MarshalJSON ¶ added in v3.16.0
func (tsr TimeSyncResponse) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
type TxConfirmation ¶
type TxConfirmation struct { Diid int64 `json:"diid"` DevEUI basicstation.EUI `json:"DevEui"` RCtx int64 `json:"rctx"` XTime int64 `json:"xtime"` TxTime float64 `json:"txtime"` GPSTime int64 `json:"gpstime"` }
TxConfirmation is the LoRaWAN Join Request message from the BasicStation.
func (TxConfirmation) MarshalJSON ¶
func (conf TxConfirmation) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
func (TxConfirmation) ToTxAck ¶
func (conf TxConfirmation) ToTxAck(ctx context.Context, tokens io.DownlinkTokens, receivedAt time.Time) *ttnpb.TxAcknowledgment
ToTxAck converts the LoRa Basics Station TxConfirmation message to ttnpb.TxAcknowledgment
type UpInfo ¶
type UpInfo struct { RxTime float64 `json:"rxtime"` RCtx int64 `json:"rtcx"` XTime int64 `json:"xtime"` GPSTime int64 `json:"gpstime"` RSSI float32 `json:"rssi"` SNR float32 `json:"snr"` }
UpInfo provides additional metadata on each upstream message.
type UplinkDataFrame ¶
type UplinkDataFrame struct { MHdr uint `json:"MHdr"` DevAddr int32 `json:"DevAddr"` FCtrl uint `json:"FCtrl"` FCnt uint `json:"Fcnt"` FOpts string `json:"FOpts"` FPort int `json:"FPort"` FRMPayload string `json:"FRMPayload"` MIC int32 `json:"MIC"` RefTime float64 `json:"RefTime"` RadioMetaData }
UplinkDataFrame is the LoRaWAN Uplink message of the LoRa Basics Station protocol.
func (*UplinkDataFrame) FromUplinkMessage ¶
func (updf *UplinkDataFrame) FromUplinkMessage(up *ttnpb.UplinkMessage, bandID string) error
FromUplinkMessage extracts fields from ttnpb.UplinkMessage and creates the LoRa Basics Station UplinkDataFrame.
func (UplinkDataFrame) MarshalJSON ¶
func (updf UplinkDataFrame) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler.
type Version ¶
type Version struct { Station string `json:"station"` Firmware string `json:"firmware"` Package string `json:"package"` Model string `json:"model"` Protocol int `json:"protocol"` Features string `json:"features,omitempty"` }
Version contains version information. This message is sent by the gateway.
func (Version) IsProduction ¶
IsProduction checks the features field for "prod" and returns true if found. This is then used to set debug options in the router config.
func (Version) MarshalJSON ¶
MarshalJSON implements json.Marshaler.