micropython客户端,允许从中央redis服务器控制网络连接板
micropython-cloudmanager的Python项目详细描述
说明
cloudmanger为micropython系统提供了一个单一的管理点,使安全攻击面最小化,并且 将资源密集型操作从micropython客户端卸载到服务器。
快速启动
下面是一个快速入门,用于使用流行的ESP8266板设置CloudManager
安装
使用pip安装服务器和客户端flash实用程序:
$ pip install micropython-cloudmanager micropython-cloudmanager-esp8266 $
启动服务器
使用默认设置启动服务器进程:
$ mbm server-start Cloudmanager service is listening on: 192.168.1.127:18266 $
闪存并将ESP8266板配置为客户端
将ESP8266板插入USB端口。
注:根据供应商的说明,有些电路板可能需要手动进入闪存模式。
只要只有一个USB串行设备,闪存工具通常会确定要闪存的正确串行设备 已连接到系统。
闪存并配置指定WiFi连接设置的板:
$ flash_esp_image --wifi_ssid mywifi --wifi_password mywifipassword esptool.py --port /dev/ttyUSB0 --baud 115200 erase_flash esptool.py v1.2.1 Connecting... Running Cesanta flasher stub... Erasing flash (this may take a while)... Erase took 9.0 seconds esptool.py --port /dev/ttyUSB0 --baud 115200 write_flash --verify --flash_size=32m --flash_mode=qio 0 /tmp/cloudmanager-micropython-esp8266/local/lib/python2.7/site-packages/cloudmanager_micropython_esp8266/firmware/firmware-combined.bin esptool.py v1.2.1 Connecting... Running Cesanta flasher stub... Flash params set to 0x0040 Writing 557056 @ 0x0... 557056 (100 %) Wrote 557056 bytes at 0x0 in 48.3 seconds (92.3 kbit/s)... Leaving... Verifying just-written flash... Verifying 0x8734c (553804) bytes @ 0x00000000 in flash against /tmp/cloudmanager-micropython-esp8266/local/lib/python2.7/site-packages/cloudmanager_micropython_esp8266/firmware/firmware-combined.bin... -- verify OK (digest matched) >>> >>> import os >>> os.mkdir('etc') >>> from bootconfig.config import get, set >>> set('wifi_ssid', 'mywifi') >>> set('wifi_password', 'mywifipassword') >>> set('redis_server', '192.168.1.127') >>> import bootconfig.service >>> bootconfig.service.autostart() >>> import redis_cloudclient.service >>> redis_cloudclient.service.autostart() >>> import machine >>> machine.reset()
注意:此时需要手动重置一些板。
验证电路板是否已在服务器上注册
几秒钟后,电路板应连接到WiFi网络并向CloudManager服务器注册:
$ mbm board-list Name Platform State esp8266-1 esp8266 idle $
请参阅使用CloudManager在板上安装包、上载文件或执行命令的完整文档。