move netdev and netlink into their own packages and out of drivers

This moves the netdev/netlink namespace out of drivers and into their
own packages.  Also, defines netdev and netlink as L3/L4 and L2 OSI
layers, respectively.  Move some L3 functionality from netlink to
netdev (GetIPAddr).

For netlink, add ConnectParams for NetConnect to pass in L2 connection
parameters (ssid, pass, auth_type, etc).  Also adds connection mode
(STA, AP, etc).

For netlink, add SendEth and RecvEthFunc funcs to handle L2 send/recv of
Ethernet pkts.
This commit is contained in:
Scott Feldman
2023-06-09 14:03:03 -07:00
committed by Ron Evans
parent e7d51d3c73
commit 8238f96319
64 changed files with 628 additions and 1419 deletions
+8 -29
View File
@@ -6,8 +6,6 @@
//go:build wioterminal
// +build: wioterminal
package main
import (
@@ -21,9 +19,9 @@ import (
"strings"
"time"
"tinygo.org/x/drivers"
"tinygo.org/x/drivers/ili9341"
"tinygo.org/x/drivers/rtl8720dn"
"tinygo.org/x/drivers/netlink"
"tinygo.org/x/drivers/netlink/probe"
"tinygo.org/x/tinyfont/proggy"
"tinygo.org/x/tinyterm"
)
@@ -34,18 +32,6 @@ var (
)
var (
netcfg = rtl8720dn.Config{
Ssid: ssid,
Passphrase: pass,
En: machine.RTL8720D_CHIP_PU,
Uart: machine.UART3,
Tx: machine.PB24,
Rx: machine.PC24,
Baudrate: 614400,
}
netdev = rtl8720dn.New(&netcfg)
display = ili9341.NewSPI(
machine.SPI3,
machine.LCD_DC,
@@ -66,17 +52,6 @@ var (
font = &proggy.TinySZ8pt7b
)
func notify(e drivers.NetlinkEvent) {
switch e {
case drivers.NetlinkEventNetUp:
fmt.Println("Wifi connection UP")
fmt.Fprintf(terminal, "Wifi connection UP")
case drivers.NetlinkEventNetDown:
fmt.Println("Wifi connection DOWN")
fmt.Fprintf(terminal, "Wifi connection DOWN")
}
}
func main() {
machine.SPI3.Configure(machine.SPIConfig{
@@ -100,9 +75,13 @@ func main() {
fmt.Fprintf(terminal, "Connecting to %s...\r\n", ssid)
netdev.NetNotify(notify)
link, _ := probe.Probe()
if err := netdev.NetConnect(); err != nil {
err := link.NetConnect(&netlink.ConnectParams{
Ssid: ssid,
Passphrase: pass,
})
if err != nil {
log.Fatal(err)
}