extmod/modbluetooth: Merge gatts_notify/indicate implementation.
Makes gatts_notify and gatts_indicate work in the same way: by default they send the DB value, but you can manually override the payload. In other words, makes gatts_indicate work the same as gatts_notify. Note: This removes support for queuing notifications and indications on btstack when the ACL buffer is full. This functionality will be reimplemented in a future commit. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
@@ -186,6 +186,10 @@
|
||||
#define MP_BLUETOOTH_PASSKEY_ACTION_DISPLAY (3)
|
||||
#define MP_BLUETOOTH_PASSKEY_ACTION_NUMERIC_COMPARISON (4)
|
||||
|
||||
// These are the ops for mp_bluetooth_gatts_notify_indicate.
|
||||
#define MP_BLUETOOTH_GATTS_OP_NOTIFY (1)
|
||||
#define MP_BLUETOOTH_GATTS_OP_INDICATE (2)
|
||||
|
||||
/*
|
||||
These aren't included in the module for space reasons, but can be used
|
||||
in your Python code if necessary.
|
||||
@@ -333,15 +337,11 @@ int mp_bluetooth_gatts_register_service(mp_obj_bluetooth_uuid_t *service_uuid, m
|
||||
int mp_bluetooth_gatts_register_service_end(void);
|
||||
|
||||
// Read the value from the local gatts db (likely this has been written by a central).
|
||||
int mp_bluetooth_gatts_read(uint16_t value_handle, uint8_t **value, size_t *value_len);
|
||||
int mp_bluetooth_gatts_read(uint16_t value_handle, const uint8_t **value, size_t *value_len);
|
||||
// Write a value to the local gatts db (ready to be queried by a central). Optionally send notifications/indications.
|
||||
int mp_bluetooth_gatts_write(uint16_t value_handle, const uint8_t *value, size_t value_len, bool send_update);
|
||||
// Notify the central that it should do a read.
|
||||
int mp_bluetooth_gatts_notify(uint16_t conn_handle, uint16_t value_handle);
|
||||
// Notify the central, including a data payload. (Note: does not set the gatts db value).
|
||||
int mp_bluetooth_gatts_notify_send(uint16_t conn_handle, uint16_t value_handle, const uint8_t *value, size_t value_len);
|
||||
// Indicate the central.
|
||||
int mp_bluetooth_gatts_indicate(uint16_t conn_handle, uint16_t value_handle);
|
||||
// Send a notification/indication to the central, optionally with custom payload (otherwise the DB value is used).
|
||||
int mp_bluetooth_gatts_notify_indicate(uint16_t conn_handle, uint16_t value_handle, int gatts_op, const uint8_t *value, size_t value_len);
|
||||
|
||||
// Resize and enable/disable append-mode on a value.
|
||||
// Append-mode means that remote writes will append and local reads will clear after reading.
|
||||
@@ -508,7 +508,7 @@ STATIC inline void mp_bluetooth_gatts_db_reset(mp_gatts_db_t db) {
|
||||
|
||||
void mp_bluetooth_gatts_db_create_entry(mp_gatts_db_t db, uint16_t handle, size_t len);
|
||||
mp_bluetooth_gatts_db_entry_t *mp_bluetooth_gatts_db_lookup(mp_gatts_db_t db, uint16_t handle);
|
||||
int mp_bluetooth_gatts_db_read(mp_gatts_db_t db, uint16_t handle, uint8_t **value, size_t *value_len);
|
||||
int mp_bluetooth_gatts_db_read(mp_gatts_db_t db, uint16_t handle, const uint8_t **value, size_t *value_len);
|
||||
int mp_bluetooth_gatts_db_write(mp_gatts_db_t db, uint16_t handle, const uint8_t *value, size_t value_len);
|
||||
int mp_bluetooth_gatts_db_resize(mp_gatts_db_t db, uint16_t handle, size_t len, bool append);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user