diff mbox series

[RFC,BlueZ,v2,1/1] Added GDBusMethod to notify one device of characteristic change

Message ID 20210817181300.24479-2-bernie@allthenticate.net (mailing list archive)
State Superseded
Headers show
Series method to notify/indicate to one device | expand

Commit Message

Bernie Conrad Aug. 17, 2021, 6:13 p.m. UTC
Updated implementation of the method and updated method table. 

---
 src/gatt-database.c | 93 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)

Comments

bluez.test.bot@gmail.com Aug. 17, 2021, 6:44 p.m. UTC | #1
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=532893

---Test result---

Test Summary:
CheckPatch                    PASS      0.57 seconds
GitLint                       PASS      0.14 seconds
Prep - Setup ELL              PASS      57.50 seconds
Build - Prep                  PASS      0.17 seconds
Build - Configure             PASS      10.13 seconds
Build - Make                  FAIL      209.04 seconds
Make Check                    FAIL      0.71 seconds
Make Distcheck                FAIL      195.94 seconds
Build w/ext ELL - Configure   PASS      9.81 seconds
Build w/ext ELL - Make        FAIL      192.74 seconds

Details
##############################
Test: CheckPatch - PASS
Desc: Run checkpatch.pl script with rule in .checkpatch.conf

##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - FAIL
Desc: Build the BlueZ source tree
Output:
src/gatt-database.c: In function ‘notify_characteristic_changed’:
src/gatt-database.c:3642:10: error: ‘btd_error_in’ undeclared (first use in this function); did you mean ‘btd_error’?
 3642 |   return btd_error_in valid_args(msg);
      |          ^~~~~~~~~~~~
      |          btd_error
src/gatt-database.c:3642:10: note: each undeclared identifier is reported only once for each function it appears in
src/gatt-database.c:3642:22: error: expected ‘;’ before ‘valid_args’
 3642 |   return btd_error_in valid_args(msg);
      |                      ^~~~~~~~~~~
      |                      ;
make[1]: *** [Makefile:9205: src/bluetoothd-gatt-database.o] Error 1
make: *** [Makefile:4147: all] Error 2


##############################
Test: Make Check - FAIL
Desc: Run 'make check'
Output:
src/gatt-database.c: In function ‘notify_characteristic_changed’:
src/gatt-database.c:3642:10: error: ‘btd_error_in’ undeclared (first use in this function); did you mean ‘btd_error’?
 3642 |   return btd_error_in valid_args(msg);
      |          ^~~~~~~~~~~~
      |          btd_error
src/gatt-database.c:3642:10: note: each undeclared identifier is reported only once for each function it appears in
src/gatt-database.c:3642:22: error: expected ‘;’ before ‘valid_args’
 3642 |   return btd_error_in valid_args(msg);
      |                      ^~~~~~~~~~~
      |                      ;
make[1]: *** [Makefile:9205: src/bluetoothd-gatt-database.o] Error 1
make: *** [Makefile:10436: check] Error 2


##############################
Test: Make Distcheck - FAIL
Desc: Run distcheck to check the distribution
Output:
../../src/gatt-database.c: In function ‘notify_characteristic_changed’:
../../src/gatt-database.c:3642:10: error: ‘btd_error_in’ undeclared (first use in this function); did you mean ‘btd_error’?
 3642 |   return btd_error_in valid_args(msg);
      |          ^~~~~~~~~~~~
      |          btd_error
../../src/gatt-database.c:3642:10: note: each undeclared identifier is reported only once for each function it appears in
../../src/gatt-database.c:3642:22: error: expected ‘;’ before ‘valid_args’
 3642 |   return btd_error_in valid_args(msg);
      |                      ^~~~~~~~~~~
      |                      ;
make[2]: *** [Makefile:9205: src/bluetoothd-gatt-database.o] Error 1
make[1]: *** [Makefile:4147: all] Error 2
make: *** [Makefile:10357: distcheck] Error 1


##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - FAIL
Desc: Build BlueZ source with '--enable-external-ell' configuration
Output:
src/gatt-database.c: In function ‘notify_characteristic_changed’:
src/gatt-database.c:3642:10: error: ‘btd_error_in’ undeclared (first use in this function); did you mean ‘btd_error’?
 3642 |   return btd_error_in valid_args(msg);
      |          ^~~~~~~~~~~~
      |          btd_error
