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
+3 -24
View File
@@ -6,9 +6,8 @@ import (
"strings"
"time"
"tinygo.org/x/drivers/net"
"tinygo.org/x/drivers/examples/rtl8720dn"
"tinygo.org/x/drivers/net/http"
"tinygo.org/x/drivers/rtl8720dn"
)
// You can override the setting with the init() in another source code.
@@ -53,12 +52,6 @@ CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
-----END CERTIFICATE-----
`
var buf [0x1000]byte
var lastRequestTime time.Time
var conn net.Conn
var adaptor *rtl8720dn.RTL8720DN
func main() {
err := run()
for err != nil {
@@ -68,26 +61,12 @@ func main() {
}
func run() error {
rtl, err := setupRTL8720DN()
rtl8720dn.Debug(debug)
rtl, err := rtl8720dn.SetupAndConnectToAccessPoint(ssid, password, 10*time.Second)
if err != nil {
return err
}
rtl.SetRootCA(&test_root_ca)
net.UseDriver(rtl)
http.SetBuf(buf[:])
err = rtl.ConnectToAccessPoint(ssid, password, 10*time.Second)
if err != nil {
return err
}
ip, subnet, gateway, err := rtl.GetIP()
if err != nil {
return err
}
fmt.Printf("IP Address : %s\r\n", ip)
fmt.Printf("Mask : %s\r\n", subnet)
fmt.Printf("Gateway : %s\r\n", gateway)
// You can send and receive cookies in the following way
// import "tinygo.org/x/drivers/net/http/cookiejar"