rtl8720dn: add SetupAndConnectToAccessPoint()

This commit is contained in:
sago35
2022-07-23 10:07:22 +09:00
parent ca34b93e5d
commit f94ef9e535
9 changed files with 52 additions and 363 deletions
+21
View File
@@ -9,12 +9,15 @@ import (
"runtime/interrupt"
"time"
"tinygo.org/x/drivers/net"
"tinygo.org/x/drivers/net/http"
"tinygo.org/x/drivers/rtl8720dn"
)
var (
uart UARTx
debug bool
buf [0x1000]byte
)
func handleInterrupt(interrupt.Interrupt) {
@@ -55,6 +58,24 @@ func Setup() (*rtl8720dn.RTL8720DN, error) {
return rtl, nil
}
func SetupAndConnectToAccessPoint(ssid, pass string, timeout time.Duration) (*rtl8720dn.RTL8720DN, error) {
rtl, err := Setup()
if err != nil {
return nil, err
}
err = rtl.ConnectToAccessPoint(ssid, pass, 10*time.Second)
if err != nil {
return rtl, err
}
net.UseDriver(rtl)
http.UseDriver(rtl)
http.SetBuf(buf[:])
return rtl, nil
}
// Wait for user to open serial console
func waitSerial() {
for !machine.Serial.DTR() {