forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add frozen module to send status from wifi.
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import _preboot | ||
import _preboot_wifi | ||
|
||
import gc | ||
import uos | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |