Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
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
card10
firmware
Commits
7101fbc2
Commit
7101fbc2
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
fix(ble): Consume all events in ble app
parent
bcb6ccc1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!446
Initial MicroPython BLE support (GATTS)
Pipeline
#5130
passed
4 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
preload/apps/ble/__init__.py
+13
-7
13 additions, 7 deletions
preload/apps/ble/__init__.py
with
13 additions
and
7 deletions
preload/apps/ble/__init__.py
+
13
−
7
View file @
7101fbc2
...
...
@@ -6,7 +6,7 @@ import sys_ble
import
interrupt
import
config
ble_event
=
None
ble_event
s
=
[]
is_active
=
False
STATE_IDLE
=
1
...
...
@@ -16,8 +16,13 @@ STATE_FAIL = 4
def
ble_callback
(
_
):
global
ble_event
ble_event
=
sys_ble
.
get_event
()
global
ble_events
while
True
:
event
=
sys_ble
.
get_event
()
if
event
==
sys_ble
.
EVENT_NONE
:
break
ble_events
.
append
(
event
)
def
init
():
...
...
@@ -95,6 +100,11 @@ while True:
v
=
~
v_old
&
v_new
v_old
=
v_new
ble_event
=
None
if
len
(
ble_events
)
>
0
:
ble_event
=
ble_events
[
0
]
ble_events
=
ble_events
[
1
:]
if
state
==
STATE_IDLE
:
# print config screen
disp
.
clear
()
...
...
@@ -104,7 +114,6 @@ while True:
# wait for button press or ble_event
if
ble_event
==
sys_ble
.
EVENT_HANDLE_NUMERIC_COMPARISON
:
ble_event
=
None
state
=
STATE_NUMERIC_COMPARISON
if
v
&
buttons
.
TOP_RIGHT
:
toggle
()
...
...
@@ -128,7 +137,6 @@ while True:
# wait for button press or ble_event
if
ble_event
==
sys_ble
.
EVENT_PAIRING_FAILED
:
ble_event
=
None
state
=
STATE_FAIL
if
v
&
buttons
.
BOTTOM_LEFT
:
sys_ble
.
confirm_compare_value
(
True
)
...
...
@@ -144,10 +152,8 @@ while True:
elif
state
==
STATE_WAIT_FOR_COMPLETION
:
# Wait for pairing to complete
if
ble_event
==
sys_ble
.
EVENT_PAIRING_FAILED
:
ble_event
=
None
state
=
STATE_FAIL
elif
ble_event
==
sys_ble
.
EVENT_PAIRING_COMPLETE
:
ble_event
=
None
pairing_name
=
sys_ble
.
get_last_pairing_name
().
split
(
"
/
"
)[
-
1
].
split
(
"
.
"
)[
0
]
disp
.
clear
()
disp
.
print
(
"
BLE Pairing
"
,
posy
=
0
,
fg
=
[
0
,
0
,
255
])
...
...
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