bt_gatt_server_destroy_func_t debug_destroy;
void *debug_data;
+ bt_gatt_server_authorize_cb_t authorize;
+ void *authorize_data;
+
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
bt_gatt_server_mtu_changed_callback_t mtu_chngd_callback;
bt_gatt_server_destroy_func_t mtu_chngd_destroy;
async_write_op_destroy(op);
}
+static uint8_t authorize_req(struct bt_gatt_server *server,
+ uint8_t opcode, uint16_t handle)
+{
+ if (!server->authorize)
+ return 0;
+
+ return server->authorize(server->att, opcode, handle,
+ server->authorize_data);
+}
+
static void write_cb(uint8_t opcode, const void *pdu,
uint16_t length, void *user_data)
{
goto error;
}
+ ecode = authorize_req(server, opcode, handle);
+ if (ecode)
+ goto error;
+
handle = get_le16(pdu);
attr = gatt_db_get_attribute(server->db, handle);
if (!attr) {
uint8_t ecode;
struct async_read_op *op = NULL;
+ ecode = authorize_req(server, opcode, handle);
+ if (ecode)
+ goto error;
+
attr = gatt_db_get_attribute(server->db, handle);
if (!attr) {
ecode = BT_ATT_ERROR_INVALID_HANDLE;
return result;
}
+bool bt_gatt_server_set_authorize(struct bt_gatt_server *server,
+ bt_gatt_server_authorize_cb_t cb,
+ void *user_data)
+{
+ if (!server)
+ return false;
+
+ server->authorize = cb;
+ server->authorize_data = user_data;
+
+ return true;
+}
+
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
bool bt_gatt_server_set_mtu_changed(struct bt_gatt_server *server,
bt_gatt_server_mtu_changed_callback_t callback,
void *user_data,
bt_gatt_server_destroy_func_t destroy);
+typedef uint8_t (*bt_gatt_server_authorize_cb_t)(struct bt_att *att,
+ uint8_t opcode, uint16_t handle,
+ void *user_data);
+bool bt_gatt_server_set_authorize(struct bt_gatt_server *server,
+ bt_gatt_server_authorize_cb_t cb,
+ void *user_data);
+
bool bt_gatt_server_send_notification(struct bt_gatt_server *server,
uint16_t handle, const uint8_t *value,
uint16_t length);