mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-18 13:43:58 +00:00
netlink: add Hostname field and some godocs comments
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
+12
-9
@@ -1,5 +1,4 @@
|
|||||||
// L2 data link layer
|
// package netlink provides an interface for L2 data link layer operations.
|
||||||
|
|
||||||
package netlink
|
package netlink
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -20,6 +19,7 @@ var (
|
|||||||
ErrNotSupported = errors.New("Not supported")
|
ErrNotSupported = errors.New("Not supported")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Event is a network event type passed to the callback registered with NetNotify.
|
||||||
type Event int
|
type Event int
|
||||||
|
|
||||||
// Network events
|
// Network events
|
||||||
@@ -38,6 +38,7 @@ const (
|
|||||||
ConnectModeAP // Connect as Wifi Access Point
|
ConnectModeAP // Connect as Wifi Access Point
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// AuthType is the type of WiFi authorization to use when connecting to an access point.
|
||||||
type AuthType int
|
type AuthType int
|
||||||
|
|
||||||
// Wifi authorization types. Used when setting up an access point, or
|
// Wifi authorization types. Used when setting up an access point, or
|
||||||
@@ -49,10 +50,11 @@ const (
|
|||||||
AuthTypeWPA2Mixed // WPA2/WPA mixed authorization
|
AuthTypeWPA2Mixed // WPA2/WPA mixed authorization
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// DefaultConnectTimeout is the default timeout for connection attempts. This is used when ConnectParams.ConnectTimeout is zero.
|
||||||
const DefaultConnectTimeout = 10 * time.Second
|
const DefaultConnectTimeout = 10 * time.Second
|
||||||
|
|
||||||
|
// ConnectParams is the set of parameters used to connect a Netlinker device to a network.
|
||||||
type ConnectParams struct {
|
type ConnectParams struct {
|
||||||
|
|
||||||
// Connect mode
|
// Connect mode
|
||||||
ConnectMode
|
ConnectMode
|
||||||
|
|
||||||
@@ -81,22 +83,23 @@ type ConnectParams struct {
|
|||||||
// downed connection or hardware fault and try to recover the
|
// downed connection or hardware fault and try to recover the
|
||||||
// connection. Set to zero to disable watchodog.
|
// connection. Set to zero to disable watchodog.
|
||||||
WatchdogTimeout time.Duration
|
WatchdogTimeout time.Duration
|
||||||
|
|
||||||
|
// Hostname to use for this device.
|
||||||
|
Hostname string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Netlinker is TinyGo's OSI L2 data link layer interface. Network device
|
// Netlinker is TinyGo's OSI L2 data link layer interface. Network device
|
||||||
// drivers implement Netlinker to expose the device's L2 functionality.
|
// drivers implement Netlinker to expose the device's L2 functionality.
|
||||||
|
|
||||||
type Netlinker interface {
|
type Netlinker interface {
|
||||||
|
// NetConnect connects the device to a network
|
||||||
// Connect device to network
|
|
||||||
NetConnect(params *ConnectParams) error
|
NetConnect(params *ConnectParams) error
|
||||||
|
|
||||||
// Disconnect device from network
|
// NetDisconnect disconnects the device from the network
|
||||||
NetDisconnect()
|
NetDisconnect()
|
||||||
|
|
||||||
// Notify to register callback for network events
|
// NetNotify registers a callback for network events
|
||||||
NetNotify(cb func(Event))
|
NetNotify(cb func(Event))
|
||||||
|
|
||||||
// GetHardwareAddr returns device MAC address
|
// GetHardwareAddr returns the device's MAC address
|
||||||
GetHardwareAddr() (net.HardwareAddr, error)
|
GetHardwareAddr() (net.HardwareAddr, error)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user