1- // L2 data link layer
2-
1+ // package netlink provides an interface for L2 data link layer operations.
32package netlink
43
54import (
2019 ErrNotSupported = errors .New ("Not supported" )
2120)
2221
22+ // Event is a network event type passed to the callback registered with NetNotify.
2323type Event int
2424
2525// Network events
@@ -38,6 +38,7 @@ const (
3838 ConnectModeAP // Connect as Wifi Access Point
3939)
4040
41+ // AuthType is the type of WiFi authorization to use when connecting to an access point.
4142type AuthType int
4243
4344// Wifi authorization types. Used when setting up an access point, or
@@ -49,10 +50,11 @@ const (
4950 AuthTypeWPA2Mixed // WPA2/WPA mixed authorization
5051)
5152
53+ // DefaultConnectTimeout is the default timeout for connection attempts. This is used when ConnectParams.ConnectTimeout is zero.
5254const DefaultConnectTimeout = 10 * time .Second
5355
56+ // ConnectParams is the set of parameters used to connect a Netlinker device to a network.
5457type ConnectParams struct {
55-
5658 // Connect mode
5759 ConnectMode
5860
@@ -81,22 +83,23 @@ type ConnectParams struct {
8183 // downed connection or hardware fault and try to recover the
8284 // connection. Set to zero to disable watchodog.
8385 WatchdogTimeout time.Duration
86+
87+ // Hostname to use for this device.
88+ Hostname string
8489}
8590
8691// Netlinker is TinyGo's OSI L2 data link layer interface. Network device
8792// drivers implement Netlinker to expose the device's L2 functionality.
88-
8993type Netlinker interface {
90-
91- // Connect device to network
94+ // NetConnect connects the device to a network
9295 NetConnect (params * ConnectParams ) error
9396
94- // Disconnect device from network
97+ // NetDisconnect disconnects the device from the network
9598 NetDisconnect ()
9699
97- // Notify to register callback for network events
100+ // NetNotify registers a callback for network events
98101 NetNotify (cb func (Event ))
99102
100- // GetHardwareAddr returns device MAC address
103+ // GetHardwareAddr returns the device's MAC address
101104 GetHardwareAddr () (net.HardwareAddr , error )
102105}
0 commit comments