Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flow3r
flow3r firmware
Commits
fbcd38ca
Commit
fbcd38ca
authored
1 year ago
by
Woazboat
Browse files
Options
Downloads
Patches
Plain Diff
Use obfuscated rendering for wifi password setting value
parent
cf318ef4
No related branches found
No related tags found
1 merge request
!205
Allow configuration of wifi credentials + hostname via settings.json
Pipeline
#7327
passed
1 year ago
Stage: check
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python_payload/st3m/settings.py
+43
-3
43 additions, 3 deletions
python_payload/st3m/settings.py
with
43 additions
and
3 deletions
python_payload/st3m/settings.py
+
43
−
3
View file @
fbcd38ca
...
@@ -278,11 +278,51 @@ class StringWidget(TunableWidget):
...
@@ -278,11 +278,51 @@ class StringWidget(TunableWidget):
self
.
_tunable
=
tunable
self
.
_tunable
=
tunable
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
# Nothing to do here
pass
pass
def
draw
(
self
,
ctx
:
Context
)
->
None
:
def
draw
(
self
,
ctx
:
Context
)
->
None
:
ctx
.
text_align
=
ctx
.
LEFT
ctx
.
text_align
=
ctx
.
LEFT
ctx
.
text
(
self
.
_tunable
.
value
if
self
.
_tunable
.
value
else
""
)
ctx
.
text
(
str
(
self
.
_tunable
.
value
)
if
self
.
_tunable
.
value
else
""
)
def
press
(
self
,
vm
:
Optional
[
ViewManager
])
->
None
:
# Text input not supported at the moment
pass
# TODO: invert Tunable <-> Widget dependency to be able to define multiple different widget renderings for the same underlying tunable type
class
ObfuscatedStringTunable
(
UnaryTunable
):
"""
ObfuscatedStringTunable is a UnaryTunable that has a string value that should not be revealed openly.
"""
def
__init__
(
self
,
name
:
str
,
key
:
str
,
default
:
Optional
[
str
])
->
None
:
super
().
__init__
(
name
,
key
,
default
)
def
get_widget
(
self
)
->
TunableWidget
:
return
ObfuscatedValueWidget
(
self
)
def
press
(
self
,
vm
:
Optional
[
ViewManager
])
->
None
:
# Text input not supported at the moment
pass
class
ObfuscatedValueWidget
(
TunableWidget
):
"""
ObfuscatedValueWidget is a TunableWidget for UnaryTunables. It renders three asterisks when the tunable contains a truthy value, otherwise nothing.
"""
def
__init__
(
self
,
tunable
:
UnaryTunable
)
->
None
:
self
.
_tunable
=
tunable
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
# Nothing to do here
pass
def
draw
(
self
,
ctx
:
Context
)
->
None
:
ctx
.
text_align
=
ctx
.
LEFT
if
self
.
_tunable
.
value
:
ctx
.
text
(
"
***
"
)
def
press
(
self
,
vm
:
Optional
[
ViewManager
])
->
None
:
def
press
(
self
,
vm
:
Optional
[
ViewManager
])
->
None
:
# Text input not supported at the moment
# Text input not supported at the moment
...
@@ -346,7 +386,7 @@ onoff_debug_touch = OnOffTunable("Touch Overlay", "system.debug_touch", False)
...
@@ -346,7 +386,7 @@ onoff_debug_touch = OnOffTunable("Touch Overlay", "system.debug_touch", False)
onoff_show_tray
=
OnOffTunable
(
"
Show Icons
"
,
"
system.show_icons
"
,
True
)
onoff_show_tray
=
OnOffTunable
(
"
Show Icons
"
,
"
system.show_icons
"
,
True
)
onoff_wifi
=
OnOffTunable
(
"
Enable WiFi
"
,
"
system.wifi.enabled
"
,
False
)
onoff_wifi
=
OnOffTunable
(
"
Enable WiFi
"
,
"
system.wifi.enabled
"
,
False
)
str_wifi_ssid
=
StringTunable
(
"
WiFi SSID
"
,
"
system.wifi.ssid
"
,
"
Camp2023-open
"
)
str_wifi_ssid
=
StringTunable
(
"
WiFi SSID
"
,
"
system.wifi.ssid
"
,
"
Camp2023-open
"
)
str_wifi_psk
=
StringTunable
(
"
WiFi Password
"
,
"
system.wifi.psk
"
,
None
)
str_wifi_psk
=
Obfuscated
StringTunable
(
"
WiFi Password
"
,
"
system.wifi.psk
"
,
None
)
str_hostname
=
StringTunable
(
"
Hostname
"
,
"
system.hostname
"
,
"
flow3r
"
)
str_hostname
=
StringTunable
(
"
Hostname
"
,
"
system.hostname
"
,
"
flow3r
"
)
# List of all settings to be loaded/saved
# List of all settings to be loaded/saved
...
@@ -379,7 +419,7 @@ settings_menu_structure: "MenuStructure" = [
...
@@ -379,7 +419,7 @@ settings_menu_structure: "MenuStructure" = [
onoff_button_swap
,
onoff_button_swap
,
onoff_debug
,
onoff_debug
,
onoff_debug_touch
,
onoff_debug_touch
,
(
"
Wi
f
i
"
,
wifi_settings
),
(
"
Wi
F
i
"
,
wifi_settings
),
]
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment