diff --git a/android/gatt.c b/android/gatt.c
index 157ebe6..ad89233 100644
--- a/android/gatt.c
+++ b/android/gatt.c
static struct ipc *hal_ipc = NULL;
static bdaddr_t adapter_addr;
static bool scanning = false;
+static unsigned int advertising_cnt = 0;
static struct queue *gatt_apps = NULL;
static struct queue *gatt_devices = NULL;
send_client_listen_notify(l->client_id, status);
+ /* In case of success update advertising state*/
+ if (!status)
+ advertising_cnt = l->start ? 1 : 0;
+
/*
* Let's remove client from the list in two cases
* 1. Start failed
}
/* If listen is already on just return success*/
- if (queue_length(listen_apps) > 1) {
+ if (advertising_cnt > 0) {
+ advertising_cnt++;
status = HAL_STATUS_SUCCESS;
goto reply;
}
* In case there is more listening clients don't stop
* advertising
*/
- if (queue_length(listen_apps) > 1) {
+ if (advertising_cnt > 1) {
+ advertising_cnt--;
queue_remove(listen_apps,
INT_TO_PTR(cmd->client_if));
status = HAL_STATUS_SUCCESS;