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
bee7c425
Commit
bee7c425
authored
4 years ago
by
schneider
Browse files
Options
Downloads
Patches
Plain Diff
feat(mp-ble): Allow to register descriptors
parent
b4f339c5
No related branches found
No related tags found
1 merge request
!446
Initial MicroPython BLE support (GATTS)
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pycardium/modules/modbluetooth_card10.c
+33
-9
33 additions, 9 deletions
pycardium/modules/modbluetooth_card10.c
with
33 additions
and
9 deletions
pycardium/modules/modbluetooth_card10.c
+
33
−
9
View file @
bee7c425
...
@@ -391,10 +391,6 @@ int mp_bluetooth_gatts_register_service(
...
@@ -391,10 +391,6 @@ int mp_bluetooth_gatts_register_service(
size_t
num_descriptors_total
=
0
;
size_t
num_descriptors_total
=
0
;
size_t
num_ccds
=
0
;
size_t
num_ccds
=
0
;
for
(
size_t
i
=
0
;
i
<
num_characteristics
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
num_characteristics
;
i
++
)
{
if
(
num_descriptors
[
i
])
{
// TODO: more specific error
raise
();
}
num_descriptors_total
+=
num_descriptors
[
i
];
num_descriptors_total
+=
num_descriptors
[
i
];
if
((
characteristic_flags
[
i
]
&
if
((
characteristic_flags
[
i
]
&
MP_BLUETOOTH_CHARACTERISTIC_FLAG_NOTIFY
)
||
MP_BLUETOOTH_CHARACTERISTIC_FLAG_NOTIFY
)
||
...
@@ -409,7 +405,7 @@ int mp_bluetooth_gatts_register_service(
...
@@ -409,7 +405,7 @@ int mp_bluetooth_gatts_register_service(
1
+
num_characteristics
*
2
+
num_ccds
+
num_descriptors_total
;
1
+
num_characteristics
*
2
+
num_ccds
+
num_descriptors_total
;
uint16_t
startHandle
;
uint16_t
startHandle
;
uint
16
_t
uuid_len
=
uint
8
_t
uuid_len
=
service_uuid
->
type
==
MP_BLUETOOTH_UUID_TYPE_16
?
2
:
16
;
service_uuid
->
type
==
MP_BLUETOOTH_UUID_TYPE_16
?
2
:
16
;
// TODO: handle error
// TODO: handle error
...
@@ -423,12 +419,13 @@ int mp_bluetooth_gatts_register_service(
...
@@ -423,12 +419,13 @@ int mp_bluetooth_gatts_register_service(
uint16_t
currentHandle
=
startHandle
;
uint16_t
currentHandle
=
startHandle
;
size_t
descriptor_index
=
0
;
size_t
handle_index
=
0
;
size_t
handle_index
=
0
;
for
(
size_t
i
=
0
;
i
<
num_characteristics
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
num_characteristics
;
i
++
)
{
uint8_t
flags
=
characteristic_flags
[
i
];
uint8_t
flags
=
characteristic_flags
[
i
];
mp_obj_bluetooth_uuid_t
*
uuid
=
characteristic_uuids
[
i
];
mp_obj_bluetooth_uuid_t
*
uuid
=
characteristic_uuids
[
i
];
uint8_t
uuid_len
=
uuid_len
=
uuid
->
type
==
MP_BLUETOOTH_UUID_TYPE_16
?
2
:
16
;
uuid
->
type
==
MP_BLUETOOTH_UUID_TYPE_16
?
2
:
16
;
currentHandle
++
;
currentHandle
++
;
epic_atts_dyn_add_characteristic
(
epic_atts_dyn_add_characteristic
(
...
@@ -484,6 +481,33 @@ int mp_bluetooth_gatts_register_service(
...
@@ -484,6 +481,33 @@ int mp_bluetooth_gatts_register_service(
}
}
handle_index
++
;
handle_index
++
;
for
(
size_t
j
=
0
;
j
<
num_descriptors
[
i
];
j
++
)
{
flags
=
descriptor_flags
[
descriptor_index
];
mp_obj_bluetooth_uuid_t
*
uuid
=
descriptor_uuids
[
descriptor_index
];
uuid_len
=
uuid
->
type
==
MP_BLUETOOTH_UUID_TYPE_16
?
2
:
16
;
epic_ble_atts_dyn_add_descriptor
(
pSvcHandle
,
uuid
->
data
,
uuid_len
,
flags
,
NULL
,
0
,
MP_BLUETOOTH_DEFAULT_ATTR_LEN
);
mp_bluetooth_gatts_db_create_entry
(
GATTS_DB
,
handles
[
handle_index
],
MP_BLUETOOTH_DEFAULT_ATTR_LEN
);
descriptor_index
++
;
handle_index
++
;
}
}
}
return
0
;
return
0
;
...
...
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