src/gatt-database.c:3642:10: note: each undeclared identifier is reported only once for each function it appears in
src/gatt-database.c:3642:22: error: expected ‘;’ before ‘valid_args’
 3642 |   return btd_error_in valid_args(msg);
      |                      ^~~~~~~~~~~
      |                      ;
make[1]: *** [Makefile:9205: src/bluetoothd-gatt-database.o] Error 1
make: *** [Makefile:4147: all] Error 2




---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/src/gatt-database.c b/src/gatt-database.c
index 99c95f2d6..8d91a7ed4 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -3615,6 +3615,93 @@  static DBusMessage *manager_unregister_app(DBusConnection *conn,
 	return dbus_message_new_method_return(msg);
 }
 
+static DBusMessage *notify_characteristic_changed(DBusConnection *conn,
+					DBusMessage *msg, void *user_data)
+{
+	struct btd_gatt_database *database = user_data;
+	uint8_t *value = NULL;
+	int value_len = 0;
+	DBusMessageIter args;
+	DBusMessageIter array;
+	const char *characteristic_path;
+	const char *client_path;
+	const char *application_path;
+	struct svc_match_data match_data;
+	const char *sender = dbus_message_get_sender(msg);
+	struct gatt_app *app;
+	struct external_service *service;
+	struct external_chrc *chrc;
+	struct notify notify;
+	struct device_state *client_state;
+	struct btd_device *client_device;
+
+	if (!dbus_message_iter_init(msg, &args))
+		return btd_error_invalid_args(msg);
+
+	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH)
+		return btd_error_in	valid_args(msg);
+	dbus_message_iter_get_basic(&args, &application_path);
+
+	dbus_message_iter_next(&args);
+	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH)
+		return btd_error_invalid_args(msg);
+	dbus_message_iter_get_basic(&args, &client_path);
+
+	dbus_message_iter_next(&args);
+	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH)
+		return btd_error_invalid_args(msg);
+	dbus_message_iter_get_basic(&args, &characteristic_path);
+
+	dbus_message_iter_next(&args);
+	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_ARRAY)
+		return btd_error_invalid_args(msg);
+
+
+	dbus_message_iter_recurse(&args, &array);
+	dbus_message_iter_get_fixed_array(&array, &value, &value_len);
+
+	match_data.path = application_path;
+	match_data.sender = sender;
+	app = queue_find(database->apps, match_app, &match_data);
+	if (!app)
+		return btd_error_does_not_exist(msg);
+
+
+	service = queue_find(app->services, match_service_by_chrc,
+					  characteristic_path);
+	if (!service)
+		return btd_error_does_not_exist(msg);
+
+
+	chrc = queue_find(service->chrcs, match_chrc, characteristic_path);
+	if (!chrc)
+		return btd_error_agent_not_available(msg);
+
+
+	client_device = btd_adapter_find_device_by_path(database->adapter,
+								 client_path);
+	if (!client_device)
+		return btd_error_does_not_exist(msg);
+
+	client_state = find_device_state(database,
+				device_get_address(client_device),
+				btd_device_get_bdaddr_type(client_device));
+	if (!client_state)
+		return btd_error_does_not_exist(msg);
+
+
+	notify.handle = gatt_db_attribute_get_handle(chrc->attrib);
+	notify.ccc_handle = gatt_db_attribute_get_handle(chrc->ccc);
+	notify.database = database;
+	notify.value = value;
+	notify.len = value_len;
+	notify.conf = conf_cb;
+
+	send_notification_to_device(client_state, &notify);
+	DBG("Notification/Indication sent to %s.", client_path);
+	return dbus_message_new_method_return(msg);
+}
+
 static const GDBusMethodTable manager_methods[] = {
 	{ GDBUS_ASYNC_METHOD("RegisterApplication",
 					GDBUS_ARGS({ "application", "o" },
@@ -3623,6 +3710,12 @@  static const GDBusMethodTable manager_methods[] = {
 	{ GDBUS_ASYNC_METHOD("UnregisterApplication",
 					GDBUS_ARGS({ "application", "o" }),
 					NULL, manager_unregister_app) },
+	{ GDBUS_ASYNC_METHOD("NotifyCharacteristicChanged",
+					GDBUS_ARGS({"application", "o" },
+					{ "device", "o" },
+					{ "characteristic_path", "o"},
+					{ "value", "ay"}),
+					NULL, notify_characteristic_changed) },
 	{ }
 };