* [PATCH BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data @ 2022-05-12 0:55 Luiz Augusto von Dentz 2022-05-12 0:55 ` [PATCH BlueZ] service: Add initiator argument to service_accept Luiz Augusto von Dentz ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Luiz Augusto von Dentz @ 2022-05-12 0:55 UTC (permalink / raw) To: linux-bluetooth From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> This makes gatt_db_attribute_get_char_data work with Characteristic Value rather than only with Characteristic Declaration. --- src/shared/gatt-db.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index 4f5d10b57..d3b5cec1d 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -1528,7 +1528,7 @@ void gatt_db_service_foreach_char(struct gatt_db_attribute *attrib, gatt_db_service_foreach(attrib, &characteristic_uuid, func, user_data); } -static int gatt_db_attribute_get_index(struct gatt_db_attribute *attrib) +static int gatt_db_attribute_get_index(const struct gatt_db_attribute *attrib) { struct gatt_db_service *service; int index; @@ -1853,8 +1853,18 @@ bool gatt_db_attribute_get_char_data(const struct gatt_db_attribute *attrib, if (!attrib) return false; - if (bt_uuid_cmp(&characteristic_uuid, &attrib->uuid)) - return false; + if (bt_uuid_cmp(&characteristic_uuid, &attrib->uuid)) { + int index; + + /* Check if Characteristic Value was passed instead */ + index = gatt_db_attribute_get_index(attrib); + if (index < 0) + return NULL; + + attrib = attrib->service->attributes[index - 1]; + if (bt_uuid_cmp(&characteristic_uuid, &attrib->uuid)) + return false; + } /* * Characteristic declaration value: -- 2.35.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH BlueZ] service: Add initiator argument to service_accept 2022-05-12 0:55 [PATCH BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data Luiz Augusto von Dentz @ 2022-05-12 0:55 ` Luiz Augusto von Dentz 2022-05-12 3:06 ` [BlueZ] " bluez.test.bot 2022-05-13 0:00 ` [PATCH BlueZ] " patchwork-bot+bluetooth 2022-05-12 3:16 ` [BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data bluez.test.bot 2022-05-13 0:00 ` [PATCH BlueZ] " patchwork-bot+bluetooth 2 siblings, 2 replies; 6+ messages in thread From: Luiz Augusto von Dentz @ 2022-05-12 0:55 UTC (permalink / raw) To: linux-bluetooth From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> This adds initiator argument to service_accept so profiles accepting the connection can use btd_service_is_initiator to determine if the connection was initiated locally (central) or remotely (peripheral). --- src/device.c | 18 ++++++++++++++++-- src/service.c | 4 +++- src/service.h | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/device.c b/src/device.c index b0309a1e7..a39eb8c64 100644 --- a/src/device.c +++ b/src/device.c @@ -158,6 +158,7 @@ struct bearer_state { bool bonded; bool connected; bool svc_resolved; + bool initiator; }; struct csrk_info { @@ -297,6 +298,16 @@ static struct bearer_state *get_state(struct btd_device *dev, return &dev->le_state; } +static bool get_initiator(struct btd_device *dev) +{ + if (dev->le_state.connected) + return dev->le_state.initiator; + if (dev->bredr_state.connected) + return dev->bredr_state.initiator; + + return false; +} + static GSList *find_service_with_profile(GSList *list, struct btd_profile *p) { GSList *l; @@ -3256,6 +3267,7 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) return; state->connected = false; + state->initiator = false; device->general_connect = FALSE; device_set_svc_refreshed(device, false); @@ -4169,7 +4181,7 @@ done: } /* Notify driver about the new connection */ - service_accept(service); + service_accept(service, get_initiator(device)); } static void device_add_gatt_services(struct btd_device *device) @@ -4191,7 +4203,7 @@ static void device_accept_gatt_profiles(struct btd_device *device) GSList *l; for (l = device->services; l != NULL; l = g_slist_next(l)) - service_accept(l->data); + service_accept(l->data, get_initiator(device)); } static void device_remove_gatt_service(struct btd_device *device, @@ -5899,6 +5911,8 @@ int device_connect_le(struct btd_device *dev) /* Keep this, so we can cancel the connection */ dev->att_io = io; + /* Set as initiator */ + dev->le_state.initiator = true; return 0; } diff --git a/src/service.c b/src/service.c index 14a4c292b..7c4dc8fe0 100644 --- a/src/service.c +++ b/src/service.c @@ -172,7 +172,7 @@ void service_remove(struct btd_service *service) btd_service_unref(service); } -int service_accept(struct btd_service *service) +int service_accept(struct btd_service *service, bool initiator) { char addr[18]; int err; @@ -198,6 +198,8 @@ int service_accept(struct btd_service *service) return -ECONNABORTED; } + service->initiator = initiator; + err = service->profile->accept(service); if (!err) goto done; diff --git a/src/service.h b/src/service.h index fa930f985..dc0d1d132 100644 --- a/src/service.h +++ b/src/service.h @@ -35,7 +35,7 @@ struct btd_service *service_create(struct btd_device *device, int service_probe(struct btd_service *service); void service_remove(struct btd_service *service); -int service_accept(struct btd_service *service); +int service_accept(struct btd_service *service, bool initiator); int service_set_connecting(struct btd_service *service); /* Connection control API */ -- 2.35.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [BlueZ] service: Add initiator argument to service_accept 2022-05-12 0:55 ` [PATCH BlueZ] service: Add initiator argument to service_accept Luiz Augusto von Dentz @ 2022-05-12 3:06 ` bluez.test.bot 2022-05-13 0:00 ` [PATCH BlueZ] " patchwork-bot+bluetooth 1 sibling, 0 replies; 6+ messages in thread From: bluez.test.bot @ 2022-05-12 3:06 UTC (permalink / raw) To: linux-bluetooth, luiz.dentz [-- Attachment #1: Type: text/plain, Size: 995 bytes --] This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series: PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=640777 ---Test result--- Test Summary: CheckPatch PASS 1.53 seconds GitLint PASS 0.98 seconds Prep - Setup ELL PASS 43.22 seconds Build - Prep PASS 0.72 seconds Build - Configure PASS 9.07 seconds Build - Make PASS 1293.83 seconds Make Check PASS 11.29 seconds Make Check w/Valgrind PASS 426.79 seconds Make Distcheck PASS 232.12 seconds Build w/ext ELL - Configure PASS 8.69 seconds Build w/ext ELL - Make PASS 1277.75 seconds Incremental Build with patchesPASS 0.00 seconds --- Regards, Linux Bluetooth ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH BlueZ] service: Add initiator argument to service_accept 2022-05-12 0:55 ` [PATCH BlueZ] service: Add initiator argument to service_accept Luiz Augusto von Dentz 2022-05-12 3:06 ` [BlueZ] " bluez.test.bot @ 2022-05-13 0:00 ` patchwork-bot+bluetooth 1 sibling, 0 replies; 6+ messages in thread From: patchwork-bot+bluetooth @ 2022-05-13 0:00 UTC (permalink / raw) To: Luiz Augusto von Dentz; +Cc: linux-bluetooth Hello: This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>: On Wed, 11 May 2022 17:55:15 -0700 you wrote: > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > > This adds initiator argument to service_accept so profiles accepting > the connection can use btd_service_is_initiator to determine if the > connection was initiated locally (central) or remotely (peripheral). > --- > src/device.c | 18 ++++++++++++++++-- > src/service.c | 4 +++- > src/service.h | 2 +- > 3 files changed, 20 insertions(+), 4 deletions(-) Here is the summary with links: - [BlueZ] service: Add initiator argument to service_accept https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=cd24715bb226 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data 2022-05-12 0:55 [PATCH BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data Luiz Augusto von Dentz 2022-05-12 0:55 ` [PATCH BlueZ] service: Add initiator argument to service_accept Luiz Augusto von Dentz @ 2022-05-12 3:16 ` bluez.test.bot 2022-05-13 0:00 ` [PATCH BlueZ] " patchwork-bot+bluetooth 2 siblings, 0 replies; 6+ messages in thread From: bluez.test.bot @ 2022-05-12 3:16 UTC (permalink / raw) To: linux-bluetooth, luiz.dentz [-- Attachment #1: Type: text/plain, Size: 1323 bytes --] This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series: PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=640776 ---Test result--- Test Summary: CheckPatch PASS 1.66 seconds GitLint FAIL 1.10 seconds Prep - Setup ELL PASS 52.47 seconds Build - Prep PASS 0.82 seconds Build - Configure PASS 10.66 seconds Build - Make PASS 1520.85 seconds Make Check PASS 13.21 seconds Make Check w/Valgrind PASS 538.52 seconds Make Distcheck PASS 281.07 seconds Build w/ext ELL - Configure PASS 10.57 seconds Build w/ext ELL - Make PASS 1484.25 seconds Incremental Build with patchesPASS 0.00 seconds Details ############################## Test: GitLint - FAIL Desc: Run gitlint with rule in .gitlint Output: [BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data 1: T1 Title exceeds max length (86>80): "[BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data" --- Regards, Linux Bluetooth ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data 2022-05-12 0:55 [PATCH BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data Luiz Augusto von Dentz 2022-05-12 0:55 ` [PATCH BlueZ] service: Add initiator argument to service_accept Luiz Augusto von Dentz 2022-05-12 3:16 ` [BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data bluez.test.bot @ 2022-05-13 0:00 ` patchwork-bot+bluetooth 2 siblings, 0 replies; 6+ messages in thread From: patchwork-bot+bluetooth @ 2022-05-13 0:00 UTC (permalink / raw) To: Luiz Augusto von Dentz; +Cc: linux-bluetooth Hello: This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>: On Wed, 11 May 2022 17:55:14 -0700 you wrote: > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> > > This makes gatt_db_attribute_get_char_data work with Characteristic > Value rather than only with Characteristic Declaration. > --- > src/shared/gatt-db.c | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) Here is the summary with links: - [BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=83497bbb307f You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-05-13 0:00 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-05-12 0:55 [PATCH BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data Luiz Augusto von Dentz 2022-05-12 0:55 ` [PATCH BlueZ] service: Add initiator argument to service_accept Luiz Augusto von Dentz 2022-05-12 3:06 ` [BlueZ] " bluez.test.bot 2022-05-13 0:00 ` [PATCH BlueZ] " patchwork-bot+bluetooth 2022-05-12 3:16 ` [BlueZ] gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_data bluez.test.bot 2022-05-13 0:00 ` [PATCH BlueZ] " patchwork-bot+bluetooth
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.