Beispiel #1
0
def update(opts):
  cfg = model.load(filename)
  cfg[opts['device']] = {
    'pin': opts['pin'],
    'default': opts['default']
  }
  model.save(filename, cfg)
Beispiel #2
0
def set(req, res):
  yield from req.read_form_data()
  cfg = model.load()
  for key, value in req.form.items():
    cfg[key] = value
  model.save(cfg)
  yield from get(req, res)
Beispiel #3
0
def boot():
    from util import exists
    if not exists(filename):
        factory()
    cfg = model.load(filename)
    interface.config(dhcp_hostname=cfg['dhcp_hostname'])
    if 'ssid' in cfg:
        interface.connect(cfg['ssid'], cfg['passwd'])
    logger.info(ujson.dumps(get()))
Beispiel #4
0
def boot():
  from util import exists
  if not exists(filename):
    factory()
  cfg = model.load(filename)
  interface.config(dhcp_hostname=cfg['dhcp_hostname'])
  if 'ssid' in cfg:
    interface.connect(cfg['ssid'], cfg['passwd'])
  logger.info(ujson.dumps(get()))
Beispiel #5
0
def list():
  cfg = model.load(filename)
  for name in cfg:
    pin = cfg[name]['pin']
    cfg[name] = {
      'pin': pin,
      'default': cfg[name]['default'],
      'value': device(pin).duty()
    }
  return cfg
Beispiel #6
0
def boot():
  from util import exists
  if not exists(filename):
    factory()
  cfg = model.load(filename)
  for name in cfg:
    pin = cfg[name]['pin']
    default = cfg[name]['default']
    dev = device(pin)
    dev.freq(1024)
    dev.duty(default)
  logger.info(ujson.dumps(cfg))
Beispiel #7
0
def set(opts):
    cfg = model.load(filename)
    if 'name' in opts:
        name = opts['name'][0]
        interface.config(dhcp_hostname=name)
        cfg['dhcp_hostname'] = name
    if 'ssid' in opts and 'passwd' in opts:
        ssid = opts['ssid'][0]
        passwd = opts['passwd'][0]
        interface.connect(ssid, passwd)
        cfg['ssid'] = ssid
        cfg['passwd'] = passwd
    model.save(filename, cfg)
Beispiel #8
0
def set(opts):
  cfg = model.load(filename)
  if 'name' in opts:
    name = opts['name'][0]
    interface.config(dhcp_hostname=name)
    cfg['dhcp_hostname'] = name
  if 'ssid' in opts and 'passwd' in opts:
    ssid = opts['ssid'][0]
    passwd = opts['passwd'][0]
    interface.connect(ssid, passwd)
    cfg['ssid'] = ssid
    cfg['passwd'] = passwd
  model.save(filename, cfg)
Beispiel #9
0
def duty(opts):
  cfg = model.load(filename)[opts['device']]
  device(cfg['pin']).duty(opts['value'])
Beispiel #10
0
def read(opts):
  cfg = model.load(filename)
  name = opts['device']
  pin = cfg[name]['pin']
  cfg[name]['value'] = device(pin).duty()
  return cfg[name]
Beispiel #11
0
def get(req, res):
  req.parse_qs()
  yield from ok(res, model.load(req.form['name'][0]))