--- src/shared/gatt-db.c | 23 +++++++++++++++++++++++ src/shared/gatt-db.h | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index dfe1a76..e562695 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -704,6 +704,29 @@ bool gatt_db_read(struct gatt_db *db, uint16_t handle, uint16_t offset, a->read_func(handle, offset, req_data, cb, a->user_data); + return true; +} + +bool gatt_db_write(struct gatt_db *db, uint16_t handle, uint16_t offset, + const uint8_t *value, size_t len, void *req_data, + gatt_db_complete_func_t cb) +{ + struct gatt_db_service *service; + uint16_t service_handle; + struct gatt_db_attribute *a; + + service = queue_find(db->services, find_service_for_handle, + INT_TO_PTR(handle)); + if (!service) + return false; + + service_handle = service->attributes[0]->handle; + + a = service->attributes[handle - service_handle]; + if (!a || !a->write_func) + return false; + + a->write_func(handle, offset, value, len, req_data, cb, a->user_data); return true; } diff --git a/src/shared/gatt-db.h b/src/shared/gatt-db.h index 9a56c51..90fa66e 100644 --- a/src/shared/gatt-db.h +++ b/src/shared/gatt-db.h @@ -112,3 +112,7 @@ void gatt_db_find_information(struct gatt_db *db, uint16_t start_handle, bool gatt_db_read(struct gatt_db *db, uint16_t handle, uint16_t offset, void *req_data, gatt_db_complete_func_t complete_cb); + +bool gatt_db_write(struct gatt_db *db, uint16_t handle, uint16_t offset, + const uint8_t *value, size_t len, void *req_data, + gatt_db_complete_func_t complete_cb); -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html