diff --git a/doc/advertising-api.txt b/doc/advertising-api.txt
index 1c18ae3..8207b59 100644
--- a/doc/advertising-api.txt
+++ b/doc/advertising-api.txt
Registers an advertisement object to be sent over the LE
Advertising channel. The service must be exported
- under interface LEAdvertisement1. InvalidArguments
- indicates that the object has invalid or conflicting
- properties. InvalidLength indicates that the data
+ under interface LEAdvertisement1.
+
+ InvalidArguments error indicates that the object has
+ invalid or conflicting properties.
+
+ InvalidLength error indicates that the data
provided generates a data packet which is too long.
+
The properties of this object are parser when it is
registered, and any changes are ignored.
- Currently only one advertisement at a time is supported,
- attempting to register two advertisements will result in
+
+ If the same object is registered twice it will result in
an AlreadyExists error.
+ If the maximum number of advertisement instances is
+ reached it will result in NotPermitted error.
+
Possible errors: org.bluez.Error.InvalidArguments
org.bluez.Error.AlreadyExists
org.bluez.Error.InvalidLength
+ org.bluez.Error.NotPermitted
UnregisterAdvertisement(object advertisement)
diff --git a/src/advertising.c b/src/advertising.c
index de07a98..1bea0d1 100644
--- a/src/advertising.c
+++ b/src/advertising.c
if (!client->data)
goto fail;
- client->instance = util_get_uid(&manager->instance_bitmap,
- manager->max_ads);
- if (!client->instance)
- goto fail;
-
client->manager = manager;
return client;
return btd_error_failed(msg,
"Failed to register advertisement");
+ client->instance = util_get_uid(&manager->instance_bitmap,
+ manager->max_ads);
+ if (!client->instance) {
+ client_free(client);
+ return btd_error_not_permitted(msg,
+ "Maximum advertisements reached");
+ }
+
DBG("Registered advertisement at path %s", match.path);
queue_push_tail(manager->clients, client);