Skip to content

increase CWLAP timeout, modify simpletest to fix AP Scan #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion adafruit_espatcontrol/adafruit_espatcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def scan_APs(self, retries=3): # pylint: disable=invalid-name
try:
if self.mode != self.MODE_STATION:
self.mode = self.MODE_STATION
scan = self.at_response("AT+CWLAP", timeout=3).split(b'\r\n')
scan = self.at_response("AT+CWLAP", timeout=5).split(b'\r\n')
except RuntimeError:
continue
routers = []
Expand Down
19 changes: 14 additions & 5 deletions examples/espatcontrol_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# With a Metro or Feather M4
uart = busio.UART(board.TX, board.RX, timeout=0.1)
resetpin = DigitalInOut(board.D5)
rtspin = DigitalInOut(board.D6)

# With a Particle Argon
"""
Expand All @@ -28,23 +29,31 @@
esp_boot.value = True
"""


print("ESP AT commands")
esp = adafruit_espatcontrol.ESP_ATcontrol(uart, 115200, run_baudrate=9600,
reset_pin=resetpin, debug=False)
esp = adafruit_espatcontrol.ESP_ATcontrol(uart, 115200,
reset_pin=resetpin, rts_pin=rtspin, debug=False)
print("Resetting ESP module")
esp.hard_reset()

first_pass = True
while True:
try:
print("Checking connection...")
while not esp.is_connected:
print("Initializing ESP module")
if first_pass :
print("Scanning for AP's")
for ap in esp.scan_APs():
print(ap)
print("Checking connection...")
# secrets dictionary must contain 'ssid' and 'password' at a minimum
print("Connecting...")
esp.connect(secrets)
print("Connected to AT software version ", esp.version)
first_pass = False
print("Pinging 8.8.8.8...", end="")
print(esp.ping("8.8.8.8"))
time.sleep(10)
except (ValueError,RuntimeError, adafruit_espatcontrol.OKError) as e:
print("Failed to get data, retrying\n", e)
print("Resetting ESP module")
esp.hard_reset()
continue
6 changes: 4 additions & 2 deletions examples/espatcontrol_webclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
# With a Metro or Feather M4
uart = busio.UART(board.TX, board.RX, timeout=0.1)
resetpin = DigitalInOut(board.D5)
rtspin = DigitalInOut(board.D6)

# With a Particle Argon
"""
uart = busio.UART(board.ESP_RX, board.ESP_TX, timeout=0.1)
resetpin = DigitalInOut(board.ESP_WIFI_EN)
rtspin = DigitalInOut(board.ESP_CTS)
esp_boot = DigitalInOut(board.ESP_BOOT_MODE)
from digitalio import Direction
esp_boot.direction = Direction.OUTPUT
Expand All @@ -29,8 +31,8 @@
URL = "http://wifitest.adafruit.com/testwifi/index.html"
print("ESP AT GET URL", URL)

esp = adafruit_espatcontrol.ESP_ATcontrol(uart, 115200, run_baudrate=9600,
reset_pin=resetpin, debug=False)
esp = adafruit_espatcontrol.ESP_ATcontrol(uart, 115200,
reset_pin=resetpin, rts_pin=rtspin, debug=False)
print("Resetting ESP module")
esp.hard_reset()

Expand Down