From 1f8969c0435f8d49c20f46dba9bece21031997c7 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 26 Apr 2011 21:13:49 +0100 Subject: [PATCH] Clean up ATT CID & PSM magic values & definititions Use proper defines for the ATT CID and PSM. The values are really ATT and not GATT specific so move them from gatt.h to att.h. --- attrib/att.h | 3 +++ attrib/client.c | 2 +- attrib/gatt.h | 2 -- attrib/utils.c | 3 ++- src/adapter.c | 2 +- src/device.c | 5 +++-- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/attrib/att.h b/attrib/att.h index 93b58dc21..3b8c098ff 100644 --- a/attrib/att.h +++ b/attrib/att.h @@ -110,6 +110,9 @@ #define ATT_DEFAULT_L2CAP_MTU 48 #define ATT_DEFAULT_LE_MTU 23 +#define ATT_CID 4 +#define ATT_PSM 31 + /* Requirements for read/write operations */ enum { ATT_NONE, /* No restrictions */ diff --git a/attrib/client.c b/attrib/client.c index 2dd70c941..71df532c0 100644 --- a/attrib/client.c +++ b/attrib/client.c @@ -384,7 +384,7 @@ static int l2cap_connect(struct gatt_service *gatt, GError **gerr, io = bt_io_connect(BT_IO_L2CAP, connect_cb, gatt, NULL, gerr, BT_IO_OPT_SOURCE_BDADDR, &gatt->sba, BT_IO_OPT_DEST_BDADDR, &gatt->dba, - BT_IO_OPT_CID, GATT_CID, + BT_IO_OPT_CID, ATT_CID, BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW, BT_IO_OPT_INVALID); else diff --git a/attrib/gatt.h b/attrib/gatt.h index 01c651e8c..c5f95ac4e 100644 --- a/attrib/gatt.h +++ b/attrib/gatt.h @@ -23,8 +23,6 @@ */ #include -#define GATT_CID 4 - typedef void (*gatt_cb_t) (GSList *l, guint8 status, gpointer user_data); guint gatt_discover_primary(GAttrib *attrib, bt_uuid_t *uuid, gatt_cb_t func, diff --git a/attrib/utils.c b/attrib/utils.c index 5f4444ada..22d23a40d 100644 --- a/attrib/utils.c +++ b/attrib/utils.c @@ -30,6 +30,7 @@ #include #include +#include "att.h" #include "gattrib.h" #include "gatt.h" #include "btio.h" @@ -84,7 +85,7 @@ GIOChannel *gatt_connect(const gchar *src, const gchar *dst, chan = bt_io_connect(BT_IO_L2CAP, connect_cb, NULL, NULL, &err, BT_IO_OPT_SOURCE_BDADDR, &sba, BT_IO_OPT_DEST_BDADDR, &dba, - BT_IO_OPT_CID, GATT_CID, + BT_IO_OPT_CID, ATT_CID, BT_IO_OPT_OMTU, mtu, BT_IO_OPT_SEC_LEVEL, sec, BT_IO_OPT_INVALID); diff --git a/src/adapter.c b/src/adapter.c index 7e9ceac11..8dbd62c61 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2016,7 +2016,7 @@ static void create_stored_device_from_profiles(char *key, char *value, device_probe_drivers(device, uuids); list = device_services_from_record(device, uuids); if (list) - device_register_services(connection, device, list, 31); + device_register_services(connection, device, list, ATT_PSM); g_slist_foreach(uuids, (GFunc) g_free, NULL); g_slist_free(uuids); diff --git a/src/device.c b/src/device.c index 72774bf56..b0a6542c2 100644 --- a/src/device.c +++ b/src/device.c @@ -1442,7 +1442,8 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data) list = device_services_from_record(device, req->profiles_added); if (list) - device_register_services(req->conn, device, list, 31); + device_register_services(req->conn, device, list, + ATT_PSM); } /* Remove drivers for services removed */ @@ -1660,7 +1661,7 @@ int device_browse_primary(struct btd_device *device, DBusConnection *conn, io = bt_io_connect(BT_IO_L2CAP, gatt_connect_cb, req, NULL, NULL, BT_IO_OPT_SOURCE_BDADDR, &src, BT_IO_OPT_DEST_BDADDR, &device->bdaddr, - BT_IO_OPT_CID, GATT_CID, + BT_IO_OPT_CID, ATT_CID, BT_IO_OPT_SEC_LEVEL, sec_level, BT_IO_OPT_INVALID); -- 2.47.3