Compare commits

..

2 Commits

3 changed files with 51 additions and 5 deletions

View File

@ -0,0 +1,2 @@
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
var saveAs=saveAs||function(e){"use strict";if(typeof e==="undefined"||typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in r,i=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},a=/constructor/i.test(e.HTMLElement),f=/CriOS\/[\d]+/.test(navigator.userAgent),u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},d="application/octet-stream",s=1e3*40,c=function(e){var t=function(){if(typeof e==="string"){n().revokeObjectURL(e)}else{e.remove()}};setTimeout(t,s)},l=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var o=e["on"+t[r]];if(typeof o==="function"){try{o.call(e,n||e)}catch(i){u(i)}}}},p=function(e){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)){return new Blob([String.fromCharCode(65279),e],{type:e.type})}return e},v=function(t,u,s){if(!s){t=p(t)}var v=this,w=t.type,m=w===d,y,h=function(){l(v,"writestart progress write writeend".split(" "))},S=function(){if((f||m&&a)&&e.FileReader){var r=new FileReader;r.onloadend=function(){var t=f?r.result:r.result.replace(/^data:[^;]*;/,"data:attachment/file;");var n=e.open(t,"_blank");if(!n)e.location.href=t;t=undefined;v.readyState=v.DONE;h()};r.readAsDataURL(t);v.readyState=v.INIT;return}if(!y){y=n().createObjectURL(t)}if(m){e.location.href=y}else{var o=e.open(y,"_blank");if(!o){e.location.href=y}}v.readyState=v.DONE;h();c(y)};v.readyState=v.INIT;if(o){y=n().createObjectURL(t);setTimeout(function(){r.href=y;r.download=u;i(r);h();c(y);v.readyState=v.DONE});return}S()},w=v.prototype,m=function(e,t,n){return new v(e,t||e.name||"download",n)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){return function(e,t,n){t=t||e.name||"download";if(!n){e=p(e)}return navigator.msSaveOrOpenBlob(e,t)}}w.abort=function(){};w.readyState=w.INIT=0;w.WRITING=1;w.DONE=2;w.error=w.onwritestart=w.onprogress=w.onwrite=w.onabort=w.onerror=w.onwriteend=null;return m}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content);if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else if(typeof define!=="undefined"&&define!==null&&define.amd!==null){define([],function(){return saveAs})}

File diff suppressed because one or more lines are too long

View File

@ -10,14 +10,13 @@ print("networks found: {}".format(networks))
ap_found = False
# TODO: edit these lines
network_name = 'M5Wifi'
password = '<PW>'
#desired_ip = '192.168.1.101'
#desired_ip = '192.168.1.102'
desired_ip = '192.168.1.103'
network_name = '<SSID>' # existing wifi network to connect to (leave empty if unused)
password = '<PW>' # password for the network
desired_ip = '192.168.1.101' # the robot will be reachable by this IP in the network
subnet = '255.255.255.0'
gateway = '192.168.1.1'
dns = '192.168.1.1'
# TODO end edit
for n in networks:
if network_name == n[0].decode():
@ -32,10 +31,23 @@ for n in networks:
ap_found = True
ap_if.active(False)
print("disabling access point interface")
elif 'MicroPython' in n[0].decode(): # alternatively, connect to MicroPython network
print("existing network found: {}".format(n[0]))
print("connecting to the network ...")
# set static ip
sta_if.ifconfig((desired_ip, subnet, gateway, dns))
sta_if.connect(n[0].decode(), 'micropythoN')
my_ip = sta_if.ifconfig()
print("my_ip[0] = {}".format(my_ip[0]))
if my_ip[0] == desired_ip:
ap_found = True
ap_if.active(False)
print("disabling access point interface")
if not ap_found:
print("could not connect to network, becoming an access point instead")
sta_if.active(False)
ap_if.active(True)
ap_if.ifconfig((desired_ip, subnet, gateway, dns))
my_ip = ap_if.ifconfig()
print("disabling station interface")
print("my_ip = {}".format(my_ip))