Documentation
¶
Overview ¶
Package bbc describes a simple Bundle Broadcasting Connector to receive and transmit Bundles over a shared broadcasting medium, e.g., LoRa.
Index ¶
- type Connector
- func (c *Connector) Address() string
- func (c *Connector) Channel() chan cla.ConvergenceStatus
- func (c *Connector) Close()
- func (c *Connector) GetEndpointID() bundle.EndpointID
- func (c *Connector) GetPeerEndpointID() bundle.EndpointID
- func (c *Connector) IsPermanent() bool
- func (c *Connector) Send(bndl *bundle.Bundle) error
- func (c *Connector) Start() (error, bool)
- func (c *Connector) String() string
- type Fragment
- type IncomingTransmission
- type Modem
- type OutgoingTransmission
- type Rf95Modem
- func (rfModem *Rf95Modem) Close() error
- func (rfModem *Rf95Modem) Frequency(frequency float64) error
- func (rfModem *Rf95Modem) Mode(mode rf95.ModemMode) error
- func (rfModem *Rf95Modem) Mtu() (mtu int)
- func (rfModem *Rf95Modem) Receive() (fragment Fragment, err error)
- func (rfModem *Rf95Modem) Send(f Fragment) (err error)
- func (rfModem *Rf95Modem) String() string
- type Transmission
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector implements both a cla.ConvergenceReceiver and cla.ConvergenceSender and supplies the possibility to receive and send Bundles over a Modem. However, based on the broadcasting nature of this CLA, addressing specific recipients is not possible. Furthermore, attributing senders is also not possible.
func NewBundleBroadcastingConnector ¶
NewBundleBroadcastingConnector tries to create a new Bundle Broadcasting Connector based on an bbc URI.
- bbc://rf95modem/dev/ttyUSB0 would open a rf95modem for /dev/ttyUSB0.
- bbc://rf95modem/dev/ttyUSB0?frequency=865.4 would open a rf95modem at 865.4 MHz.
- bbc://rf95modem/dev/ttyUSB0?mode=fast-short-range would open a rf95modem with the FAST+SHORT RANGE mode.
- bbc://rf95modem/dev/ttyUSB0?frequency=865.23&mode=fast-short-range would be all together.
func NewConnector ¶
NewConnector creates a new Connector, wrapping around the given Modem.
func (*Connector) Channel ¶
func (c *Connector) Channel() chan cla.ConvergenceStatus
func (*Connector) GetEndpointID ¶
func (c *Connector) GetEndpointID() bundle.EndpointID
func (*Connector) GetPeerEndpointID ¶
func (c *Connector) GetPeerEndpointID() bundle.EndpointID
func (*Connector) IsPermanent ¶
type Fragment ¶
type Fragment struct { Payload []byte // contains filtered or unexported fields }
Fragment is a part of a Transmission. Multiple Fragments represent an entire Transmission.
For identification, a tuple consisting of a transmission ID, a sequence number, a start bit, an end bit, and a fail bit is used. Because of memory reasons, the whole header has a size of two bytes. First the transmission ID with a length of one byte is given, followed by the two five long sequence number and the three flags, the start, end and fail bits.
The transmission ID is taken from the respective Transmission. If this Fragment is the first of a Transmission, the start bit is set to one. The same applies to the end bit for the last Fragment.
The five bit sequence number represents a simple binary counter, which is incremented for each Fragment. Missing Fragments can be detected this way
The header is followed by the payload. The total data can be as long as the particular MTU allows.
0 1 2 3 4 5 6 7 +---+---+---+---+---+---+---+---+ |Transmission ID | +---+---+---+---+---+---+---+---+ |Seq. No |SB |EB |FB | +---+---+---+---+---+---+---+---+ | | + Payload + | |
func NewFragment ¶
NewFragment creates a new Fragment based on the given arguments.
func ParseFragment ¶
func (Fragment) ReportFailure ¶ added in v0.5.3
ReportFailure creates a failure Fragment based on the current one.
func (Fragment) SequenceNumber ¶
SequenceNumber returns the two bit sequence number.
func (Fragment) TransmissionID ¶
TransmissionID returns the four bit transmission ID.
type IncomingTransmission ¶
type IncomingTransmission struct { Transmission // contains filtered or unexported fields }
IncomingTransmission are the incoming Transmissions from external sources.
func NewIncomingTransmission ¶
func NewIncomingTransmission(f Fragment) (t *IncomingTransmission, err error)
NewIncomingTransmission creates a new IncomingTransmission from a Fragment with the start bit set.
func (*IncomingTransmission) Bundle ¶
func (t *IncomingTransmission) Bundle() (bndl bundle.Bundle, err error)
func (*IncomingTransmission) ReadFragment ¶
func (t *IncomingTransmission) ReadFragment(f Fragment) (finished bool, err error)
ReadFragment processes the next Fragment for this IncomingTransmission.
type Modem ¶
type Modem interface { // Mtu returns the maximum transmission unit for this Modem. Mtu() int // Send broadcasts a Fragment over this Modem. This method might block. Send(Fragment) error // Receive waits for the next Fragment to be received. This method blocks. Receive() (Fragment, error) // Close this Modem. Furthermore, the Receive method should be interrupted. Close() error }
Modem is the interface for possible broadcasting modems. Every Modem must be able to broadcast and receive packets resp. Fragments. The Mtu method indicates the maximum transmission unit (Mtu) for outgoing Fragments.
type OutgoingTransmission ¶
type OutgoingTransmission struct { Transmission // contains filtered or unexported fields }
OutgoingTransmission are the outgoing Transmissions to external sources.
func NewOutgoingTransmission ¶
func NewOutgoingTransmission(transmissionID byte, bndl bundle.Bundle, mtu int) (t *OutgoingTransmission, err error)
NewOutgoingTransmission creates a new OutgoingTransmission for a Bundle.
func (*OutgoingTransmission) WriteFragment ¶
func (t *OutgoingTransmission) WriteFragment() (f Fragment, finished bool, err error)
WriteFragment creates the next Fragment for an OutgoingTransmission.
type Rf95Modem ¶
type Rf95Modem struct {
// contains filtered or unexported fields
}
Rf95Modem is a Modem for transmitting and receiving Fragments by using LoRa over a rf95modem.
func NewRf95Modem ¶
NewRf95Modem creates a new Rf95Modem using a serial connection to the given device, e.g., /dev/ttyUSB0.
func (*Rf95Modem) Frequency ¶
Frequency changes the internal rf95modem's frequency, specified in MHz.
type Transmission ¶
type Transmission struct { TransmissionID byte Payload []byte // contains filtered or unexported fields }
Transmission allows the transmission of data, for example Bundles, between several endpoints.
Due to the maximum transmission unit (MTU), most Transmissions are likely to be fragmented. This results in Fragments. In order to keep the Fragments apart and to associate them with their Transmission, a transmission ID exists. Since the data size is very limited, the transmission ID is reduced to a byte. In order to avoid collisions, the transmission ID should be chosen as randomly or cleverly as possible.
In the following, a distinction is made between incoming and outgoing Transmissions: IncomingTransmission and OutgoingTransmission.
func (Transmission) IsFinished ¶
func (t Transmission) IsFinished() bool
IsFinished indicates a finished Transmission.
func (Transmission) String ¶
func (t Transmission) String() string