In [1]:
import os, sys
sys.path.append(os.path.join('..', '..', '..', '..', '..', ))
import ampy_utils
# with open(os.path.join('..', '..', '..', '..', '..', 'ampy_utils.py'), 'r') as f:
# print(f.read())
In [2]:
ampy_utils.baud_rate = 115200
ampy_utils.com_port = 'COM3'
# ampy_utils.com_port = '/dev/ttyUSB0'
In [3]:
from ampy_utils import *
In [5]:
root_folders = [os.path.sep.join(['..', '..', 'codes', 'micropython']),
os.path.sep.join(['..', '..', 'codes', 'micropython_mqtt']),
os.path.sep.join(['..', '..', 'codes', 'node']),
os.path.sep.join(['..', '..', 'codes', 'shared']),]
folders = []
format_put_files_folders(root_folders = root_folders,
folders = folders,
format_first = True)
In [5]:
# copy_one_file_to_device(os.path.sep.join(['..', '..', 'codes', 'micropython']), 'main.py')
In [6]:
# copy_one_file_to_device(os.path.sep.join(['..', '..', 'codes', 'shared']), 'config_mqtt.py')
In [7]:
# copy_one_file_to_device(os.path.sep.join(['..', '..', '..', 'dmz']), 'config_mqtt.py')
In [8]:
# copy_one_file_to_device(os.path.sep.join(['..', '..', 'codes', 'node']), 'node.py')
In [9]:
# list_files_in_device()
In [10]:
# cat_file_from_device('main.py')
In [11]:
# 連上網路
# import network; nic=network.WLAN(network.STA_IF); nic.active(False); # disable network
# import network; nic=network.WLAN(network.STA_IF); nic.active(True); nic.connect('SSID','password');nic.ifconfig()
# import network; nic=network.WLAN(network.STA_IF); nic.ifconfig()
# import network; nic=network.WLAN(network.STA_IF);nic.ifconfig();nic.config('mac');nic.ifconfig((['mac',])
copy folder 'codes' to Raspberry Pi under folder '/data/elastic_network_of_things_with_micropython',
so Raspberry Pi has folder '/data/elastic_network_of_things_with_micropython/codes'
then run the command below on Raspberry Pi.
docker run -it -p 9662:9662 --name=Broker --hostname=Broker --volume=/data/elastic_network_of_things_with_micropython:/project wei1234c/python_armv7 /bin/sh -c "cd /project/codes/broker && python3 broker.py"