Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Unable to Subscribe to More than 3 BLE Notifications in NCS v3.1.0

Hi,

I am trying to subscribe to notifications from a peripheral device on my central device. The peripheral has more than 3 characteristics, but I am only able to successfully subscribe to 3 handles in my central.

For the 4th handle, I get the following error:  Subscribe failed for gas[3] (err -12)

Could you please clarify:

  • Is there a limit on the number of simultaneous subscriptions in the SDK?

  • Is there any configuration or workaround to allow subscribing to more than 3 characteristics?

Your guidance would be greatly appreciated and I have attached my code snippet as well .

static struct bt_gatt_subscribe_params gas_subscribe_params[8];

void subscribe_to_gas_notifications(void)
{

    for (int i = 0; i < gas_alert_count-1; i++) {
        gas_subscribe_params[i].ccc_handle = gas_ch_alert_handle[i+1] + 1;
        gas_subscribe_params[i].value_handle = gas_ch_alert_handle[i+1];
        gas_subscribe_params[i].value = BT_GATT_CCC_NOTIFY;
        gas_subscribe_params[i].notify = x_am_notify_cb;

        int err = bt_gatt_subscribe(default_conn, &gas_subscribe_params[i]);
        if (err) {
            #if DEBUG
            printk("Subscribe failed for gas[%d] (err %d)\n", i, err);
            #endif
        } else {
            #if DEBUG
            printk("Subscribed to gas[%d] (handle 0x%04x)\n", i, gas_ch_alert_handle[i+1]);
            #endif
        }
    }
}

Thank you.

Parents Reply Children
No Data
Related