#include "bluetooth-gatt-server-api.h"
#endif
+#ifdef TIZEN_GATT_CLIENT
+#include "bluetooth-gatt-client-api.h"
+#endif
+
#include "bt-common.h"
#include "bt-request-sender.h"
#include "bt-event-handler.h"
NULL, /* GDBusAuthObserver */
NULL,
&error);
+ g_free(address);
if (!private_gconn) {
if (error) {
BT_ERR("Unable to connect to dbus: %s", error->message);
user_data);
}
+#ifdef TIZEN_GATT_CLIENT
+void _bt_gatt_client_event_cb(int event, int result, void *param,
+ void *callback, void *user_data)
+{
+ BT_DBG("__bt_gatt_client_event_cb");
+ gatt_client_event_param_t bt_event = { 0, 0, NULL, NULL };
+ bt_event.event = event;
+ bt_event.result = result;
+ bt_event.param_data = param;
+ if (callback) {
+ BT_DBG("GATT Client event callback is registered");
+ ((gatt_client_cb_func_ptr)callback)(bt_event.event, &bt_event,
+ user_data);
+ } else {
+ BT_ERR("GATT Client event callback is not registered!!!");
+ }
+}
+#endif
+
#ifndef GATT_DIRECT
void _bt_gatt_server_event_cb(int event, int result, void *param,
void *callback, void *user_data)
strncpy(addr, address, len);
addr[len] = '\0';
- addr[len-1] = 'X';
- addr[len-2] = 'X';
+ addr[len-7] = 'X';
+ addr[len-8] = 'X';
+ addr[len-10] = 'X';
+ addr[len-11] = 'X';
+ addr[len-13] = 'X';
+ addr[len-14] = 'X';
+ addr[len-16] = 'X';
+ addr[len-17] = 'X';
return;
}
ret_if(addr == NULL);
g_snprintf(address, BT_ADDRESS_STRING_SIZE,
- "%2.2X:%2.2X:%2.2X:%2.2X:XX:XX",
- addr[0], addr[1], addr[2], addr[3]);
+ "XX:XX:XX:XX:%2.2X:%2.2X", addr[4], addr[5]);
}
const char *_bt_convert_error_to_string(int error)
return "NOT_INITIALIZED";
case BLUETOOTH_ERROR_AUTHENTICATION_REJECTED:
return "AUTHENTICATION REJECTED";
+ case BLUETOOTH_ERROR_AUTHORIZATION_REJECTED:
+ return "AUTHORIZATION REJECTED";
default:
return "UNKNOWN";
}
GDBusNodeInfo * _bt_get_gdbus_node(const gchar *xml_data)
{
if (bus_id == 0) {
- char *name = g_strdup_printf("org.bt.frwk%d", getpid());
+ char *name = g_strdup_printf("org.bt.frwk.p%d", getpid());
bus_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
name,
proxy = g_dbus_proxy_new_sync(gconn, G_DBUS_PROXY_FLAGS_NONE, NULL,
BT_BLUEZ_NAME, object_path, BT_PROPERTIES_INTERFACE, NULL,
&err);
-
g_free(object_path);
-
- retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
- if (err) {
- BT_ERR("DBus Error: [%s]", err->message);
- g_clear_error(&err);
+ if (proxy == NULL) {
+ if (err) {
+ BT_ERR("DBus Error: [%s]", err->message);
+ g_clear_error(&err);
+ }
+ return BLUETOOTH_ERROR_INTERNAL;
}
ret = g_dbus_proxy_call_sync(proxy, "Get",
g_variant_new("(ss)", BT_DEVICE_INTERFACE, "UUIDs"),
GVariant *value = NULL;
GVariant *result = NULL;
unsigned int class = 0x00;
- int ret = BLUETOOTH_ERROR_INTERNAL;
+ int ret = BLUETOOTH_ERROR_NONE;
gconn = __get_gdbus_connection();
retv_if(gconn == NULL, BLUETOOTH_ERROR_INTERNAL);
- object_path = _bt_get_device_object_path(address);
+ object_path = _bt_get_device_object_path(address);
retv_if(object_path == NULL, BLUETOOTH_ERROR_INTERNAL);
proxy = g_dbus_proxy_new_sync(gconn, G_DBUS_PROXY_FLAGS_NONE, NULL,
BT_BLUEZ_NAME, object_path, BT_PROPERTIES_INTERFACE, NULL,
&err);
-
- g_free(object_path);
-
- retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
- if (err) {
- BT_ERR("DBus Error: [%s]", err->message);
- g_clear_error(&err);
+ if (proxy == NULL) {
+ ret = BLUETOOTH_ERROR_INTERNAL;
+ if (err) {
+ BT_ERR("DBus Error: [%s]", err->message);
+ g_clear_error(&err);
+ }
+ goto done;
}
result = g_dbus_proxy_call_sync(proxy, "Get",
}
done:
+ g_free(object_path);
if (proxy)
g_object_unref(proxy);
BT_EXPORT_API int bluetooth_get_uuid_name(const char *uuid, char **name)
{
- int i;
+#define SHORT_UUID_COUNT 162
+#define LONG_UUID_COUNT 17
+
int offset = 0;
int uuid_len = 4;
- static struct {
+ typedef struct {
const char *uuid;
const char *specification_name;
- } bt_uuid_name[] = {
+ } uuid_name_s;
+ static uuid_name_s short_uuid_name[SHORT_UUID_COUNT] = {
+ // List should be sorted by UUID
/* BT Classic Services */
{"1101", "Serial Port Service"},
{"1102", "LAN Access Using PPP Service"},
{"2A68", "Navigation"},
{"2A6D", "Pressure"},
{"2A6E", "Temperature"},
-
+ };
+ static uuid_name_s long_uuid_name[LONG_UUID_COUNT] = {
+ // List should be sorted by UUID
/* Custom uuids */
- {"7905F431-B5CE-4E99-A40F-4B1E122D00D0", "Apple Notification Center Service"},
- {"9FBF120D-6301-42D9-8C58-25E699A21DBD", "Notifications Source"},
- {"69D1D8F3-45E1-49A8-9821-9BBDFDAAD9D9", "Control Point"},
+ {"1AB7C24D-185A-45B9-90D4-F7AB1A71949A", "Samsung Health Service"},
{"22EAC6E9-24D6-4BB5-BE44-B36ACE7C7BFB", "Data Source"},
+ {"2F7CABCE-808D-411F-9A0C-BB92BA96C102", "Entity Update"},
+ {"32D1955A-E5AA-4A96-9A49-08538DA8B8F6", "Samsung Gear Fit Manager Service"},
+ {"69D1D8F3-45E1-49A8-9821-9BBDFDAAD9D9", "Control Point"},
+ {"7905F431-B5CE-4E99-A40F-4B1E122D00D0", "Apple Notification Center Service"},
{"89D3502B-0F36-433A-8EF4-C502AD55F8DC", "Apple Media Service"},
+ {"9A3F68E0-86CE-11E5-A309-0002A5D5C51B", "Samsung Gear Manager Service"},
{"9B3C81D8-57B1-4A8A-B8DF-0E56F7CA51C2", "Remote Command"},
- {"2F7CABCE-808D-411F-9A0C-BB92BA96C102", "Entity Update"},
+ {"9FBF120D-6301-42D9-8C58-25E699A21DBD", "Notifications Source"},
+ {"A49EB41E-CB06-495C-9F4F-BB80A90CDF00", "Samsung Gear Manager Service"},
+ {"ADE3D529-C784-4F63-A987-EB69F70EE816", "IoT OIC Service"},
+ {"C2051EE0-804D-4D50-A12C-15E243852100", "Notifications Source"},
+ {"C2F2CC0F-C085-4DD4-BE5A-ACA3074BBC72", "Control Point"},
{"C6B2F38C-23AB-46D8-A6AB-A3A870BBD5D7", "Entity Attribute"},
- {"9A3F68E0-86CE-11E5-A309-0002A5D5C51B", "Samsung Gear Manager Service"},
- {"c2f2cc0f-c085-4dd4-be5a-aca3074bbc72", "Control Point"},
- {"cece518b-28d7-4171-92d5-76a1e249a3b9", "Notifications Source"},
- {"32D1955A-E5AA-4A96-9A49-08538DA8B8F6", "Samsung Gear Fit Manager Service"},
+ {"CECE518B-28D7-4171-92D5-76A1E249A3B9", "Notifications Source"},
{"FE53FF98-B259-4337-B56A-0EC9F82C6BAD", "Control Point"},
- {"C2051EE0-804D-4D50-A12C-15E243852100", "Notifications Source"},
- {"1ab7c24d-185a-45b9-90d4-f7ab1a71949a", "Samsung Health Service"},
- {NULL, NULL}
};
+ const uuid_name_s *uuid_name = short_uuid_name;
+ int start = 0;
+ int end = SHORT_UUID_COUNT - 1;
+ int p;
+ int ret;
if (!uuid || !name)
return BLUETOOTH_ERROR_INVALID_PARAM;
else {
offset = 0;
uuid_len = 36;
+ end = LONG_UUID_COUNT - 1;
+ uuid_name = long_uuid_name;
}
} else if (strlen(uuid) >= 8)
offset = 4;
- for (i = 0; bt_uuid_name[i].uuid; i++) {
- if (!g_ascii_strncasecmp(uuid + offset, bt_uuid_name[i].uuid, uuid_len)) {
- *name = g_strdup(bt_uuid_name[i].specification_name);
+ while (start <= end) {
+ p = start + (end - start) / 2;
+ ret = g_ascii_strncasecmp(uuid + offset, uuid_name[p].uuid, uuid_len);
+ if (ret == 0) {
+ *name = g_strdup(uuid_name[p].specification_name);
return BLUETOOTH_ERROR_NONE;
- }
+ } else if (ret < 0)
+ end = p - 1;
+ else
+ start = p + 1;
}
+ BT_INFO("Unknown uuid : %s", uuid);
*name = g_strdup("Unknown");
return BLUETOOTH_ERROR_NONE;
}