Skip to content

Commit

Permalink
Add frozen module to send status from wifi.
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn20 committed Nov 28, 2022
1 parent fc62686 commit 44a1341
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ports/esp32/modules/_boot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _preboot
import _preboot_wifi

import gc
import uos
Expand Down
23 changes: 23 additions & 0 deletions ports/esp32/modules/_preboot_wifi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import machine


def send_state(broker):
import network
import urequests

sta = network.WLAN(network.STA_IF)
sta.active(True)
sta.connect("ssid", "password")
while not sta.isconnected():
pass
try:
r = urequests.post("http://192.168.40.10:5000/status", data="hello")
except OSError:
pass
sta.disconnect()
sta.active(False)


if machine.reset_cause() == machine.DEEPSLEEP_RESET:
send_state()
machine.deepsleep(1000)

0 comments on commit 44a1341

Please sign in to comment.