summaryrefslogtreecommitdiffstatshomepage
path: root/extmod/btstack/modbluetooth_btstack.c
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2020-11-03 17:46:11 +1100
committerDamien George <damien@micropython.org>2020-11-13 17:19:05 +1100
commitc398e46b29f5c780b8016f2e88afe4c6984c54d8 (patch)
tree77cfcb38d5133db94464e66c86f395229ab55371 /extmod/btstack/modbluetooth_btstack.c
parent4559bcb4679e04e0a5e24030675676ff6a9803f2 (diff)
downloadmicropython-c398e46b29f5c780b8016f2e88afe4c6984c54d8.tar.gz
micropython-c398e46b29f5c780b8016f2e88afe4c6984c54d8.zip
extmod/modbluetooth: Combine gattc-data-available callbacks into one.
Instead of having the stack indicate a "start", "data"..., "end", pass through the data in one callback as an array of chunks of data. This is because the upcoming non-ringbuffer modbluetooth implementation cannot buffer the data in the ringbuffer and requires instead a single callback with all the data, to pass to the Python callback. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'extmod/btstack/modbluetooth_btstack.c')
-rw-r--r--extmod/btstack/modbluetooth_btstack.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/extmod/btstack/modbluetooth_btstack.c b/extmod/btstack/modbluetooth_btstack.c
index fd5d343637..a4cc601746 100644
--- a/extmod/btstack/modbluetooth_btstack.c
+++ b/extmod/btstack/modbluetooth_btstack.c
@@ -414,30 +414,21 @@ STATIC void btstack_packet_handler(uint8_t packet_type, uint8_t *packet, uint8_t
uint16_t value_handle = gatt_event_characteristic_value_query_result_get_value_handle(packet);
uint16_t len = gatt_event_characteristic_value_query_result_get_value_length(packet);
const uint8_t *data = gatt_event_characteristic_value_query_result_get_value(packet);
- mp_uint_t atomic_state;
- len = mp_bluetooth_gattc_on_data_available_start(MP_BLUETOOTH_IRQ_GATTC_READ_RESULT, conn_handle, value_handle, len, &atomic_state);
- mp_bluetooth_gattc_on_data_available_chunk(data, len);
- mp_bluetooth_gattc_on_data_available_end(atomic_state);
+ mp_bluetooth_gattc_on_data_available(MP_BLUETOOTH_IRQ_GATTC_READ_RESULT, conn_handle, value_handle, &data, &len, 1);
} else if (event_type == GATT_EVENT_NOTIFICATION) {
DEBUG_printf(" --> gatt notification\n");
uint16_t conn_handle = gatt_event_notification_get_handle(packet);
uint16_t value_handle = gatt_event_notification_get_value_handle(packet);
uint16_t len = gatt_event_notification_get_value_length(packet);
const uint8_t *data = gatt_event_notification_get_value(packet);
- mp_uint_t atomic_state;
- len = mp_bluetooth_gattc_on_data_available_start(MP_BLUETOOTH_IRQ_GATTC_NOTIFY, conn_handle, value_handle, len, &atomic_state);
- mp_bluetooth_gattc_on_data_available_chunk(data, len);
- mp_bluetooth_gattc_on_data_available_end(atomic_state);
+ mp_bluetooth_gattc_on_data_available(MP_BLUETOOTH_IRQ_GATTC_NOTIFY, conn_handle, value_handle, &data, &len, 1);
} else if (event_type == GATT_EVENT_INDICATION) {
DEBUG_printf(" --> gatt indication\n");
uint16_t conn_handle = gatt_event_indication_get_handle(packet);
uint16_t value_handle = gatt_event_indication_get_value_handle(packet);
uint16_t len = gatt_event_indication_get_value_length(packet);
const uint8_t *data = gatt_event_indication_get_value(packet);
- mp_uint_t atomic_state;
- len = mp_bluetooth_gattc_on_data_available_start(MP_BLUETOOTH_IRQ_GATTC_INDICATE, conn_handle, value_handle, len, &atomic_state);
- mp_bluetooth_gattc_on_data_available_chunk(data, len);
- mp_bluetooth_gattc_on_data_available_end(atomic_state);
+ mp_bluetooth_gattc_on_data_available(MP_BLUETOOTH_IRQ_GATTC_INDICATE, conn_handle, value_handle, &data, &len, 1);
} else if (event_type == GATT_EVENT_CAN_WRITE_WITHOUT_RESPONSE) {
uint16_t conn_handle = gatt_event_can_write_without_response_get_handle(packet);
DEBUG_printf(" --> gatt can write without response %d\n", conn_handle);