Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
3c7ca200
Commit
3c7ca200
authored
Jul 20, 2020
by
Jim Mussared
Committed by
Damien George
Jul 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extmod/modbluetooth: Fix so it builds in peripheral-only mode.
parent
43ceadac
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
18 deletions
+23
-18
extmod/btstack/modbluetooth_btstack.c
extmod/btstack/modbluetooth_btstack.c
+12
-10
extmod/btstack/modbluetooth_btstack.h
extmod/btstack/modbluetooth_btstack.h
+2
-1
extmod/modbluetooth.c
extmod/modbluetooth.c
+2
-0
extmod/nimble/modbluetooth_nimble.c
extmod/nimble/modbluetooth_nimble.c
+7
-7
No files found.
extmod/btstack/modbluetooth_btstack.c
View file @
3c7ca200
...
...
@@ -70,6 +70,7 @@ STATIC int btstack_error_to_errno(int err) {
}
}
#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
STATIC
mp_obj_bluetooth_uuid_t
create_mp_uuid
(
uint16_t
uuid16
,
const
uint8_t
*
uuid128
)
{
mp_obj_bluetooth_uuid_t
result
;
if
(
uuid16
!=
0
)
{
...
...
@@ -82,6 +83,7 @@ STATIC mp_obj_bluetooth_uuid_t create_mp_uuid(uint16_t uuid16, const uint8_t *uu
}
return
result
;
}
#endif
// Notes on supporting background ops (e.g. an attempt to gatts_notify while
// an existing notification is in progress):
...
...
@@ -286,16 +288,6 @@ STATIC void btstack_packet_handler(uint8_t packet_type, uint8_t *packet, uint8_t
DEBUG_EVENT_printf
(
" --> btstack # conns changed
\n
"
);
}
else
if
(
event_type
==
HCI_EVENT_VENDOR_SPECIFIC
)
{
DEBUG_EVENT_printf
(
" --> hci vendor specific
\n
"
);
}
else
if
(
event_type
==
GAP_EVENT_ADVERTISING_REPORT
)
{
DEBUG_EVENT_printf
(
" --> gap advertising report
\n
"
);
bd_addr_t
address
;
gap_event_advertising_report_get_address
(
packet
,
address
);
uint8_t
adv_event_type
=
gap_event_advertising_report_get_advertising_event_type
(
packet
);
uint8_t
address_type
=
gap_event_advertising_report_get_address_type
(
packet
);
int8_t
rssi
=
gap_event_advertising_report_get_rssi
(
packet
);
uint8_t
length
=
gap_event_advertising_report_get_data_length
(
packet
);
const
uint8_t
*
data
=
gap_event_advertising_report_get_data
(
packet
);
mp_bluetooth_gap_on_scan_result
(
address_type
,
address
,
adv_event_type
,
rssi
,
data
,
length
);
}
else
if
(
event_type
==
HCI_EVENT_DISCONNECTION_COMPLETE
)
{
DEBUG_EVENT_printf
(
" --> hci disconnect complete
\n
"
);
uint16_t
conn_handle
=
hci_event_disconnection_complete_get_connection_handle
(
packet
);
...
...
@@ -311,6 +303,16 @@ STATIC void btstack_packet_handler(uint8_t packet_type, uint8_t *packet, uint8_t
uint8_t
addr
[
6
]
=
{
0
};
mp_bluetooth_gap_on_connected_disconnected
(
irq_event
,
conn_handle
,
0xff
,
addr
);
#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
}
else
if
(
event_type
==
GAP_EVENT_ADVERTISING_REPORT
)
{
DEBUG_EVENT_printf
(
" --> gap advertising report
\n
"
);
bd_addr_t
address
;
gap_event_advertising_report_get_address
(
packet
,
address
);
uint8_t
adv_event_type
=
gap_event_advertising_report_get_advertising_event_type
(
packet
);
uint8_t
address_type
=
gap_event_advertising_report_get_address_type
(
packet
);
int8_t
rssi
=
gap_event_advertising_report_get_rssi
(
packet
);
uint8_t
length
=
gap_event_advertising_report_get_data_length
(
packet
);
const
uint8_t
*
data
=
gap_event_advertising_report_get_data
(
packet
);
mp_bluetooth_gap_on_scan_result
(
address_type
,
address
,
adv_event_type
,
rssi
,
data
,
length
);
}
else
if
(
event_type
==
GATT_EVENT_QUERY_COMPLETE
)
{
uint16_t
conn_handle
=
gatt_event_query_complete_get_handle
(
packet
);
uint16_t
status
=
gatt_event_query_complete_get_att_status
(
packet
);
...
...
extmod/btstack/modbluetooth_btstack.h
View file @
3c7ca200
...
...
@@ -44,10 +44,11 @@ typedef struct _mp_bluetooth_btstack_root_pointers_t {
// Characteristic (and descriptor) value storage.
mp_gatts_db_t
gatts_db
;
btstack_linked_list_t
pending_ops
;
#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
// Registration for notify/indicate events.
gatt_client_notification_t
notification
;
btstack_linked_list_t
pending_ops
;
#endif
}
mp_bluetooth_btstack_root_pointers_t
;
...
...
extmod/modbluetooth.c
View file @
3c7ca200
...
...
@@ -836,10 +836,12 @@ STATIC void ringbuf_extract(ringbuf_t *ringbuf, mp_obj_tuple_t *data_tuple, size
// Note the int8_t got packed into the ringbuf as a uint8_t.
data_tuple
->
items
[
j
++
]
=
MP_OBJ_NEW_SMALL_INT
((
int8_t
)
ringbuf_get
(
ringbuf
));
}
#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
if
(
uuid
)
{
ringbuf_get_uuid
(
ringbuf
,
uuid
);
data_tuple
->
items
[
j
++
]
=
MP_OBJ_FROM_PTR
(
uuid
);
}
#endif
// The code that enqueues into the ringbuf should ensure that it doesn't
// put more than bt->irq_data_data_alloc bytes into the ringbuf, because
// that's what's available here in bt->irq_data_bytes.
...
...
extmod/nimble/modbluetooth_nimble.c
View file @
3c7ca200
...
...
@@ -96,6 +96,13 @@ STATIC ble_uuid_t *create_nimble_uuid(const mp_obj_bluetooth_uuid_t *uuid, ble_u
}
}
// modbluetooth (and the layers above it) work in BE for addresses, Nimble works in LE.
STATIC
void
reverse_addr_byte_order
(
uint8_t
*
addr_out
,
const
uint8_t
*
addr_in
)
{
for
(
int
i
=
0
;
i
<
6
;
++
i
)
{
addr_out
[
i
]
=
addr_in
[
5
-
i
];
}
}
#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
STATIC
mp_obj_bluetooth_uuid_t
create_mp_uuid
(
const
ble_uuid_any_t
*
uuid
)
{
...
...
@@ -123,13 +130,6 @@ STATIC mp_obj_bluetooth_uuid_t create_mp_uuid(const ble_uuid_any_t *uuid) {
return
result
;
}
// modbluetooth (and the layers above it) work in BE for addresses, Nimble works in LE.
STATIC
void
reverse_addr_byte_order
(
uint8_t
*
addr_out
,
const
uint8_t
*
addr_in
)
{
for
(
int
i
=
0
;
i
<
6
;
++
i
)
{
addr_out
[
i
]
=
addr_in
[
5
-
i
];
}
}
STATIC
ble_addr_t
create_nimble_addr
(
uint8_t
addr_type
,
const
uint8_t
*
addr
)
{
ble_addr_t
addr_nimble
;
addr_nimble
.
type
=
addr_type
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment