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
8c7cd9ad
Commit
8c7cd9ad
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
feat(ble): pycardium support for scanning
parent
bbb027ba
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!392
Show COVID-19 exposure notification statistics
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pycardium/modules/qstrdefs.h
+3
-0
3 additions, 0 deletions
pycardium/modules/qstrdefs.h
pycardium/modules/sys_ble.c
+35
-0
35 additions, 0 deletions
pycardium/modules/sys_ble.c
with
38 additions
and
0 deletions
pycardium/modules/qstrdefs.h
+
3
−
0
View file @
8c7cd9ad
...
...
@@ -199,11 +199,14 @@ Q(get_string)
Q
(
BLE
)
Q
(
ble
)
Q
(
get_compare_value
)
Q
(
get_scan_report
)
Q
(
confirm_compare_value
)
Q
(
set_bondable
)
Q
(
scan_start
)
Q
(
get_event
)
Q
(
EVENT_NONE
)
Q
(
EVENT_HANDLE_NUMERIC_COMPARISON
)
Q
(
EVENT_PAIRING_COMPLETE
)
Q
(
EVENT_PAIRING_FAILED
)
Q
(
EVENT_SCAN_REPORT
)
This diff is collapsed.
Click to expand it.
pycardium/modules/sys_ble.c
+
35
−
0
View file @
8c7cd9ad
...
...
@@ -24,6 +24,29 @@ static MP_DEFINE_CONST_FUN_OBJ_0(
ble_get_compare_value_obj
,
mp_ble_get_compare_value
);
static
mp_obj_t
mp_ble_get_scan_report
(
void
)
{
struct
epic_scan_report
scan_report
;
int
ret
=
epic_ble_get_scan_report
(
&
scan_report
);
if
(
ret
<
0
)
{
return
mp_const_none
;
}
mp_obj_t
data
=
mp_obj_new_bytes
(
scan_report
.
data
,
scan_report
.
len
);
mp_obj_t
rssi
=
MP_OBJ_NEW_SMALL_INT
(
scan_report
.
rssi
);
mp_obj_t
eventType
=
MP_OBJ_NEW_SMALL_INT
(
scan_report
.
eventType
);
mp_obj_t
addrType
=
MP_OBJ_NEW_SMALL_INT
(
scan_report
.
addrType
);
mp_obj_t
addr
=
mp_obj_new_bytes
(
scan_report
.
addr
,
6
);
mp_obj_t
values_list
[]
=
{
data
,
rssi
,
eventType
,
addrType
,
addr
};
return
mp_obj_new_tuple
(
5
,
values_list
);
}
static
MP_DEFINE_CONST_FUN_OBJ_0
(
ble_get_scan_report_obj
,
mp_ble_get_scan_report
);
static
mp_obj_t
mp_ble_get_event
(
void
)
{
return
mp_obj_new_int
(
epic_ble_get_event
());
...
...
@@ -38,15 +61,25 @@ static mp_obj_t mp_ble_set_bondable(mp_obj_t bondable_obj)
}
static
MP_DEFINE_CONST_FUN_OBJ_1
(
ble_set_bondable_obj
,
mp_ble_set_bondable
);
static
mp_obj_t
mp_ble_scan_start
()
{
epic_ble_set_mode
(
false
,
true
);
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_0
(
ble_scan_start_obj
,
mp_ble_scan_start
);
static
const
mp_rom_map_elem_t
ble_module_globals_table
[]
=
{
{
MP_ROM_QSTR
(
MP_QSTR___name__
),
MP_ROM_QSTR
(
MP_QSTR_sys_ble
)
},
{
MP_ROM_QSTR
(
MP_QSTR_confirm_compare_value
),
MP_ROM_PTR
(
&
ble_confirm_compare_value_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_get_compare_value
),
MP_ROM_PTR
(
&
ble_get_compare_value_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_get_scan_report
),
MP_ROM_PTR
(
&
ble_get_scan_report_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_get_event
),
MP_ROM_PTR
(
&
ble_get_event_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_set_bondable
),
MP_ROM_PTR
(
&
ble_set_bondable_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_scan_start
),
MP_ROM_PTR
(
&
ble_scan_start_obj
)
},
/* Event Numbers */
{
MP_ROM_QSTR
(
MP_QSTR_EVENT_NONE
),
...
...
@@ -57,6 +90,8 @@ static const mp_rom_map_elem_t ble_module_globals_table[] = {
MP_OBJ_NEW_SMALL_INT
(
BLE_EVENT_PAIRING_FAILED
)
},
{
MP_ROM_QSTR
(
MP_QSTR_EVENT_PAIRING_COMPLETE
),
MP_OBJ_NEW_SMALL_INT
(
BLE_EVENT_PAIRING_COMPLETE
)
},
{
MP_ROM_QSTR
(
MP_QSTR_EVENT_SCAN_REPORT
),
MP_OBJ_NEW_SMALL_INT
(
BLE_EVENT_SCAN_REPORT
)
},
};
static
MP_DEFINE_CONST_DICT
(
ble_module_globals
,
ble_module_globals_table
);
...
...
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