Documentation ¶
Index ¶
- Constants
- type Emulator
- func (emu *Emulator) AddNode(node Node) error
- func (emu *Emulator) Clear()
- func (emu *Emulator) GetFreq() float64
- func (emu *Emulator) GetGamma() float64
- func (emu *Emulator) GetKMRange() float64
- func (emu *Emulator) GetNode(id string) Node
- func (emu *Emulator) GetRefDist() float64
- func (emu *Emulator) GetStartTime() int64
- func (emu *Emulator) HasNode(id string) bool
- func (emu *Emulator) NodeIDs() []string
- func (emu *Emulator) Nodes() []Node
- func (emu *Emulator) RemoveNode(id string) error
- func (emu *Emulator) SendMessage(id string, msg []byte) error
- func (emu *Emulator) SetIgnoreCollision(state bool)
- func (emu *Emulator) SetLogger(logger logr.Logger)
- func (emu *Emulator) SetOnEvent(onEvent OnEventFn)
- func (emu *Emulator) SetOnReceived(onReceived OnReceivedFn)
- func (emu *Emulator) SetSNROffset(value int)
- func (emu *Emulator) SetTimeScaling(value int) error
- func (emu *Emulator) SetTraceWriter(writer io.Writer)
- func (emu *Emulator) UpdateNode(id string, updater func(node *Node) error) error
- type Event
- type LogEntry
- type Mobility
- func (m *Mobility) Done()
- func (m *Mobility) GetPause() bool
- func (m *Mobility) SetLoop(val bool) *Mobility
- func (m *Mobility) SetPause(val bool)
- func (m *Mobility) SetTickrate(tickrate float64) *Mobility
- func (m *Mobility) SetTimeScaling(value int) error
- func (m *Mobility) Start()
- func (m *Mobility) Stop()
- type Node
- type OnEventFn
- type OnReceivedFn
- type RxPacket
Constants ¶
const ( EventNodeAdded = Event("NodeAdded") EventNodeRemoved = Event("NodeRemoved") EventNodeUpdated = Event("NodeUpdated") EventCollision = Event("NodeCollision") EventSending = Event("NodeSending") EventReceived = Event("NodeReceived") EventPayloadSizeExceeded = Event("NodePayloadSizeExceeded") )
const ( // CollisionDecodeableLevel describes the dB strength a received packets needs to have compared // to other packets it's collides with. If this is the case the packet can be decoded // even while collision. CollisionDecodeableLevel = 6 // MaxPacketLen specifies the maximum length a single LoRa packet can be. MaxPacketLen = 255 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Emulator ¶
Emulator represents a LoRa emulator.
func New ¶
func New(freq float64, gamma float64, refDist float64, kmRange float64, config lora.PacketConfig) *Emulator
New creates a new emulator with the given frequency, gamma (which is the Log-Distance Path Loss exponent) and LoRa packet config.
func (*Emulator) GetKMRange ¶
func (*Emulator) GetRefDist ¶
func (*Emulator) GetStartTime ¶
func (*Emulator) RemoveNode ¶
RemoveNode removes a node by id.
func (*Emulator) SendMessage ¶
SendMessage starts the data sending for a given node by id.
func (*Emulator) SetIgnoreCollision ¶
SetIgnoreCollision enables or disables the collision detection.
func (*Emulator) SetLogger ¶
SetLogger sets the logger. This will log additional information that are not relevant for the trace.
func (*Emulator) SetOnEvent ¶
SetOnEvent sets the callback that should be called if a event happens in the simulator.
func (*Emulator) SetOnReceived ¶
func (emu *Emulator) SetOnReceived(onReceived OnReceivedFn)
SetOnReceived sets the callback that should be called if a simulated node receives a message.
func (*Emulator) SetSNROffset ¶
SetSNROffset sets a static offset that will be added to the RSSI and the node SNR (SNR = RSSI + Node.SNR + SNROffset).
func (*Emulator) SetTimeScaling ¶
SetTimeScaling (warning: experimental!) lets the simulator run with a time speedup. A value of 10 would mean that 1 second only takes 100ms.
func (*Emulator) SetTraceWriter ¶
SetTraceWriter sets the writer for the trace logs. If no writer was set no trace logs will be emitted.
func (*Emulator) UpdateNode ¶
UpdateNode updates a node by a given id. The updater function will be called with the node and any changes to the node in that function will be set to the emulator.
Don't call any other emulator functions in the updater to avoid deadlocks!
type LogEntry ¶
type LogEntry struct { Time time.Time `json:"time"` Event Event `json:"event"` NodeID string `json:"nodeId"` Data any `json:"data"` }
LogEntry represents an entry in the trace log of the emulator.
type Mobility ¶
type Mobility struct {
// contains filtered or unexported fields
}
Mobility represents a mobility manager that executes a set of mobility commands from the ns-2 format on a LoRaEMU instance.
func NewMobility ¶
NewMobility creates a new mobility manager linked to an emu with the given commands.
func (*Mobility) SetLoop ¶
SetLoop changes if the mobility simulation should restart after finishing. Default is false.
func (*Mobility) SetTickrate ¶
SetTickrate sets the ticks per seconds rate at which the sub-steps of movement will be calculated. 10 means 10 sub-steps per second, 30 means 30 sub-steps per second and so on.
func (*Mobility) SetTimeScaling ¶
SetTimeScaling ets the mobility run with a time speedup. A value of 10 would mean that 1 second only takes 100ms.
type Node ¶
type Node struct { ID string `json:"id"` Online bool `json:"online"` X float64 `json:"x"` Y float64 `json:"y"` Z float64 `json:"z"` TXGain float64 `json:"txGain"` RXSens float64 `json:"rxSens"` SNR int `json:"snr"` Icon string `json:"icon"` Meta map[string]interface{} `json:"meta"` // contains filtered or unexported fields }
Node represents a LoRa device in the emulator.