Skip to content
Snippets Groups Projects
Commit ea13596b authored by schneider's avatar schneider
Browse files

change(mp): Plug in MP v1.14

parent 68a8906a
Branches
Tags
1 merge request!452change(mp): Plug in MP v1.14
Pipeline #5143 passed
Subproject commit b0932fcf2e2f9a81abf7737ed4b2573bd9ad4a49
Subproject commit 78b23c3a1f064dc19bbee68930ef3aba110c781c
......@@ -30,6 +30,14 @@ typedef struct {
static bool active = false;
static mp_obj_bluetooth_uuid_t uuid_filter;
const char *const not_implemented_message =
"Not (yet) implemented on card10. See https://git.card10.badge.events.ccc.de/card10/firmware/-/issues/8";
static void raise(void)
{
mp_raise_NotImplementedError(not_implemented_message);
}
static void gatts_status_create_entry(mp_gatts_db_t db, uint16_t handle)
{
mp_map_elem_t *elem = mp_map_lookup(
......@@ -213,18 +221,14 @@ static void handle_att_event(struct epic_att_event *att_event)
}
if (att_event->hdr.event == ATTC_READ_RSP) {
mp_uint_t atomic_state;
size_t len = mp_bluetooth_gattc_on_data_available_start(
mp_bluetooth_gattc_on_data_available(
MP_BLUETOOTH_IRQ_GATTC_READ_RESULT,
1,
att_event->handle,
att_event->valueLen,
&atomic_state
(const uint8_t **)&att_event->pValue,
&att_event->valueLen,
1
);
mp_bluetooth_gattc_on_data_available_chunk(
att_event->pValue, len
);
mp_bluetooth_gattc_on_data_available_end(atomic_state);
mp_bluetooth_gattc_on_read_write_status(
MP_BLUETOOTH_IRQ_GATTC_READ_DONE,
1,
......@@ -238,18 +242,14 @@ static void handle_att_event(struct epic_att_event *att_event)
uint16_t ev = att_event->hdr.event == ATTC_HANDLE_VALUE_NTF ?
MP_BLUETOOTH_IRQ_GATTC_NOTIFY :
MP_BLUETOOTH_IRQ_GATTC_INDICATE;
mp_uint_t atomic_state;
size_t len = mp_bluetooth_gattc_on_data_available_start(
mp_bluetooth_gattc_on_data_available(
ev,
1,
att_event->handle,
att_event->valueLen,
&atomic_state
);
mp_bluetooth_gattc_on_data_available_chunk(
att_event->pValue, len
(const uint8_t **)&att_event->pValue,
&att_event->valueLen,
1
);
mp_bluetooth_gattc_on_data_available_end(atomic_state);
}
if (att_event->hdr.event == ATTC_WRITE_RSP) {
......@@ -368,12 +368,19 @@ bool mp_bluetooth_is_active(void)
return active;
}
// Gets the MAC addr of this device in big-endian format.
void mp_bluetooth_get_device_addr(uint8_t *addr)
// Gets the current address of this device in big-endian format.
void mp_bluetooth_get_current_address(uint8_t *addr_type, uint8_t *addr)
{
*addr_type = 0; // Public address
epic_ble_get_address(addr);
}
// Sets the addressing mode to use.
void mp_bluetooth_set_address_mode(uint8_t addr_mode)
{
raise();
}
size_t mp_bluetooth_gap_get_device_name(const uint8_t **buf)
{
uint16_t len;
......@@ -427,14 +434,14 @@ int mp_bluetooth_gatts_register_service_begin(bool append)
return 0;
}
// // Add a service with the given list of characteristics to the queue to be registered.
// Add a service with the given list of characteristics to the queue to be registered.
// The value_handles won't be valid until after mp_bluetooth_register_service_end is called.
int mp_bluetooth_gatts_register_service(
mp_obj_bluetooth_uuid_t *service_uuid,
mp_obj_bluetooth_uuid_t **characteristic_uuids,
uint8_t *characteristic_flags,
uint16_t *characteristic_flags,
mp_obj_bluetooth_uuid_t **descriptor_uuids,
uint8_t *descriptor_flags,
uint16_t *descriptor_flags,
uint8_t *num_descriptors,
uint16_t *handles,
size_t num_characteristics
......@@ -682,15 +689,20 @@ int mp_bluetooth_gap_disconnect(uint16_t conn_handle)
return 0;
}
#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
const char *const not_implemented_message =
"Not (yet) implemented on card10. See https://git.card10.badge.events.ccc.de/card10/firmware/-/issues/8";
// Set/get the MTU that we will respond to a MTU exchange with.
int mp_bluetooth_get_preferred_mtu(void)
{
raise();
return 0;
}
static void raise(void)
int mp_bluetooth_set_preferred_mtu(uint16_t mtu)
{
mp_raise_NotImplementedError(not_implemented_message);
raise();
return 0;
}
#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
// Start a discovery (scan). Set duration to zero to run continuously.
int mp_bluetooth_gap_scan_start(
int32_t duration_ms,
......@@ -788,4 +800,11 @@ int mp_bluetooth_gattc_write(
}
return err;
}
// Initiate MTU exchange for a specific connection using the preferred MTU.
int mp_bluetooth_gattc_exchange_mtu(uint16_t conn_handle)
{
raise();
return 0;
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment