Skip to content

Commit

Permalink
小更改: 增加了串口模式中的reboot选项和sys.exit()时的提示
Browse files Browse the repository at this point in the history
  • Loading branch information
RainGather committed Nov 13, 2018
1 parent 9cfb6a4 commit 0180737
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/serial/WiFi与物联网MQTT.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@
以上命令都会在成功执行后返回::

sta|ok;

如需重启或重置,可以发送命令::

sys|reboot;

会收到命令::
sys|rebooting;
6 changes: 6 additions & 0 deletions src/ezmpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ def wifi(self, ssid, pwd, test_mqtt=True):
while not wlan.isconnected():
if time.time() - t > 15:
print('Network Connect Error, Please Press [RST] To Retry...')
if self.serial_mode:
self.send_ser.write('sta|exit;')
wlan.active(False)
sys.exit()
print('Network config: ', wlan.ifconfig())
Expand Down Expand Up @@ -284,6 +286,10 @@ def serial_daemon_once(self):
user = args[2]
pwd = args[3]
self.mqtt_init(host, port, user, pwd)
elif cmd.lower() == 'sys' and len(args) >= 1:
if args[0] == 'reboot':
self.send_ser.write('sta|rebooting;')
machine.reset()
else:
self.send_ser.write('sta|no_cmd;')
return
Expand Down

0 comments on commit 0180737

Please sign in to comment.