Problems with the "bt_gatt_dm_start" function

Hi,

I'm just learning the nRF Connect SDK and don't know all the ins and outs of it.

I have the following problem:
When calling the function bt_gatt_dm_start, I get the following log:

<err> bt_gatt_dm: attr_store: No space for new attribute.
<err> bt_gatt_dm: discovery_process_attribute: Not enough memory for next attribute descriptor at handle 68.

The discovery procedure failed with -12

The service I want to connect to has 14 attributes, I think this is the problem.

How can I fix this problem?

When trying to call bt_gatt_dm_start for BT_UUID_BAS (Battery Service) there is no problem.

Parents
  • Hello,

    Looks like the default discovery module attribute table size is set to 35. Try increasing this in your prj.conf:

    CONFIG_BT_GATT_DM_MAX_ATTRS=50

    Best regards,

    Edvin

  • Hi,

    Thanks for all your help.

    That solved my problem.

    Please clarify, is there a list of all available СONFIG_.... to understand when to use them?

  • There used to be on our documentation page, but it was removed. But it was a very (!!!!) long list, so it doesn't really make sense to read it from start to finish. Most of them are not relevant for you project (it contained all CONFIGs for Zephyr as well as our custom). Unfortunately, I don't have any good advice to familiarize yourself with the ones that you would need. To find the one that you were looking for, I was searching through the source code, and found the struct that held the array that was too small in your case, and I saw that it's size was set by that config:

    struct bt_gatt_dm {
    	/* Connection object */
    	struct bt_conn *conn;
    	/* The user context */
    	void *context;
    
    	/* The discovery parameters used */
    	struct bt_gatt_discover_params discover_params;
    	/* Currently parsed attributes */
    	struct bt_gatt_dm_attr attrs[CONFIG_BT_GATT_DM_MAX_ATTRS];
    	/* Currently accessed attribute */
    	size_t cur_attr_id;
    	/* Flags with the status of the attributes */
    	ATOMIC_DEFINE(state_flags, STATE_NUM);
    
    	/* The UUID of the service to discover. */
    	union {
    		struct bt_uuid uuid;
    		struct bt_uuid_16 u16;
    		struct bt_uuid_32 u32;
    		struct bt_uuid_128 u128;
    	} svc_uuid;
    
        ...

    Also, if you know approximately what config you are looking for, you can search either in the link at the start of this reply, or you can start typing into prj.conf if you are using nRF Connect for VS Code, and it should give you a list of possible matches. 

    Best regards,

    Edvin

Reply
  • There used to be on our documentation page, but it was removed. But it was a very (!!!!) long list, so it doesn't really make sense to read it from start to finish. Most of them are not relevant for you project (it contained all CONFIGs for Zephyr as well as our custom). Unfortunately, I don't have any good advice to familiarize yourself with the ones that you would need. To find the one that you were looking for, I was searching through the source code, and found the struct that held the array that was too small in your case, and I saw that it's size was set by that config:

    struct bt_gatt_dm {
    	/* Connection object */
    	struct bt_conn *conn;
    	/* The user context */
    	void *context;
    
    	/* The discovery parameters used */
    	struct bt_gatt_discover_params discover_params;
    	/* Currently parsed attributes */
    	struct bt_gatt_dm_attr attrs[CONFIG_BT_GATT_DM_MAX_ATTRS];
    	/* Currently accessed attribute */
    	size_t cur_attr_id;
    	/* Flags with the status of the attributes */
    	ATOMIC_DEFINE(state_flags, STATE_NUM);
    
    	/* The UUID of the service to discover. */
    	union {
    		struct bt_uuid uuid;
    		struct bt_uuid_16 u16;
    		struct bt_uuid_32 u32;
    		struct bt_uuid_128 u128;
    	} svc_uuid;
    
        ...

    Also, if you know approximately what config you are looking for, you can search either in the link at the start of this reply, or you can start typing into prj.conf if you are using nRF Connect for VS Code, and it should give you a list of possible matches. 

    Best regards,

    Edvin

Children
Related