def radio(): if request.method == 'POST': f = request.files['file'] f.save(os.path.join(app.config['CACHE_ROOT'], 'br.bin')) try: load_radio() except IOError: return render_mako('radio.html', error={'badupload':['resetcmd']} ) return render_mako('radio.html', error={})
def login(): error = None if request.method == 'POST': try: user = LoginUser() if bcrypt.check_password_hash(user.password, request.form['password']): doLogin(user) return redirect(url_for('index')) else: raise ValueError except ValueError: return render_mako('login.html', name=mako, error=error) return render_mako('login.html', name=mako, error=error)
def radio(): if request.method == 'POST': f = request.files['file'] f.save(os.path.join(app.config['CACHE_ROOT'], 'br.bin')) # try: # broadcastStatus("radio", json.dumps(dict(task = "uploadingFirmware"))) # load_radio() # except IOError: # return render_mako('radio.html', error={'badupload':['resetcmd']} ) radio = json.loads(db.get('conf/radio')) return render_mako('radio.html', error = {}, radio = radio, forceReload="true") # GET radio = json.loads(db.get('conf/radio')) return render_mako('radio.html', error={}, radio = radio, forceReload="false")
def brSetup(): if request.method == 'GET': return render_mako('brSetup.html') elif request.method == 'POST': br = lowpan.getBRInfo(request.form['eui'], request.form['brkey']) lowpan.createDefaultConf() lowpanConf = json.loads(db.get('conf/lowpan')) lowpanConf['eui'] = request.form['eui'] lowpanConf['password'] = request.form['brkey'] lowpanConf['url'] = BASE_URL + request.form['eui'] db.store('conf/lowpan', json.dumps(lowpanConf)) db.store('conf/br', json.dumps(br)) # change root password os.system('echo "root:%s" | chpasswd' % (br['pin'])) # also set login password to pin conf['password'] = bcrypt.generate_password_hash(br['pin']) db.store('conf/bradmin', json.dumps(conf, sort_keys=True, indent=4)) # set the hostname os.system('hostnamectl set-hostname br12-%s' % (lowpanConf['eui'])) os.system('sleep 3 && systemctl restart bramble') return "Now you need to restart BRamble"
def settings(): release = {} try: release = json.loads(db.get("conf/release")) except IOError: release = {"distro": "br12", "release": "testing", "url": "distro.lowpan.com/distro"} db.store("conf/release", json.dumps(release)) return render_mako("settings.html", release=release)
def radio(): if request.method == 'POST': f = request.files['file'] f.save(os.path.join(app.config['CACHE_ROOT'], 'br.bin')) # try: # broadcastStatus("radio", json.dumps(dict(task = "uploadingFirmware"))) # load_radio() # except IOError: # return render_mako('radio.html', error={'badupload':['resetcmd']} ) radio = json.loads(db.get('conf/radio')) return render_mako('radio.html', error={}, radio=radio, forceReload="true") # GET radio = json.loads(db.get('conf/radio')) return render_mako('radio.html', error={}, radio=radio, forceReload="false")
def settings(): release = {} try: release = json.loads(db.get('conf/release')) except IOError: release = { "distro": "br12", "release": "testing", "url": "distro.lowpan.com/distro" } db.store('conf/release', json.dumps(release)) return render_mako('settings.html', release=release)
def brSetup(): if request.method == 'GET': return render_mako('brSetup.html', url=BASE_URL) elif request.method == 'POST': baseurl = BASE_URL br = {} if request.form['url'] != '': baseurl = request.form['url'] if baseurl[-1] != '/': baseurl = baseurl + '/' br = lowpan.getBRInfo(request.form['eui'], request.form['brkey'], baseurl) else: br = lowpan.getBRInfo(request.form['eui'], request.form['brkey']) lowpan.createDefaultConf() lowpanConf = json.loads(db.get('conf/lowpan')) lowpanConf['eui'] = request.form['eui'] lowpanConf['password'] = request.form['brkey'] lowpanConf['url'] = baseurl + request.form['eui'] db.store('conf/lowpan', json.dumps(lowpanConf)) db.store('conf/lowpan.factory', json.dumps(lowpanConf)) db.store('conf/br', json.dumps(br)) db.store('conf/br.factory', json.dumps(br)) lowpan.syncConfig() lowpan.updateGogoc() # set the radio's serial (which also sets the eui) try: radio.setSerial(br['m12serial']) except KeyError: print "Warning: no m12 serial number set" # change root password os.system('echo "root:%s" | chpasswd' % (br['pin'])) # also set login password to pin conf['password'] = bcrypt.generate_password_hash(br['pin']) db.store('conf/bradmin', json.dumps(conf, sort_keys=True, indent=4)) db.store('conf/bradmin.factory', json.dumps(conf, sort_keys=True, indent=4)) # set the hostname os.system('hostnamectl set-hostname br12-%s' % (lowpanConf['eui'])) return "Now you need to restart BRamble"
def mesh(): return render_mako('mesh.html')
def mesh(): return render_mako("mesh.html")
def index(): if current_user.is_anonymous() is True: return redirect(url_for('login')) return render_mako('index.html', user=current_user)
def settings(): return render_mako('settings.html')
def index(): if current_user.is_anonymous() is True: return redirect(url_for('login')) return render_mako('mesh.html', user=current_user)
def clouds(): return render_mako('clouds.html')