Documentation ¶
Index ¶
- Constants
- Variables
- type Backend
- type CompactTime
- type Config
- type DatR
- type ExpandedTime
- type PacketForwarder
- func (f *PacketForwarder) Connect() (err error)
- func (f *PacketForwarder) Disconnect() error
- func (f *PacketForwarder) PublishDownlink(message *types.DownlinkMessage) error
- func (f *PacketForwarder) SubscribeConnect() (<-chan *types.ConnectMessage, error)
- func (f *PacketForwarder) SubscribeDisconnect() (<-chan *types.DisconnectMessage, error)
- func (f *PacketForwarder) SubscribeStatus(gatewayID string) (<-chan *types.StatusMessage, error)
- func (f *PacketForwarder) SubscribeUplink(gatewayID string) (<-chan *types.UplinkMessage, error)
- func (f *PacketForwarder) UnsubscribeConnect() error
- func (f *PacketForwarder) UnsubscribeDisconnect() error
- func (f *PacketForwarder) UnsubscribeStatus(gatewayID string) error
- func (f *PacketForwarder) UnsubscribeUplink(gatewayID string) error
- type PacketType
- type PullACKPacket
- type PullDataPacket
- type PullRespPacket
- type PullRespPayload
- type PushACKPacket
- type PushDataPacket
- type PushDataPayload
- type RSig
- type RXPK
- type Stat
- type TXACKPacket
- type TXACKPayload
- type TXPK
- type TXPKACK
Constants ¶
const ( ProtocolVersion1 uint8 = 0x01 ProtocolVersion2 uint8 = 0x02 )
Protocol versions
Variables ¶
var (
ErrInvalidProtocolVersion = errors.New("gateway: invalid protocol version")
)
Errors
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend implements a Semtech gateway backend.
func NewBackend ¶
func NewBackend(config Config, onNew func(lorawan.EUI64) error, onDelete func(lorawan.EUI64) error, skipCRCCheck bool) (*Backend, error)
NewBackend creates a new backend.
func (*Backend) RXPacketChan ¶
func (b *Backend) RXPacketChan() chan *types.UplinkMessage
RXPacketChan returns the channel containing the received RX packets.
func (*Backend) Send ¶
func (b *Backend) Send(txPacket *types.DownlinkMessage) error
Send sends the given packet to the gateway.
func (*Backend) StatsChan ¶
func (b *Backend) StatsChan() chan *types.StatusMessage
StatsChan returns the channel containg the received gateway stats.
type CompactTime ¶
CompactTime implements time.Time but (un)marshals to and from ISO 8601 'compact' format.
func (CompactTime) MarshalJSON ¶
func (t CompactTime) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*CompactTime) UnmarshalJSON ¶
func (t *CompactTime) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type DatR ¶
DatR implements the data rate which can be either a string (LoRa identifier) or an unsigned integer in case of FSK (bits per second).
func (DatR) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*DatR) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type ExpandedTime ¶
ExpandedTime implements time.Time but (un)marshals to and from ISO 8601 'expanded' format.
func (ExpandedTime) MarshalJSON ¶
func (t ExpandedTime) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*ExpandedTime) UnmarshalJSON ¶
func (t *ExpandedTime) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.
type PacketForwarder ¶
type PacketForwarder struct {
// contains filtered or unexported fields
}
PacketForwarder backend based on github.com/brocaar/lora-gateway-bridge
func New ¶
func New(config Config, ctx log.Interface) *PacketForwarder
New returns a new Dummy backend
func (*PacketForwarder) Connect ¶
func (f *PacketForwarder) Connect() (err error)
Connect implements the Southbound interface
func (*PacketForwarder) Disconnect ¶
func (f *PacketForwarder) Disconnect() error
Disconnect implements the Southbound interface
func (*PacketForwarder) PublishDownlink ¶
func (f *PacketForwarder) PublishDownlink(message *types.DownlinkMessage) error
PublishDownlink implements the Southbound interface
func (*PacketForwarder) SubscribeConnect ¶
func (f *PacketForwarder) SubscribeConnect() (<-chan *types.ConnectMessage, error)
SubscribeConnect implements the Southbound interface
func (*PacketForwarder) SubscribeDisconnect ¶
func (f *PacketForwarder) SubscribeDisconnect() (<-chan *types.DisconnectMessage, error)
SubscribeDisconnect implements the Southbound interface
func (*PacketForwarder) SubscribeStatus ¶
func (f *PacketForwarder) SubscribeStatus(gatewayID string) (<-chan *types.StatusMessage, error)
SubscribeStatus implements the Southbound interface
func (*PacketForwarder) SubscribeUplink ¶
func (f *PacketForwarder) SubscribeUplink(gatewayID string) (<-chan *types.UplinkMessage, error)
SubscribeUplink implements the Southbound interface
func (*PacketForwarder) UnsubscribeConnect ¶
func (f *PacketForwarder) UnsubscribeConnect() error
UnsubscribeConnect implements the Southbound interface
func (*PacketForwarder) UnsubscribeDisconnect ¶
func (f *PacketForwarder) UnsubscribeDisconnect() error
UnsubscribeDisconnect implements the Southbound interface
func (*PacketForwarder) UnsubscribeStatus ¶
func (f *PacketForwarder) UnsubscribeStatus(gatewayID string) error
UnsubscribeStatus implements the Southbound interface
func (*PacketForwarder) UnsubscribeUplink ¶
func (f *PacketForwarder) UnsubscribeUplink(gatewayID string) error
UnsubscribeUplink implements the Southbound interface
type PacketType ¶
type PacketType byte
PacketType defines the packet type.
const ( PushData PacketType = iota PushACK PullData PullResp PullACK TXACK )
Available packet types
func GetPacketType ¶
func GetPacketType(data []byte) (PacketType, error)
GetPacketType returns the packet type for the given packet data.
func (PacketType) String ¶
func (i PacketType) String() string
type PullACKPacket ¶
PullACKPacket is used by the server to confirm that the network route is open and that the server can send PULL_RESP packets at any time.
func (PullACKPacket) MarshalBinary ¶
func (p PullACKPacket) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*PullACKPacket) UnmarshalBinary ¶
func (p *PullACKPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type PullDataPacket ¶
PullDataPacket is used by the gateway to poll data from the server.
func (PullDataPacket) MarshalBinary ¶
func (p PullDataPacket) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*PullDataPacket) UnmarshalBinary ¶
func (p *PullDataPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type PullRespPacket ¶
type PullRespPacket struct { ProtocolVersion uint8 RandomToken uint16 Payload PullRespPayload }
PullRespPacket is used by the server to send RF packets and associated metadata that will have to be emitted by the gateway.
func (PullRespPacket) MarshalBinary ¶
func (p PullRespPacket) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*PullRespPacket) UnmarshalBinary ¶
func (p *PullRespPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type PullRespPayload ¶
type PullRespPayload struct {
TXPK TXPK `json:"txpk"`
}
PullRespPayload represents the downstream JSON data structure.
type PushACKPacket ¶
PushACKPacket is used by the server to acknowledge immediately all the PUSH_DATA packets received.
func (PushACKPacket) MarshalBinary ¶
func (p PushACKPacket) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*PushACKPacket) UnmarshalBinary ¶
func (p *PushACKPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type PushDataPacket ¶
type PushDataPacket struct { ProtocolVersion uint8 RandomToken uint16 GatewayMAC lorawan.EUI64 Payload PushDataPayload }
PushDataPacket type is used by the gateway mainly to forward the RF packets received, and associated metadata, to the server.
func (PushDataPacket) MarshalBinary ¶
func (p PushDataPacket) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object in binary form.
func (*PushDataPacket) UnmarshalBinary ¶
func (p *PushDataPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type PushDataPayload ¶
type PushDataPayload struct { RXPK []RXPK `json:"rxpk,omitempty"` Stat *Stat `json:"stat,omitempty"` }
PushDataPayload represents the upstream JSON data structure.
type RSig ¶
type RSig struct { Ant uint8 `json:"ant"` // Antenna number on which signal has been received Chan uint8 `json:"chan"` // Concentrator "IF" channel used for RX (unsigned integer) RSSIC int16 `json:"rssic"` // RSSI in dBm of the channel (signed integer, 1 dB precision) RSSIS int16 `json:"rssis"` // RSSI in dBm of the signal (signed integer, 1 DB precision) (Optional) RSSISD uint16 `json:"rssisd"` // Standard deviation of RSSI during preamble (unsigned integer) (Optional) LSNR float64 `json:"lsnr"` // Lora SNR ratio in dB (signed float, 0.1 dB precision) ETime string `json:"etime"` // Encrypted timestamp, ns precision [0..999999999] (Optional) FTime int64 `json:"ftime"` // Fine timestamp, ns precision [0..999999999] (Optional) FOff int32 `json:"foff"` // Frequency offset in Hz [-125kHz..+125Khz] (Optional) }
RSig contains the metadata associated with the received signal
type RXPK ¶
type RXPK struct { Time CompactTime `json:"time"` // UTC time of pkt RX, us precision, ISO 8601 'compact' format (e.g. 2013-03-31T16:21:17.528002Z) Tmst uint32 `json:"tmst"` // Internal timestamp of "RX finished" event (32b unsigned) Freq float64 `json:"freq"` // RX central frequency in MHz (unsigned float, Hz precision) Chan uint8 `json:"chan"` // Concentrator "IF" channel used for RX (unsigned integer) RFCh uint8 `json:"rfch"` // Concentrator "RF chain" used for RX (unsigned integer) Stat int8 `json:"stat"` // CRC status: 1 = OK, -1 = fail, 0 = no CRC Modu string `json:"modu"` // Modulation identifier "LORA" or "FSK" DatR DatR `json:"datr"` // LoRa datarate identifier (eg. SF12BW500) || FSK datarate (unsigned, in bits per second) CodR string `json:"codr"` // LoRa ECC coding rate identifier RSSI int16 `json:"rssi"` // RSSI in dBm (signed integer, 1 dB precision) LSNR float64 `json:"lsnr"` // Lora SNR ratio in dB (signed float, 0.1 dB precision) Size uint16 `json:"size"` // RF packet payload size in bytes (unsigned integer) Data string `json:"data"` // Base64 encoded RF packet payload, padded RSig []RSig `json:"rsig"` // Received signal information, per antenna (Optional) }
RXPK contain a RF packet and associated metadata.
type Stat ¶
type Stat struct { Time ExpandedTime `json:"time"` // UTC 'system' time of the gateway, ISO 8601 'expanded' format (e.g 2014-01-12 08:59:28 GMT) Boot ExpandedTime `json:"boot"` // UTC 'boot' time of the gateway, ISO 8601 'expanded' format (e.g 2014-01-12 08:59:28 GMT) Lati float64 `json:"lati"` // GPS latitude of the gateway in degree (float, N is +) Long float64 `json:"long"` // GPS latitude of the gateway in degree (float, E is +) Alti int32 `json:"alti"` // GPS altitude of the gateway in meter RX (integer) RXNb uint32 `json:"rxnb"` // Number of radio packets received (unsigned integer) RXOK uint32 `json:"rxok"` // Number of radio packets received with a valid PHY CRC RXFW uint32 `json:"rxfw"` // Number of radio packets forwarded (unsigned integer) ACKR float64 `json:"ackr"` // Percentage of upstream datagrams that were acknowledged DWNb uint32 `json:"dwnb"` // Number of downlink datagrams received (unsigned integer) TXNb uint32 `json:"txnb"` // Number of packets emitted (unsigned integer) LMOK uint32 `json:"lmok"` // Number of packets received from link testing mote, with CRC OK (unsigned inteter) LMST uint32 `json:"lmst"` // Sequence number of the first packet received from link testing mote (unsigned integer) LMNW uint32 `json:"lmnw"` // Sequence number of the last packet received from link testing mote (unsigned integer) LPPS uint32 `json:"lpps"` // Number of lost PPS pulses (unsigned integer) Temp int32 `json:"temp"` // Temperature of the Gateway (signed integer) FPGA uint32 `json:"fpga"` // Version of Gateway FPGA (unsigned integer) DSP uint32 `json:"dsp"` // Version of Gateway DSP software (unsigned interger) HAL string `json:"hal"` // Version of Gateway driver (format X.X.X) // Informal fields Pfrm string `json:"pfrm"` // Platform definition Mail string `json:"mail"` // Email address of gateway operator Desc string `json:"desc"` // Public description of this device }
Stat contains the status of the gateway.
type TXACKPacket ¶
type TXACKPacket struct { ProtocolVersion uint8 RandomToken uint16 GatewayMAC lorawan.EUI64 Payload *TXACKPayload }
TXACKPacket is used by the gateway to send a feedback to the server to inform if a downlink request has been accepted or rejected by the gateway.
func (TXACKPacket) MarshalBinary ¶
func (p TXACKPacket) MarshalBinary() ([]byte, error)
MarshalBinary marshals the object into binary form.
func (*TXACKPacket) UnmarshalBinary ¶
func (p *TXACKPacket) UnmarshalBinary(data []byte) error
UnmarshalBinary decodes the object from binary form.
type TXACKPayload ¶
type TXACKPayload struct {
TXPKACK TXPKACK `json:"txpk_ack"`
}
TXACKPayload contains the TXACKPacket payload.
type TXPK ¶
type TXPK struct { Imme bool `json:"imme"` // Send packet immediately (will ignore tmst & time) Tmst uint32 `json:"tmst,omitempty"` // Send packet on a certain timestamp value (will ignore time) Time *CompactTime `json:"time,omitempty"` // Send packet at a certain time (GPS synchronization required) Freq float64 `json:"freq"` // TX central frequency in MHz (unsigned float, Hz precision) RFCh uint8 `json:"rfch"` // Concentrator "RF chain" used for TX (unsigned integer) Powe uint8 `json:"powe"` // TX output power in dBm (unsigned integer, dBm precision) Modu string `json:"modu"` // Modulation identifier "LORA" or "FSK" DatR DatR `json:"datr"` // LoRa datarate identifier (eg. SF12BW500) || FSK datarate (unsigned, in bits per second) CodR string `json:"codr,omitempty"` // LoRa ECC coding rate identifier FDev uint16 `json:"fdev,omitempty"` // FSK frequency deviation (unsigned integer, in Hz) IPol bool `json:"ipol"` // Lora modulation polarization inversion Prea uint16 `json:"prea,omitempty"` // RF preamble size (unsigned integer) Size uint16 `json:"size"` // RF packet payload size in bytes (unsigned integer) NCRC bool `json:"ncrc,omitempty"` // If true, disable the CRC of the physical layer (optional) Data string `json:"data"` // Base64 encoded RF packet payload, padding optional }
TXPK contains a RF packet to be emitted and associated metadata.