summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/bluetooth-adapter.c3
-rw-r--r--src/bluetooth-common.c55
-rw-r--r--src/bluetooth-gatt.c40
3 files changed, 6 insertions, 92 deletions
diff --git a/src/bluetooth-adapter.c b/src/bluetooth-adapter.c
index 8824c2d..1c5ff8c 100755
--- a/src/bluetooth-adapter.c
+++ b/src/bluetooth-adapter.c
@@ -1422,10 +1422,7 @@ static int __bt_convert_string_to_uuid(const char *string, char **uuid, int *bit
ret = sscanf(string, "%08x-%04hx-%04hx-%04hx-%08x%04hx",
&val0, &val1, &val2, &val3, &val4, &val5);
if (ret != 6)
- {
- g_free(data);
return BT_ERROR_OPERATION_FAILED;
- }
val0 = htonl(val0);
val1 = htons(val1);
diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c
index 90678cb..06f199b 100644
--- a/src/bluetooth-common.c
+++ b/src/bluetooth-common.c
@@ -610,43 +610,6 @@ static bt_gatt_server_notification_state_change_cb __bt_gatt_attribute_get_notif
return NULL;
}
-static bt_gatt_server_notification_sent_cb __bt_gatt_attribute_get_indication_confrim_cb(
- bt_gatt_h service, bt_gatt_h attribute, void **user_data)
-{
- gchar *svc_path = (gchar *)service;
- gchar *att_path = (gchar *)attribute;
- const GSList *gatt_server_list = NULL;
- const GSList *l1, *l2, *l3;
-
- gatt_server_list = _bt_gatt_get_server_list();
-
- for (l1 = gatt_server_list; l1 != NULL; l1 = l1->next) {
- bt_gatt_server_s *serv = l1->data;
-
- if (!serv)
- return NULL;
-
- for (l2 = serv->services; l2 != NULL; l2 = l2->next) {
- bt_gatt_service_s *svc = l2->data;
-
- if (g_strcmp0(svc->path, svc_path) == 0) {
- for (l3 = svc->characteristics; l3 != NULL; l3 = l3->next) {
- bt_gatt_characteristic_s *chr = l3->data;
-
- if (chr && g_strcmp0(chr->path, att_path) == 0) {
- if (chr->indication_confirm_cb) {
- *user_data = chr->indication_confirm_user_data;
- return chr->indication_confirm_cb;
- } else
- return NULL;
- }
- }
- }
- }
- }
- return NULL;
-}
-
static void __bt_free_bt_device_connection_info_s(bt_device_connection_info_s *conn_info)
{
if (conn_info == NULL)
@@ -778,7 +741,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
if (event == BLUETOOTH_EVENT_GATT_SERVER_VALUE_CHANGED || event == BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED ||
event == BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED || event == BLUETOOTH_EVENT_ADVERTISING_STARTED ||
- event == BLUETOOTH_EVENT_GATT_SERVER_INDICATE_CONFIRMED || event == BLUETOOTH_EVENT_ADVERTISING_STOPPED)
+ event == BLUETOOTH_EVENT_ADVERTISING_STOPPED)
BT_INFO("NOT use bt_event_slot_container");
else if (event_index == -1 || bt_event_slot_container[event_index].callback == NULL)
return;
@@ -1684,23 +1647,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
value_change->att_handle, user_data);
break;
}
- case BLUETOOTH_EVENT_GATT_SERVER_INDICATE_CONFIRMED: {
- bt_gatt_indicate_confirm_t *confrim_status = param->param_data;
- bt_gatt_server_notification_sent_cb cb;
- void *user_data = NULL;
- cb = __bt_gatt_attribute_get_indication_confrim_cb(confrim_status->service_handle,
- confrim_status->att_handle, &user_data);
-
- BT_INFO("BLUETOOTH_EVENT_GATT_SERVER_INDICATE_CONFIRMED");
- if (cb == NULL)
- return;
-
- cb(_bt_get_error_code(param->result), confrim_status->address,
- confrim_status->service_handle,
- confrim_status->att_handle, confrim_status->complete, user_data);
- break;
- }
#ifdef BT_ENABLE_LEGACY_GATT_CLIENT
case BLUETOOTH_EVENT_GATT_SVC_CHAR_DESC_DISCOVERED: {
BT_INFO("BLUETOOTH_EVENT_GATT_SVC_CHAR_DESC_DISCOVERED");
diff --git a/src/bluetooth-gatt.c b/src/bluetooth-gatt.c
index 21929dc..8e497bf 100644
--- a/src/bluetooth-gatt.c
+++ b/src/bluetooth-gatt.c
@@ -1021,7 +1021,7 @@ int bt_gatt_set_value(bt_gatt_h gatt_handle, const char *value, int value_length
}
if (handle->role == BT_GATT_ROLE_SERVER && handle->path) {
- ret = _bt_get_error_code(bluetooth_gatt_update_characteristic(handle->path, value, value_length));
+ ret = _bt_get_error_code(bluetooth_gatt_notify_characteristics_value_change(handle->path, value, value_length, NULL));
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
return ret;
@@ -1131,7 +1131,7 @@ int bt_gatt_set_int_value(bt_gatt_h gatt_handle, bt_data_type_int_e type, int va
}
if (handle->role == BT_GATT_ROLE_SERVER && handle->path) {
- ret = _bt_get_error_code(bluetooth_gatt_update_characteristic(handle->path, *val, *val_len));
+ ret = _bt_get_error_code(bluetooth_gatt_notify_characteristics_value_change(handle->path, *val, *val_len, NULL));
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
return ret;
@@ -1236,7 +1236,7 @@ int bt_gatt_set_float_value(bt_gatt_h gatt_handle, bt_data_type_float_e type,
}
if (handle->role == BT_GATT_ROLE_SERVER && handle->path) {
- ret = _bt_get_error_code(bluetooth_gatt_update_characteristic(handle->path, *val, *val_len));
+ ret = _bt_get_error_code(bluetooth_gatt_notify_characteristics_value_change(handle->path, *val, *val_len, NULL));
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
return ret;
@@ -2112,42 +2112,12 @@ int bt_gatt_server_send_response(int request_id,
}
int bt_gatt_server_notify(bt_gatt_h characteristic, bool need_confirm,
- bt_gatt_server_notification_sent_cb callback,
- const char *device_address, void *user_data)
+ bt_gatt_server_notification_sent_cb callback, void *user_data)
{
- bt_gatt_characteristic_s *chr = (bt_gatt_characteristic_s*)characteristic;
- bt_gatt_common_s *handle = (bt_gatt_common_s*)characteristic;
- bluetooth_device_address_t addr_hex = { {0,} };
- int ret = BT_ERROR_NONE;
-
BT_CHECK_INIT_STATUS();
BT_CHECK_GATT_SERVER_INIT_STATUS();
- BT_CHECK_INPUT_PARAMETER(characteristic);
- BT_CHECK_INPUT_PARAMETER(callback);
-
- _bt_convert_address_to_hex(&addr_hex, device_address);
-
- if (chr->value_length > 0 && chr->value) {
- if (handle->role == BT_GATT_ROLE_SERVER && handle->path) {
- ret = bluetooth_gatt_server_set_notification(handle->path, &addr_hex);
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- return ret;
- }
- ret = _bt_get_error_code(bluetooth_gatt_update_characteristic(handle->path, chr->value, chr->value_length));
- if (ret != BT_ERROR_NONE) {
- BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
- return ret;
- }
- }
- }
-
- if (need_confirm) {
- chr->indication_confirm_cb = callback;
- chr->indication_confirm_user_data = user_data;
- }
- return ret;
+ return BT_ERROR_NONE;
}
int bt_gatt_server_set_value_changed_cb(bt_gatt_h characteristic,