units set , wifi fix
This commit is contained in:
@@ -10,6 +10,7 @@ from tornado import gen
|
|||||||
import re
|
import re
|
||||||
import bbctrl
|
import bbctrl
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
import iw_parse
|
||||||
|
|
||||||
|
|
||||||
def call_get_output(cmd):
|
def call_get_output(cmd):
|
||||||
@@ -150,34 +151,57 @@ class NetworkData(bbctrl.APIHandler):
|
|||||||
'wifi': wifiName
|
'wifi': wifiName
|
||||||
})
|
})
|
||||||
|
|
||||||
class WifiHandler(bbctrl.APIHandler):
|
class NetworkHandler(bbctrl.APIHandler):
|
||||||
def get(self):
|
|
||||||
data = {'ssid': '', 'channel': 0}
|
|
||||||
try:
|
|
||||||
data = json.loads(call_get_output(['config-wifi', '-j']))
|
|
||||||
except: pass
|
|
||||||
self.write_json(data)
|
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
try:
|
||||||
|
ipAddresses = subprocess.check_output(
|
||||||
|
"ip -4 addr | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'", shell=True).decode().split()
|
||||||
|
ipAddresses.remove("127.0.0.1")
|
||||||
|
regex = re.compile(r'/255$/')
|
||||||
|
filtered = [i for i in ipAddresses if not regex.match(i)]
|
||||||
|
ipAddresses = filtered[0]
|
||||||
|
|
||||||
|
except:
|
||||||
|
ipAddresses = "Not Connected"
|
||||||
|
|
||||||
|
hostname = socket.gethostname()
|
||||||
|
|
||||||
|
try:
|
||||||
|
wifi = json.loads(call_get_output(['config-wifi', '-j']))
|
||||||
|
except:
|
||||||
|
wifi = {'enabled': False}
|
||||||
|
|
||||||
|
try:
|
||||||
|
lines = iw_parse.call_iwlist().decode("utf-8").split("\n")
|
||||||
|
wifi['networks'] = iw_parse.get_parsed_cells(lines)
|
||||||
|
except:
|
||||||
|
wifi['networks'] = []
|
||||||
|
|
||||||
|
self.write_json({
|
||||||
|
'ipAddresses': ipAddresses,
|
||||||
|
'hostname': hostname,
|
||||||
|
'wifi': wifi
|
||||||
|
})
|
||||||
|
|
||||||
def put(self):
|
def put(self):
|
||||||
if self.get_ctrl().args.demo:
|
if self.get_ctrl().args.demo:
|
||||||
raise HTTPError(400, 'Cannot configure WiFi in demo mode')
|
raise HTTPError(400, 'Cannot configure WiFi in demo mode')
|
||||||
|
|
||||||
if 'mode' in self.json:
|
if not 'wifi' in self.json:
|
||||||
|
raise HTTPError(400, 'Payload is missing wifi config information')
|
||||||
|
|
||||||
|
wifi = self.json['wifi']
|
||||||
cmd = ['config-wifi', '-r']
|
cmd = ['config-wifi', '-r']
|
||||||
mode = self.json['mode']
|
|
||||||
|
|
||||||
if mode == 'disabled': cmd += ['-d']
|
if not wifi['enabled']:
|
||||||
elif 'ssid' in self.json:
|
cmd += ['-d']
|
||||||
cmd += ['-s', self.json['ssid']]
|
else:
|
||||||
|
if 'ssid' in wifi:
|
||||||
|
cmd += ['-s', wifi['ssid']]
|
||||||
|
|
||||||
if mode == 'ap':
|
if 'password' in wifi:
|
||||||
cmd += ['-a']
|
cmd += ['-p', wifi['password']]
|
||||||
if 'channel' in self.json:
|
|
||||||
cmd += ['-c', self.json['channel']]
|
|
||||||
|
|
||||||
if 'pass' in self.json:
|
|
||||||
cmd += ['-p', self.json['pass']]
|
|
||||||
|
|
||||||
if subprocess.call(cmd) == 0:
|
if subprocess.call(cmd) == 0:
|
||||||
self.write_json('ok')
|
self.write_json('ok')
|
||||||
@@ -186,7 +210,6 @@ class WifiHandler(bbctrl.APIHandler):
|
|||||||
raise HTTPError(400, 'Failed to configure wifi')
|
raise HTTPError(400, 'Failed to configure wifi')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class UsernameHandler(bbctrl.APIHandler):
|
class UsernameHandler(bbctrl.APIHandler):
|
||||||
def get(self): self.write_json(get_username())
|
def get(self): self.write_json(get_username())
|
||||||
|
|
||||||
@@ -613,7 +636,7 @@ class Web(tornado.web.Application):
|
|||||||
(r'/api/shutdown', ShutdownHandler),
|
(r'/api/shutdown', ShutdownHandler),
|
||||||
(r'/api/hostname', HostnameHandler),
|
(r'/api/hostname', HostnameHandler),
|
||||||
(r'/api/wifi', NetworkData),
|
(r'/api/wifi', NetworkData),
|
||||||
(r'/api/network', WifiHandler),
|
(r'/api/network', NetworkHandler),
|
||||||
(r'/api/remote/username', UsernameHandler),
|
(r'/api/remote/username', UsernameHandler),
|
||||||
(r'/api/remote/password', PasswordHandler),
|
(r'/api/remote/password', PasswordHandler),
|
||||||
(r'/api/config/load', ConfigLoadHandler),
|
(r'/api/config/load', ConfigLoadHandler),
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const namesByKey = {
|
const namesByKey = {
|
||||||
"junction-accel": "Default type",
|
"units":"units",
|
||||||
"probing-prompts": "Show safety prompts",
|
"probing-prompts": "Show safety prompts",
|
||||||
"probe-xdim": "Probe block width",
|
"probe-xdim": "Probe block width",
|
||||||
"probe-ydim": "Probe block length",
|
"probe-ydim": "Probe block length",
|
||||||
|
|||||||
@@ -16,13 +16,13 @@
|
|||||||
for a variety of support resources, and to find our contact information.
|
for a variety of support resources, and to find our contact information.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<Button
|
<!-- <Button
|
||||||
touch
|
touch
|
||||||
variant="raised"
|
variant="raised"
|
||||||
on:click={() => (showRemoteDiagnosticsDialog = true)}
|
on:click={() => (showRemoteDiagnosticsDialog = true)}
|
||||||
>
|
>
|
||||||
<Label>Remote Diagnostics</Label>
|
<Label>Remote Diagnostics</Label>
|
||||||
</Button>
|
</Button> -->
|
||||||
|
|
||||||
<h2>Discussion Forum</h2>
|
<h2>Discussion Forum</h2>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ScreenRotationDialog bind:open={showScreenRotationDialog} />
|
<ScreenRotationDialog bind:open={showScreenRotationDialog} />
|
||||||
<SetTimeDialog bind:open={showSetTimeDialog} />
|
<!-- <SetTimeDialog bind:open={showSetTimeDialog} /> -->
|
||||||
|
|
||||||
<div class="settings-view">
|
<div class="settings-view">
|
||||||
<h1>Settings</h1>
|
<h1>Settings</h1>
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pure-control-group">
|
<!-- <div class="pure-control-group">
|
||||||
<label for="set-time" />
|
<label for="set-time" />
|
||||||
<Button
|
<Button
|
||||||
name="set-time"
|
name="set-time"
|
||||||
@@ -42,15 +42,15 @@
|
|||||||
>
|
>
|
||||||
<Label>Change Time & Timezone</Label>
|
<Label>Change Time & Timezone</Label>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div> -->
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<h2>Gamepads / Joypads</h2>
|
<h2>Units</h2>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<ConfigTemplatedInput key={`settings.junction-accel`} />
|
<ConfigTemplatedInput key={`settings.units`} />
|
||||||
<div class="tip">
|
<div class="tip">
|
||||||
If your gamepad doesn't work as expected, try one of the other
|
Note, units sets both the machine default units and the units used in motor configuration. GCode program-start,
|
||||||
types.
|
set below, may also change the default machine units.
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user