summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bluetooth-adapter.c14
-rw-r--r--src/bluetooth-common.c20
-rw-r--r--src/bluetooth-device.c17
-rw-r--r--src/bluetooth-gatt.c4
-rw-r--r--src/bluetooth-pan.c17
5 files changed, 69 insertions, 3 deletions
diff --git a/src/bluetooth-adapter.c b/src/bluetooth-adapter.c
index 46c2947..ba125ce 100644
--- a/src/bluetooth-adapter.c
+++ b/src/bluetooth-adapter.c
@@ -243,6 +243,7 @@ int bt_adapter_foreach_bonded_device(bt_adapter_bonded_device_cb foreach_cb, voi
}
if (dev_list != NULL) {
+ g_ptr_array_foreach(dev_list, (GFunc)g_free, NULL);
g_ptr_array_free(dev_list, TRUE);
}
@@ -428,6 +429,19 @@ int bt_adapter_start_device_discovery(void)
return error_code;
}
+int bt_adapter_start_discover_devices(bt_adapter_discover_devices_type_e type)
+{
+ int error_code = BT_ERROR_NONE;
+
+ BT_CHECK_INIT_STATUS();
+ error_code = _bt_get_error_code(bluetooth_start_custom_discovery(type,
+ 0, 0, BLUETOOTH_DEVICE_MAJOR_MASK_MISC));
+ if (error_code != BT_ERROR_NONE) {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error_code), error_code);
+ }
+ return error_code;
+}
+
int bt_adapter_stop_device_discovery(void)
{
int error_code = BT_ERROR_NONE;
diff --git a/src/bluetooth-common.c b/src/bluetooth-common.c
index 67a6cc1..7d01ba3 100644
--- a/src/bluetooth-common.c
+++ b/src/bluetooth-common.c
@@ -68,7 +68,9 @@ static bt_event_sig_event_slot_s bt_event_slot_container[] = {
{BT_EVENT_HID_CONNECTION_STATUS, NULL, NULL},
{BT_EVENT_DEVICE_CONNECTION_STATUS, NULL, NULL},
{BT_EVENT_GATT_CHARACTERISTIC_DISCOVERED, NULL, NULL},
- {BT_EVENT_GATT_VALUE_CHANGED, NULL, NULL}
+ {BT_EVENT_GATT_VALUE_CHANGED, NULL, NULL},
+ {BT_EVENT_GATT_READ_CHARACTERISTIC, NULL, NULL},
+ {BT_EVENT_GATT_WRITE_CHARACTERISTIC, NULL, NULL}
};
/*
@@ -184,6 +186,8 @@ int _bt_get_error_code(int origin_error)
return BT_ERROR_REMOTE_DEVICE_NOT_FOUND;
case BLUETOOTH_ERROR_SERVICE_SEARCH_ERROR:
return BT_ERROR_SERVICE_SEARCH_FAILED;
+ case BLUETOOTH_ERROR_PERMISSION_DEINED :
+ return BT_ERROR_PERMISSION_DENIED;
case BLUETOOTH_ERROR_SERVICE_NOT_FOUND:
case BLUETOOTH_ERROR_PARING_FAILED:
case BLUETOOTH_ERROR_MAX_CONNECTION:
@@ -526,6 +530,7 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
(_bt_get_error_code(param->result), BT_ADAPTER_DEVICE_DISCOVERY_FINISHED, NULL, bt_event_slot_container[event_index].user_data);
break;
case BLUETOOTH_EVENT_REMOTE_DEVICE_NAME_UPDATED:
+ case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
BT_INFO("bt_adapter_device_discovery_state_changed_cb() will be called with BT_ADAPTER_DEVICE_DISCOVERY_FOUND");
if (__bt_get_bt_adapter_device_discovery_info_s(&discovery_info, (bluetooth_device_info_t *)(param->param_data)) == BT_ERROR_NONE) {
((bt_adapter_device_discovery_state_changed_cb)bt_event_slot_container[event_index].callback)
@@ -1062,7 +1067,11 @@ static void __bt_event_proxy(int event, bluetooth_event_param_t *param, void *us
bt_event_slot_container[event_index].user_data);
break;
+ case BLUETOOTH_EVENT_GATT_READ_CHAR:
+ BT_INFO("BLUETOOTH_EVENT_GATT_READ_CHAR");
+ break;
default:
+ BT_INFO("__bt_event_proxy default case %d",event);
break;
}
}
@@ -1161,6 +1170,11 @@ static int __bt_get_cb_index(int event)
case BLUETOOTH_EVENT_DEVICE_CONNECTED:
case BLUETOOTH_EVENT_DEVICE_DISCONNECTED:
return BT_EVENT_DEVICE_CONNECTION_STATUS;
+ case BLUETOOTH_EVENT_GATT_CONNECTED:
+ case BLUETOOTH_EVENT_GATT_DISCONNECTED:
+ return BT_EVENT_GATT_CONNECTION_STATUS;
+ case BLUETOOTH_EVENT_GATT_RSSI:
+ return BT_EVENT_GATT_RSSI_VALUE;
case BLUETOOTH_EVENT_SERVICE_SEARCHED:
return BT_EVENT_SERVICE_SEARCHED;
case BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED:
@@ -1252,6 +1266,10 @@ static int __bt_get_cb_index(int event)
return BT_EVENT_GATT_CHARACTERISTIC_DISCOVERED;
case BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED:
return BT_EVENT_GATT_VALUE_CHANGED;
+ case BLUETOOTH_EVENT_GATT_READ_CHAR:
+ return BT_EVENT_GATT_READ_CHARACTERISTIC;
+ case BLUETOOTH_EVENT_GATT_WRITE_CHAR:
+ return BT_EVENT_GATT_WRITE_CHARACTERISTIC;
default:
return -1;
}
diff --git a/src/bluetooth-device.c b/src/bluetooth-device.c
index 442f0b9..85c6a9a 100644
--- a/src/bluetooth-device.c
+++ b/src/bluetooth-device.c
@@ -255,3 +255,20 @@ int bt_device_unset_connection_state_changed_cb(void)
return BT_ERROR_NONE;
}
+int bt_device_read_rssi_value(const char *address)
+{
+ int ret;
+ bluetooth_device_address_t bd_addr = { {0,} };
+
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(address);
+
+ _bt_convert_address_to_hex(&bd_addr, address);
+
+ ret = _bt_get_error_code(bluetooth_read_rssi(&bd_addr));
+
+ if (ret != BT_ERROR_NONE) {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
+ }
+ return ret;
+}
diff --git a/src/bluetooth-gatt.c b/src/bluetooth-gatt.c
index b159fb0..19315c4 100644
--- a/src/bluetooth-gatt.c
+++ b/src/bluetooth-gatt.c
@@ -211,7 +211,7 @@ int bt_gatt_get_characteristic_declaration(bt_gatt_attribute_h characteristic,
BT_CHECK_INIT_STATUS();
BT_CHECK_INPUT_PARAMETER(characteristic);
- memset(&property, 0x00, sizeof(bt_gatt_service_property_t));
+ memset(&property, 0x00, sizeof(bt_gatt_char_property_t));
ret = _bt_get_error_code(bluetooth_gatt_get_characteristics_property((const char *)characteristic, &property));
@@ -250,7 +250,7 @@ int bt_gatt_set_characteristic_value(bt_gatt_attribute_h characteristic,
return BT_ERROR_INVALID_PARAMETER;
ret = _bt_get_error_code(bluetooth_gatt_set_characteristics_value((const char *)characteristic,
- (const guint8 *)value, value_length));
+ (const guint8 *)value, value_length, 0));
if (ret != BT_ERROR_NONE) {
BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(ret), ret);
diff --git a/src/bluetooth-pan.c b/src/bluetooth-pan.c
index eb27268..740b429 100644
--- a/src/bluetooth-pan.c
+++ b/src/bluetooth-pan.c
@@ -70,6 +70,23 @@ int bt_nap_disconnect_all(void)
return error;
}
+int bt_nap_disconnect(const char *remote_address)
+{
+ int error = BT_ERROR_INVALID_PARAMETER;
+ bluetooth_device_address_t addr_hex = { {0,} };
+
+ BT_CHECK_INIT_STATUS();
+ BT_CHECK_INPUT_PARAMETER(remote_address);
+ _bt_convert_address_to_hex(&addr_hex, remote_address);
+ error = bluetooth_network_server_disconnect(&addr_hex);
+ error = _bt_get_error_code(error);
+ if (error != BT_ERROR_NONE) {
+ BT_ERR("%s(0x%08x)", _bt_convert_error_to_string(error),
+ error);
+ }
+ return error;
+}
+
int bt_nap_set_connection_state_changed_cb(
bt_nap_connection_state_changed_cb callback,
void *user_data)