The cloudmanager server is:
- Completely open source
- pip installable (no yum/apt/dmg packages are required)
- Runs on pretty much any Posix compliant operating system (this means in practice it will run on pretty much anything but Microsoft Windows. Although it may run in the windows 10 bash shell)
- Currently doesn't have the security proxy implemented so should only be run on secure networks.
- It does the heavy lifting on the server, instead of trying to implement the functionality in micropython on a board with limited resources. This also means that added functionality can leverage many existing python packages like django/redislite/mysql/etc on the server side.
Install cloudmanager
Code: Select all
dwight@laptop:~/cm$ pip install micropython-cloudmanager
dwight@laptop:~/cm$
The cloudmanager server is designed to not require a bunch of configuration in order to use it. A single command will start the server/service.
Code: Select all
dwight@laptop:~/cm$ mbm server-start
dwight@laptop:~/cm$
The boards need to have the micropython-redis-cloudclient module installed and enabled. For esp8266 boards the simplest way to do this is to pip install the cloudmanager-micropython-esp8266 package and run the flash_image command with the wifi connection settings specified as arguments (this will search for the tty device the board is attached to, flash the esp8266 board with a micropython flash image that has micropython-redis-cloudclient installed, configure it and enable it to run at boot):
dwight@laptop:~cm$ flash_esp_image --wifi_ssid mywifissdid --wifi_password mywifi_password
... Lots of output
dwight@laptop:~cm$
List boards registered with the server
Cloudmanager uses a single management host that the boards connect into, the board-list subcommand lists the boards that have registered with the service.
Code: Select all
dwight@laptop:~/cm$ mbm board-list
Name Platform State
esp8266-10 esp8266 idle
esp8266-16 esp8266 idle
esp8266-17 esp8266 idle
wipy2-1 WiPy idle
dwight@laptop:~/cm$
The mbm board subcommand runs a pre-defined macro (code to do a common operations) one of the more convenient macros is ls, which will list the directory on the board's flash.
Code: Select all
dwight@laptop:~/cm$ mbm board esp8266-10 ls
## 'ls' on 'esp8266-10' ########################################################
boot.py
etc
main.py
lib
dwight@laptop:~/cm$
A management infrastructure isn't much use if it can't copy data to the boards. The board-upload command does that. Note, this command is fairly simple, method to copy a single file. To copy many files, etc the mbm_sync service, it's easier to use.
Code: Select all
dwight@laptop:~/cm$
cat hello.py
print('Hello World!!')
dwight@laptop:~/cm$ mbm board-upload esp8266-10 hello.py hello.py
Copying file to esp8266-10:hello.py
dwight@laptop:~/cm$
Execute a command on a board from stdin to run the file just uploaded
The board-execute command takes code on stdin and executes it on the specified board(s). Here we are importing the module we uploaded in the last step.
Code: Select all
dwight@laptop:~/cm$ echo "import hello"|mbm board-execute esp8266-10
## Executing on 'esp8266-10' ###################################################
Hello World!!
dwight@laptop:~/cm$
The package installation does the package download and unpack operations on the cloudmanager server so the board doesn't need to have upip installed to install the packages. Like the other commands we've been using, it works with hostslists ranges so it can operate on multiple boards.
Code: Select all
dwight@laptop:~/cm$ mbm board-install esp8266-[10-17] micropython-logging
Installing package 'micropython-logging'
Copying file to esp8266-16:lib/logging.py
Copying file to esp8266-17:lib/logging.py
Copying file to esp8266-10:lib/logging.py
dwight@laptop:~/cm$
The mbm board-execute subcommand takes input from standard in, if we don't pipe input into it we can just time multiple lines of code and press ctrl-d to execute it.
Code: Select all
dwight@laptop:~/cm$ mbm board-execute esp8266-1[0-7]
import logging
logging.info('These are wonderful times')
## Executing on 'esp8266-16' ###################################################
INFO:None:These are wonderful times
## Executing on 'esp8266-17' ###################################################
INFO:None:These are wonderful times
## Executing on 'esp8266-10' ###################################################
INFO:None:These are wonderful times
dwight@laptop:~/cm$
Start the mbm_sync service to create a /tmp/mbm sync directory tree
The mbm_sync service creates a /tmp/mbm directory with subdirectories for each board. It then monitors them for changes, any files copied into a board directory will be uploaded to the board. Files deleted from the directory will be deleted from the board.
Note: This is a one way sync, it doesn't copy existing files from the board into the /tmp/mbm directory.
Code: Select all
dwight@laptop:~/cm$ mbm_sync
dwight@laptop:~/cm$ ls -lh /tmp/mbm
total 16K
drwxrwxrwx 3 dwight dwight 4.0K Nov 29 10:19 esp8266-10
drwxrwxrwx 4 dwight dwight 4.0K Nov 29 09:52 esp8266-16
drwxrwxrwx 2 dwight dwight 4.0K Nov 29 09:41 esp8266-17
drwxrwxrwx 2 dwight dwight 4.0K Nov 29 09:41 wipy2-1
dwight@laptop:~/cm$
So here I have a directory with 2 files and I'm going to copy it to the esp8266-10 board.
Code: Select all
dwight@laptop:~/cm$ ls -lh mydata
total 8.0K
-rw-rw-r-- 1 dwight dwight 1.0K Nov 29 09:36 courier.font
-rw-rw-r-- 1 dwight dwight 2.0K Nov 29 09:37 furbie.font
dwight@laptop:~/cm$ cp -a mydata /tmp/mbm/esp8266-10
dwight@laptop:~/cm$
Listing the files on the esp8266-10 board we can see the directory got copied.
Code: Select all
dwight@laptop:~/cm$ mbm board esp8266-10 ls
## 'ls' on 'esp8266-10' ########################################################
boot.py
etc
main.py
hello.py
lib
mydata
dwight@laptop:~/cm$ mbm board esp8266-10 ls mydata
## 'ls' on 'esp8266-10' ########################################################
courier.font
furbie.font
dwight@laptop:~/cm$
The mbm_sync service works very well with IDEs that support deploy on save like pycharm. Just set it to deploy to a /tmp/mbm/[board] directory and mbm_sync will deploy the code to the board every time a file is saved in the IDE. This allows for usage of your preferred editor while still having automatic code deployment.
ftp/webdav access
It is possible to configure ftp or web servers on the cloudmanager host to present the /tmp/mbm directory and provide the ability to copy to boards using ftp or webdav.