mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-19 14:14:00 +00:00
espat: change Response() method to use a passed-in timeout value instead of fixed pauses.
Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
+13
-10
@@ -50,7 +50,7 @@ func (d *Device) Connected() bool {
|
|||||||
d.Execute(Test)
|
d.Execute(Test)
|
||||||
|
|
||||||
// handle response here, should include "OK"
|
// handle response here, should include "OK"
|
||||||
r := d.Response()
|
r := d.Response(100)
|
||||||
if strings.Contains(string(r), "OK") {
|
if strings.Contains(string(r), "OK") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ func (d Device) Set(cmd, params string) error {
|
|||||||
// Version returns the ESP8266/ESP32 firmware version info.
|
// Version returns the ESP8266/ESP32 firmware version info.
|
||||||
func (d Device) Version() []byte {
|
func (d Device) Version() []byte {
|
||||||
d.Execute(Version)
|
d.Execute(Version)
|
||||||
return d.Response()
|
return d.Response(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Echo sets the ESP8266/ESP32 echo setting.
|
// Echo sets the ESP8266/ESP32 echo setting.
|
||||||
@@ -104,7 +104,7 @@ func (d Device) Echo(set bool) {
|
|||||||
d.Execute(EchoConfigOff)
|
d.Execute(EchoConfigOff)
|
||||||
}
|
}
|
||||||
// TODO: check for success
|
// TODO: check for success
|
||||||
d.Response()
|
d.Response(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset restarts the ESP8266/ESP32 firmware. Due to how the baud rate changes,
|
// Reset restarts the ESP8266/ESP32 firmware. Due to how the baud rate changes,
|
||||||
@@ -112,13 +112,13 @@ func (d Device) Echo(set bool) {
|
|||||||
// what you are doing when you call this.
|
// what you are doing when you call this.
|
||||||
func (d Device) Reset() {
|
func (d Device) Reset() {
|
||||||
d.Execute(Restart)
|
d.Execute(Restart)
|
||||||
d.Response()
|
d.Response(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadSocket returns the data that has already been read in from the responses.
|
// ReadSocket returns the data that has already been read in from the responses.
|
||||||
func (d *Device) ReadSocket(b []byte) (n int, err error) {
|
func (d *Device) ReadSocket(b []byte) (n int, err error) {
|
||||||
// make sure no data in buffer
|
// make sure no data in buffer
|
||||||
d.Response()
|
d.Response(100)
|
||||||
|
|
||||||
count := len(b)
|
count := len(b)
|
||||||
if len(b) >= len(d.socketdata) {
|
if len(b) >= len(d.socketdata) {
|
||||||
@@ -137,8 +137,11 @@ func (d *Device) ReadSocket(b []byte) (n int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Response gets the next response bytes from the ESP8266/ESP32.
|
// Response gets the next response bytes from the ESP8266/ESP32.
|
||||||
func (d *Device) Response() []byte {
|
// The call will retry for up to timeout milliseconds before returning nothing.
|
||||||
var i, retries int
|
func (d *Device) Response(timeout int) []byte {
|
||||||
|
var i int
|
||||||
|
pause := 10 // pause to wait for 10 ms
|
||||||
|
retries := timeout / pause
|
||||||
|
|
||||||
header := make([]byte, 2)
|
header := make([]byte, 2)
|
||||||
for {
|
for {
|
||||||
@@ -174,13 +177,13 @@ func (d *Device) Response() []byte {
|
|||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
retries++
|
retries--
|
||||||
if retries > 2 {
|
if retries == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// pause to make sure is no more data to be read
|
// pause to make sure is no more data to be read
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(time.Duration(pause) * time.Millisecond)
|
||||||
}
|
}
|
||||||
return d.response[:i]
|
return d.response[:i]
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-23
@@ -4,7 +4,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -18,8 +17,7 @@ const (
|
|||||||
// GetDNS returns the IP address for a domain name.
|
// GetDNS returns the IP address for a domain name.
|
||||||
func (d *Device) GetDNS(domain string) (IP, error) {
|
func (d *Device) GetDNS(domain string) (IP, error) {
|
||||||
d.Set(TCPDNSLookup, "\""+domain+"\"")
|
d.Set(TCPDNSLookup, "\""+domain+"\"")
|
||||||
time.Sleep(1000 * time.Millisecond)
|
r := strings.Split(string(d.Response(1000)), ":")
|
||||||
r := strings.Split(string(d.Response()), ":")
|
|
||||||
if len(r) != 2 {
|
if len(r) != 2 {
|
||||||
return nil, errors.New("Invalid domain lookup result")
|
return nil, errors.New("Invalid domain lookup result")
|
||||||
}
|
}
|
||||||
@@ -33,8 +31,7 @@ func (d *Device) ConnectTCPSocket(addr, port string) error {
|
|||||||
protocol := "TCP"
|
protocol := "TCP"
|
||||||
val := "\"" + protocol + "\",\"" + addr + "\"," + port + ",120"
|
val := "\"" + protocol + "\",\"" + addr + "\"," + port + ",120"
|
||||||
d.Set(TCPConnect, val)
|
d.Set(TCPConnect, val)
|
||||||
time.Sleep(1000 * time.Millisecond)
|
r := d.Response(1000)
|
||||||
r := d.Response()
|
|
||||||
if strings.Contains(string(r), "OK") {
|
if strings.Contains(string(r), "OK") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -46,8 +43,7 @@ func (d *Device) ConnectUDPSocket(addr, sendport, listenport string) error {
|
|||||||
protocol := "UDP"
|
protocol := "UDP"
|
||||||
val := "\"" + protocol + "\",\"" + addr + "\"," + sendport + "," + listenport + ",2"
|
val := "\"" + protocol + "\",\"" + addr + "\"," + sendport + "," + listenport + ",2"
|
||||||
d.Set(TCPConnect, val)
|
d.Set(TCPConnect, val)
|
||||||
time.Sleep(pause * time.Millisecond)
|
r := d.Response(pause)
|
||||||
r := d.Response()
|
|
||||||
if strings.Contains(string(r), "OK") {
|
if strings.Contains(string(r), "OK") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -60,8 +56,8 @@ func (d *Device) ConnectSSLSocket(addr, port string) error {
|
|||||||
protocol := "SSL"
|
protocol := "SSL"
|
||||||
val := "\"" + protocol + "\",\"" + addr + "\"," + port + ",120"
|
val := "\"" + protocol + "\",\"" + addr + "\"," + port + ",120"
|
||||||
d.Set(TCPConnect, val)
|
d.Set(TCPConnect, val)
|
||||||
time.Sleep(5000 * time.Millisecond)
|
// this operation takes longer, so wait up to 6 seconds to complete.
|
||||||
r := d.Response()
|
r := d.Response(6000)
|
||||||
if strings.Contains(string(r), "CONNECT") {
|
if strings.Contains(string(r), "CONNECT") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -71,8 +67,7 @@ func (d *Device) ConnectSSLSocket(addr, port string) error {
|
|||||||
// DisconnectSocket disconnects the ESP8266/ESP32 from the current TCP/UDP connection.
|
// DisconnectSocket disconnects the ESP8266/ESP32 from the current TCP/UDP connection.
|
||||||
func (d *Device) DisconnectSocket() error {
|
func (d *Device) DisconnectSocket() error {
|
||||||
d.Execute(TCPClose)
|
d.Execute(TCPClose)
|
||||||
time.Sleep(pause * time.Millisecond)
|
d.Response(pause)
|
||||||
d.Response()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,15 +76,14 @@ func (d *Device) DisconnectSocket() error {
|
|||||||
func (d *Device) SetMux(mode int) error {
|
func (d *Device) SetMux(mode int) error {
|
||||||
val := strconv.Itoa(mode)
|
val := strconv.Itoa(mode)
|
||||||
d.Set(TCPMultiple, val)
|
d.Set(TCPMultiple, val)
|
||||||
time.Sleep(pause * time.Millisecond)
|
d.Response(pause)
|
||||||
d.Response()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMux returns the ESP8266/ESP32 current client TCP/UDP configuration for concurrent connections.
|
// GetMux returns the ESP8266/ESP32 current client TCP/UDP configuration for concurrent connections.
|
||||||
func (d *Device) GetMux() ([]byte, error) {
|
func (d *Device) GetMux() ([]byte, error) {
|
||||||
d.Query(TCPMultiple)
|
d.Query(TCPMultiple)
|
||||||
return d.Response(), nil
|
return d.Response(pause), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetTCPTransferMode sets the ESP8266/ESP32 current client TCP/UDP transfer mode.
|
// SetTCPTransferMode sets the ESP8266/ESP32 current client TCP/UDP transfer mode.
|
||||||
@@ -97,26 +91,24 @@ func (d *Device) GetMux() ([]byte, error) {
|
|||||||
func (d *Device) SetTCPTransferMode(mode int) error {
|
func (d *Device) SetTCPTransferMode(mode int) error {
|
||||||
val := strconv.Itoa(mode)
|
val := strconv.Itoa(mode)
|
||||||
d.Set(TransmissionMode, val)
|
d.Set(TransmissionMode, val)
|
||||||
time.Sleep(pause * time.Millisecond)
|
d.Response(pause)
|
||||||
d.Response()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTCPTransferMode returns the ESP8266/ESP32 current client TCP/UDP transfer mode.
|
// GetTCPTransferMode returns the ESP8266/ESP32 current client TCP/UDP transfer mode.
|
||||||
func (d *Device) GetTCPTransferMode() []byte {
|
func (d *Device) GetTCPTransferMode() []byte {
|
||||||
d.Query(TransmissionMode)
|
d.Query(TransmissionMode)
|
||||||
return d.Response()
|
return d.Response(pause)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartSocketSend gets the ESP8266/ESP32 ready to receive TCP/UDP socket data.
|
// StartSocketSend gets the ESP8266/ESP32 ready to receive TCP/UDP socket data.
|
||||||
func (d *Device) StartSocketSend(size int) error {
|
func (d *Device) StartSocketSend(size int) error {
|
||||||
val := strconv.Itoa(size)
|
val := strconv.Itoa(size)
|
||||||
d.Set(TCPSend, val)
|
d.Set(TCPSend, val)
|
||||||
time.Sleep(pause * time.Millisecond)
|
|
||||||
|
|
||||||
// when ">" is received, it indicates
|
// when ">" is received, it indicates
|
||||||
// ready to receive data
|
// ready to receive data
|
||||||
r := d.Response()
|
r := d.Response(pause)
|
||||||
if strings.Contains(string(r), ">") {
|
if strings.Contains(string(r), ">") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -127,10 +119,7 @@ func (d *Device) StartSocketSend(size int) error {
|
|||||||
// and to return to command mode. This is only used in "unvarnished" raw mode.
|
// and to return to command mode. This is only used in "unvarnished" raw mode.
|
||||||
func (d *Device) EndSocketSend() error {
|
func (d *Device) EndSocketSend() error {
|
||||||
d.Write([]byte("+++"))
|
d.Write([]byte("+++"))
|
||||||
time.Sleep(pause * time.Millisecond)
|
|
||||||
|
|
||||||
// TODO: wait until ">" is received, which indicates
|
d.Response(pause)
|
||||||
// ready to receive data
|
|
||||||
d.Response()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-26
@@ -2,7 +2,6 @@ package espat
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -19,15 +18,14 @@ const (
|
|||||||
// GetWifiMode returns the ESP8266/ESP32 wifi mode.
|
// GetWifiMode returns the ESP8266/ESP32 wifi mode.
|
||||||
func (d *Device) GetWifiMode() []byte {
|
func (d *Device) GetWifiMode() []byte {
|
||||||
d.Query(WifiMode)
|
d.Query(WifiMode)
|
||||||
return d.Response()
|
return d.Response(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWifiMode sets the ESP8266/ESP32 wifi mode.
|
// SetWifiMode sets the ESP8266/ESP32 wifi mode.
|
||||||
func (d *Device) SetWifiMode(mode int) error {
|
func (d *Device) SetWifiMode(mode int) error {
|
||||||
val := strconv.Itoa(mode)
|
val := strconv.Itoa(mode)
|
||||||
d.Set(WifiMode, val)
|
d.Set(WifiMode, val)
|
||||||
time.Sleep(pause * time.Millisecond)
|
d.Response(pause)
|
||||||
d.Response()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ func (d *Device) SetWifiMode(mode int) error {
|
|||||||
// GetConnectedAP returns the ESP8266/ESP32 is currently connected to as a client.
|
// GetConnectedAP returns the ESP8266/ESP32 is currently connected to as a client.
|
||||||
func (d *Device) GetConnectedAP() []byte {
|
func (d *Device) GetConnectedAP() []byte {
|
||||||
d.Query(ConnectAP)
|
d.Query(ConnectAP)
|
||||||
return d.Response()
|
return d.Response(100)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConnectToAP connects the ESP8266/ESP32 to an access point.
|
// ConnectToAP connects the ESP8266/ESP32 to an access point.
|
||||||
@@ -44,32 +42,28 @@ func (d *Device) GetConnectedAP() []byte {
|
|||||||
func (d *Device) ConnectToAP(ssid, pwd string, ws int) error {
|
func (d *Device) ConnectToAP(ssid, pwd string, ws int) error {
|
||||||
val := "\"" + ssid + "\",\"" + pwd + "\""
|
val := "\"" + ssid + "\",\"" + pwd + "\""
|
||||||
d.Set(ConnectAP, val)
|
d.Set(ConnectAP, val)
|
||||||
// TODO: a better way to wait for connect and check for up to ws seconds.
|
d.Response(ws * 1000)
|
||||||
time.Sleep(time.Duration(ws) * time.Second)
|
|
||||||
d.Response()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisconnectFromAP disconnects the ESP8266/ESP32 from the current access point.
|
// DisconnectFromAP disconnects the ESP8266/ESP32 from the current access point.
|
||||||
func (d *Device) DisconnectFromAP() error {
|
func (d *Device) DisconnectFromAP() error {
|
||||||
d.Execute(Disconnect)
|
d.Execute(Disconnect)
|
||||||
time.Sleep(1000 * time.Millisecond)
|
d.Response(1000)
|
||||||
d.Response()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetClientIP returns the ESP8266/ESP32 current client IP addess when connected to an Access Point.
|
// GetClientIP returns the ESP8266/ESP32 current client IP addess when connected to an Access Point.
|
||||||
func (d *Device) GetClientIP() string {
|
func (d *Device) GetClientIP() string {
|
||||||
d.Query(SetStationIP)
|
d.Query(SetStationIP)
|
||||||
return string(d.Response())
|
return string(d.Response(100))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetClientIP sets the ESP8266/ESP32 current client IP addess when connected to an Access Point.
|
// SetClientIP sets the ESP8266/ESP32 current client IP addess when connected to an Access Point.
|
||||||
func (d *Device) SetClientIP(ipaddr string) []byte {
|
func (d *Device) SetClientIP(ipaddr string) []byte {
|
||||||
val := "\"" + ipaddr + "\""
|
val := "\"" + ipaddr + "\""
|
||||||
d.Set(ConnectAP, val)
|
d.Set(ConnectAP, val)
|
||||||
time.Sleep(500 * time.Millisecond)
|
d.Response(500)
|
||||||
d.Response()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +72,7 @@ func (d *Device) SetClientIP(ipaddr string) []byte {
|
|||||||
// GetAPConfig returns the ESP8266/ESP32 current configuration when acting as an Access Point.
|
// GetAPConfig returns the ESP8266/ESP32 current configuration when acting as an Access Point.
|
||||||
func (d *Device) GetAPConfig() string {
|
func (d *Device) GetAPConfig() string {
|
||||||
d.Query(SoftAPConfigCurrent)
|
d.Query(SoftAPConfigCurrent)
|
||||||
return string(d.Response())
|
return string(d.Response(100))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAPConfig sets the ESP8266/ESP32 current configuration when acting as an Access Point.
|
// SetAPConfig sets the ESP8266/ESP32 current configuration when acting as an Access Point.
|
||||||
@@ -89,29 +83,27 @@ func (d *Device) SetAPConfig(ssid, pwd string, ch, security int) error {
|
|||||||
ecnval := strconv.Itoa(security)
|
ecnval := strconv.Itoa(security)
|
||||||
val := "\"" + ssid + "\",\"" + pwd + "\"," + chval + "," + ecnval
|
val := "\"" + ssid + "\",\"" + pwd + "\"," + chval + "," + ecnval
|
||||||
d.Set(SoftAPConfigCurrent, val)
|
d.Set(SoftAPConfigCurrent, val)
|
||||||
time.Sleep(1000 * time.Millisecond)
|
d.Response(1000)
|
||||||
d.Response()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAPClients returns the ESP8266/ESP32 current clients when acting as an Access Point.
|
// GetAPClients returns the ESP8266/ESP32 current clients when acting as an Access Point.
|
||||||
func (d *Device) GetAPClients() string {
|
func (d *Device) GetAPClients() string {
|
||||||
d.Query(ListConnectedIP)
|
d.Query(ListConnectedIP)
|
||||||
return string(d.Response())
|
return string(d.Response(100))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAPIP returns the ESP8266/ESP32 current IP addess when configured as an Access Point.
|
// GetAPIP returns the ESP8266/ESP32 current IP addess when configured as an Access Point.
|
||||||
func (d *Device) GetAPIP() string {
|
func (d *Device) GetAPIP() string {
|
||||||
d.Query(SetSoftAPIPCurrent)
|
d.Query(SetSoftAPIPCurrent)
|
||||||
return string(d.Response())
|
return string(d.Response(100))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAPIP sets the ESP8266/ESP32 current IP addess when configured as an Access Point.
|
// SetAPIP sets the ESP8266/ESP32 current IP addess when configured as an Access Point.
|
||||||
func (d *Device) SetAPIP(ipaddr string) error {
|
func (d *Device) SetAPIP(ipaddr string) error {
|
||||||
val := "\"" + ipaddr + "\""
|
val := "\"" + ipaddr + "\""
|
||||||
d.Set(SetSoftAPIPCurrent, val)
|
d.Set(SetSoftAPIPCurrent, val)
|
||||||
time.Sleep(500 * time.Millisecond)
|
d.Response(500)
|
||||||
d.Response()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +111,7 @@ func (d *Device) SetAPIP(ipaddr string) error {
|
|||||||
// from flash storage. These settings are those used after a reset.
|
// from flash storage. These settings are those used after a reset.
|
||||||
func (d *Device) GetAPConfigFlash() string {
|
func (d *Device) GetAPConfigFlash() string {
|
||||||
d.Query(SoftAPConfigFlash)
|
d.Query(SoftAPConfigFlash)
|
||||||
return string(d.Response())
|
return string(d.Response(100))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAPConfigFlash sets the ESP8266/ESP32 current configuration acting as an Access Point,
|
// SetAPConfigFlash sets the ESP8266/ESP32 current configuration acting as an Access Point,
|
||||||
@@ -131,8 +123,7 @@ func (d *Device) SetAPConfigFlash(ssid, pwd string, ch, security int) error {
|
|||||||
ecnval := strconv.Itoa(security)
|
ecnval := strconv.Itoa(security)
|
||||||
val := "\"" + ssid + "\",\"" + pwd + "\"," + chval + "," + ecnval
|
val := "\"" + ssid + "\",\"" + pwd + "\"," + chval + "," + ecnval
|
||||||
d.Set(SoftAPConfigFlash, val)
|
d.Set(SoftAPConfigFlash, val)
|
||||||
time.Sleep(1000 * time.Millisecond)
|
d.Response(1000)
|
||||||
d.Response()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +131,7 @@ func (d *Device) SetAPConfigFlash(ssid, pwd string, ch, security int) error {
|
|||||||
// This is the IP address that will be used after a reset.
|
// This is the IP address that will be used after a reset.
|
||||||
func (d *Device) GetAPIPFlash() string {
|
func (d *Device) GetAPIPFlash() string {
|
||||||
d.Query(SetSoftAPIPFlash)
|
d.Query(SetSoftAPIPFlash)
|
||||||
return string(d.Response())
|
return string(d.Response(100))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAPIPFlash sets the ESP8266/ESP32 current IP addess when configured as an Access Point.
|
// SetAPIPFlash sets the ESP8266/ESP32 current IP addess when configured as an Access Point.
|
||||||
@@ -148,7 +139,6 @@ func (d *Device) GetAPIPFlash() string {
|
|||||||
func (d *Device) SetAPIPFlash(ipaddr string) error {
|
func (d *Device) SetAPIPFlash(ipaddr string) error {
|
||||||
val := "\"" + ipaddr + "\""
|
val := "\"" + ipaddr + "\""
|
||||||
d.Set(SetSoftAPIPFlash, val)
|
d.Set(SetSoftAPIPFlash, val)
|
||||||
time.Sleep(500 * time.Millisecond)
|
d.Response(500)
|
||||||
d.Response()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,11 +80,8 @@ func main() {
|
|||||||
input[i+1] = byte('\n')
|
input[i+1] = byte('\n')
|
||||||
adaptor.Write(input[:i+2])
|
adaptor.Write(input[:i+2])
|
||||||
|
|
||||||
// give the ESP8266 a chance to respond.
|
|
||||||
time.Sleep(10 * time.Millisecond)
|
|
||||||
|
|
||||||
// display response
|
// display response
|
||||||
console.Write(adaptor.Response())
|
console.Write(adaptor.Response(100))
|
||||||
|
|
||||||
// prompt
|
// prompt
|
||||||
prompt()
|
prompt()
|
||||||
@@ -118,6 +115,7 @@ func connectToAP() {
|
|||||||
|
|
||||||
// provide access point
|
// provide access point
|
||||||
func provideAP() {
|
func provideAP() {
|
||||||
|
time.Sleep(500 * time.Millisecond)
|
||||||
console.Write([]byte("Starting wifi network as access point '"))
|
console.Write([]byte("Starting wifi network as access point '"))
|
||||||
console.Write([]byte(ssid))
|
console.Write([]byte(ssid))
|
||||||
console.Write([]byte("'...\r\n"))
|
console.Write([]byte("'...\r\n"))
|
||||||
|
|||||||
Reference in New Issue
Block a user