Documentation ¶
Index ¶
- Constants
- Variables
- func NewSimulationController(sim *Simulation) visualize.SimulationController
- type CmdRunner
- type Config
- type LeaderData
- type Node
- func (node *Node) AssurePrompt()
- func (node *Node) Command(cmd string, timeout time.Duration) []string
- func (node *Node) CommandExpectEnabledOrDisabled(cmd string, timeout time.Duration) bool
- func (node *Node) CommandExpectHex(cmd string, timeout time.Duration) int
- func (node *Node) CommandExpectInt(cmd string, timeout time.Duration) int
- func (node *Node) CommandExpectNone(cmd string, timeout time.Duration)
- func (node *Node) CommandExpectString(cmd string, timeout time.Duration) string
- func (node *Node) ConfigActiveDataset(channel int, networkkey string, panid uint16)
- func (node *Node) DumpStat() string
- func (node *Node) Exit() error
- func (node *Node) FactoryReset()
- func (node *Node) GetChannel() int
- func (node *Node) GetChildList() (childlist []int)
- func (node *Node) GetChildTable()
- func (node *Node) GetChildTimeout() int
- func (node *Node) GetContextReuseDelay() int
- func (node *Node) GetEui64() string
- func (node *Node) GetExtAddr() uint64
- func (node *Node) GetExtPanid() string
- func (node *Node) GetIfconfig() string
- func (node *Node) GetIpAddr() []string
- func (node *Node) GetIpAddrLinkLocal() []string
- func (node *Node) GetIpAddrMleid() []string
- func (node *Node) GetIpAddrRloc() []string
- func (node *Node) GetIpMaddr() []string
- func (node *Node) GetIpMaddrPromiscuous() bool
- func (node *Node) GetJoinerPort() int
- func (node *Node) GetKeySequenceCounter() int
- func (node *Node) GetKeySequenceGuardTime() int
- func (node *Node) GetLeaderData() (leaderData LeaderData)
- func (node *Node) GetLeaderPartitionId() int
- func (node *Node) GetLeaderWeight() int
- func (node *Node) GetMode() string
- func (node *Node) GetNetworkKey() string
- func (node *Node) GetNetworkName() string
- func (node *Node) GetPanid() uint16
- func (node *Node) GetPromiscuous() bool
- func (node *Node) GetRloc16() uint16
- func (node *Node) GetRouterDowngradeThreshold() int
- func (node *Node) GetRouterEligible() bool
- func (node *Node) GetRouterSelectionJitter() int
- func (node *Node) GetRouterUpgradeThreshold() int
- func (node *Node) GetSingleton() bool
- func (node *Node) GetState() string
- func (node *Node) GetVersion() string
- func (node *Node) IfconfigDown()
- func (node *Node) IfconfigUp()
- func (node *Node) IpMaddrPromiscuousDisable()
- func (node *Node) IpMaddrPromiscuousEnable()
- func (node *Node) IsFED() bool
- func (node *Node) Ping(addr string, payloadSize int, count int, interval int, hopLimit int)
- func (node *Node) PromiscuousDisable()
- func (node *Node) PromiscuousEnable()
- func (node *Node) Reset()
- func (node *Node) RouterEligibleDisable()
- func (node *Node) RouterEligibleEnable()
- func (node *Node) SetChannel(ch int)
- func (node *Node) SetChildTimeout(timeout int)
- func (node *Node) SetContextReuseDelay(delay int)
- func (node *Node) SetEui64(eui64 string)
- func (node *Node) SetExtAddr(extaddr uint64)
- func (node *Node) SetExtPanid(extpanid string)
- func (node *Node) SetJoinerPort(port int)
- func (node *Node) SetKeySequenceCounter(counter int)
- func (node *Node) SetKeySequenceGuardTime(guardtime int)
- func (node *Node) SetLeaderPartitionId(partitionid int)
- func (node *Node) SetLeaderWeight(weight int)
- func (node *Node) SetMode(mode string)
- func (node *Node) SetNetworkKey(key string)
- func (node *Node) SetNetworkName(name string)
- func (node *Node) SetPanid(panid uint16)
- func (node *Node) SetRouterDowngradeThreshold(timeout int)
- func (node *Node) SetRouterSelectionJitter(timeout int)
- func (node *Node) SetRouterUpgradeThreshold(timeout int)
- func (node *Node) SetupNetworkParameters(sim *Simulation)
- func (node *Node) Start()
- func (node *Node) Stop()
- func (node *Node) String() string
- func (node *Node) ThreadStart()
- func (node *Node) ThreadStop()
- func (node *Node) TryExpectLine(line interface{}, timeout time.Duration) (bool, []string)
- type NodeConfig
- type NodeUartType
- type Simulation
- func (s *Simulation) AddNode(cfg *NodeConfig) (*Node, error)
- func (s *Simulation) Channel() int
- func (s *Simulation) CountDown(duration time.Duration, text string)
- func (s *Simulation) DeleteNode(nodeid NodeId) error
- func (s *Simulation) Dispatcher() *dispatcher.Dispatcher
- func (s *Simulation) GetNetworkInfo() visualize.NetworkInfo
- func (s *Simulation) GetSpeed() float64
- func (s *Simulation) Go(duration time.Duration) <-chan struct{}
- func (s *Simulation) IsStopped() bool
- func (s *Simulation) MoveNodeTo(nodeid NodeId, x, y int)
- func (s *Simulation) NetworkKey() string
- func (s *Simulation) Nodes() map[NodeId]*Node
- func (s *Simulation) OnNodeFail(nodeid NodeId)
- func (s *Simulation) OnNodeRecover(nodeid NodeId)
- func (s *Simulation) OnUartWrite(nodeid NodeId, data []byte)
- func (s *Simulation) Panid() uint16
- func (s *Simulation) PostAsync(trivial bool, f func())
- func (s *Simulation) Run()
- func (s *Simulation) SetCmdRunner(cmdRunner CmdRunner)
- func (s *Simulation) SetNetworkInfo(networkInfo visualize.NetworkInfo)
- func (s *Simulation) SetNodeFailed(id NodeId, failed bool)
- func (s *Simulation) SetSpeed(speed float64)
- func (s *Simulation) SetTitleInfo(titleInfo visualize.TitleInfo)
- func (s *Simulation) SetVisualizer(vis visualize.Visualizer)
- func (s *Simulation) ShowDemoLegend(x int, y int, title string)
- func (s *Simulation) Stop()
- func (s *Simulation) VisitNodesInOrder(cb func(node *Node))
Constants ¶
View Source
const ( DefaultChannel = 11 DefaultChannelMask = 0x07fff800 DefaultExtPanid = "dead00beef00cafe" DefaultMeshLocalPrefix = "fdde:ad00:beef:0::" DefaultNetworkKey = "00112233445566778899aabbccddeeff" DefaultNetworkName = "otns" DefaultPanid = 0xface DefaultPskc = "3aa55f91ca47d1e4e71a08cb35e91591" DefaultSecurityPolicy = "672 onrc" )
View Source
const (
DefaultCommandTimeout = time.Second * 10
)
Variables ¶
View Source
var (
DoneOrErrorRegexp = regexp.MustCompile(`(Done|Error \d+: .*)`)
)
Functions ¶
func NewSimulationController ¶
func NewSimulationController(sim *Simulation) visualize.SimulationController
Types ¶
type Config ¶
type Config struct { NetworkKey string Panid uint16 Channel int OtCliPath string Speed float64 ReadOnly bool RawMode bool Real bool DispatcherHost string DispatcherPort int DumpPackets bool }
func DefaultConfig ¶
func DefaultConfig() *Config
type LeaderData ¶
type Node ¶
type Node struct { S *Simulation Id int // contains filtered or unexported fields }
func (*Node) AssurePrompt ¶
func (node *Node) AssurePrompt()
func (*Node) CommandExpectEnabledOrDisabled ¶
func (*Node) CommandExpectHex ¶
func (*Node) CommandExpectInt ¶
func (*Node) CommandExpectNone ¶
func (*Node) CommandExpectString ¶
func (*Node) ConfigActiveDataset ¶
func (*Node) FactoryReset ¶
func (node *Node) FactoryReset()
func (*Node) GetChannel ¶
func (*Node) GetChildList ¶
func (*Node) GetChildTable ¶
func (node *Node) GetChildTable()
func (*Node) GetChildTimeout ¶
func (*Node) GetContextReuseDelay ¶
func (*Node) GetExtAddr ¶
func (*Node) GetExtPanid ¶
func (*Node) GetIfconfig ¶
func (*Node) GetIpAddrLinkLocal ¶
func (*Node) GetIpAddrMleid ¶
func (*Node) GetIpAddrRloc ¶
func (*Node) GetIpMaddr ¶
func (*Node) GetIpMaddrPromiscuous ¶
func (*Node) GetJoinerPort ¶
func (*Node) GetKeySequenceCounter ¶
func (*Node) GetKeySequenceGuardTime ¶
func (*Node) GetLeaderData ¶
func (node *Node) GetLeaderData() (leaderData LeaderData)
func (*Node) GetLeaderPartitionId ¶
func (*Node) GetLeaderWeight ¶
func (*Node) GetNetworkKey ¶
func (*Node) GetNetworkName ¶
func (*Node) GetPromiscuous ¶
func (*Node) GetRouterDowngradeThreshold ¶
func (*Node) GetRouterEligible ¶
func (*Node) GetRouterSelectionJitter ¶
func (*Node) GetRouterUpgradeThreshold ¶
func (*Node) GetSingleton ¶
func (*Node) GetVersion ¶
func (*Node) IfconfigDown ¶
func (node *Node) IfconfigDown()
func (*Node) IfconfigUp ¶
func (node *Node) IfconfigUp()
func (*Node) IpMaddrPromiscuousDisable ¶
func (node *Node) IpMaddrPromiscuousDisable()
func (*Node) IpMaddrPromiscuousEnable ¶
func (node *Node) IpMaddrPromiscuousEnable()
func (*Node) PromiscuousDisable ¶
func (node *Node) PromiscuousDisable()
func (*Node) PromiscuousEnable ¶
func (node *Node) PromiscuousEnable()
func (*Node) RouterEligibleDisable ¶
func (node *Node) RouterEligibleDisable()
func (*Node) RouterEligibleEnable ¶
func (node *Node) RouterEligibleEnable()
func (*Node) SetChannel ¶
func (*Node) SetChildTimeout ¶
func (*Node) SetContextReuseDelay ¶
func (*Node) SetExtAddr ¶
func (*Node) SetExtPanid ¶
func (*Node) SetJoinerPort ¶
func (*Node) SetKeySequenceCounter ¶
func (*Node) SetKeySequenceGuardTime ¶
func (*Node) SetLeaderPartitionId ¶
func (*Node) SetLeaderWeight ¶
func (*Node) SetNetworkKey ¶
func (*Node) SetNetworkName ¶
func (*Node) SetRouterDowngradeThreshold ¶
func (*Node) SetRouterSelectionJitter ¶
func (*Node) SetRouterUpgradeThreshold ¶
func (*Node) SetupNetworkParameters ¶
func (node *Node) SetupNetworkParameters(sim *Simulation)
func (*Node) ThreadStart ¶
func (node *Node) ThreadStart()
func (*Node) ThreadStop ¶
func (node *Node) ThreadStop()
type NodeConfig ¶
type NodeConfig struct { ID int X, Y int IsMtd bool IsRouter bool RxOffWhenIdle bool RadioRange int ExecutablePath string Restore bool }
func DefaultNodeConfig ¶
func DefaultNodeConfig() *NodeConfig
type NodeUartType ¶
type NodeUartType int
const ( NodeUartTypeUndefined NodeUartType = iota NodeUartTypeRealTime NodeUartType = iota NodeUartTypeVirtualTime NodeUartType = iota )
type Simulation ¶
type Simulation struct {
// contains filtered or unexported fields
}
func NewSimulation ¶
func NewSimulation(ctx *progctx.ProgCtx, cfg *Config, dispatcherCfg *dispatcher.Config) (*Simulation, error)
func (*Simulation) AddNode ¶
func (s *Simulation) AddNode(cfg *NodeConfig) (*Node, error)
func (*Simulation) Channel ¶
func (s *Simulation) Channel() int
func (*Simulation) DeleteNode ¶
func (s *Simulation) DeleteNode(nodeid NodeId) error
func (*Simulation) Dispatcher ¶
func (s *Simulation) Dispatcher() *dispatcher.Dispatcher
func (*Simulation) GetNetworkInfo ¶
func (s *Simulation) GetNetworkInfo() visualize.NetworkInfo
func (*Simulation) GetSpeed ¶
func (s *Simulation) GetSpeed() float64
func (*Simulation) Go ¶
func (s *Simulation) Go(duration time.Duration) <-chan struct{}
func (*Simulation) IsStopped ¶
func (s *Simulation) IsStopped() bool
IsStopped returns if the simulation is already stopped.
func (*Simulation) MoveNodeTo ¶
func (s *Simulation) MoveNodeTo(nodeid NodeId, x, y int)
func (*Simulation) NetworkKey ¶
func (s *Simulation) NetworkKey() string
func (*Simulation) Nodes ¶
func (s *Simulation) Nodes() map[NodeId]*Node
func (*Simulation) OnNodeFail ¶
func (s *Simulation) OnNodeFail(nodeid NodeId)
func (*Simulation) OnNodeRecover ¶
func (s *Simulation) OnNodeRecover(nodeid NodeId)
func (*Simulation) OnUartWrite ¶
func (s *Simulation) OnUartWrite(nodeid NodeId, data []byte)
OnUartWrite notifies the simulation that a node has received some data from UART. It is part of implementation of dispatcher.CallbackHandler.
func (*Simulation) Panid ¶
func (s *Simulation) Panid() uint16
func (*Simulation) PostAsync ¶
func (s *Simulation) PostAsync(trivial bool, f func())
func (*Simulation) Run ¶
func (s *Simulation) Run()
func (*Simulation) SetCmdRunner ¶
func (s *Simulation) SetCmdRunner(cmdRunner CmdRunner)
func (*Simulation) SetNetworkInfo ¶
func (s *Simulation) SetNetworkInfo(networkInfo visualize.NetworkInfo)
func (*Simulation) SetNodeFailed ¶
func (s *Simulation) SetNodeFailed(id NodeId, failed bool)
func (*Simulation) SetSpeed ¶
func (s *Simulation) SetSpeed(speed float64)
func (*Simulation) SetTitleInfo ¶
func (s *Simulation) SetTitleInfo(titleInfo visualize.TitleInfo)
func (*Simulation) SetVisualizer ¶
func (s *Simulation) SetVisualizer(vis visualize.Visualizer)
func (*Simulation) ShowDemoLegend ¶
func (s *Simulation) ShowDemoLegend(x int, y int, title string)
func (*Simulation) Stop ¶
func (s *Simulation) Stop()
func (*Simulation) VisitNodesInOrder ¶
func (s *Simulation) VisitNodesInOrder(cb func(node *Node))
Click to show internal directories.
Click to hide internal directories.