Find and Subscribe to multiple BT Characteristics

Hi,

I've tried a lot of different things.  Occasionally I've had promising results where I actually fine and subscribe to a single characteristic.  Most recently I've tried gatt_dm with no results, it finds service 1801 with 4 characteristics, then 1800 with 7 characteristics then errors out with Not enough memory for next attribute descriptor at handle 40.  

My Prj.conf file contains CONFIG_BT_GATT_DM_MAX_ATTRS=350 per another persons post with a similar problem.  The peripheral I'm connecting to from my central app has A LOT of characteristics (unfortunately I have to connect to it and deal with the issues of having a lot of characteristics (310))

I've tried this but it doesn't find all of the characteristics for some reason.  it will find one and subscribe to one as well but I have 5 I need to subscribe to as well as several i need handles to that i need to write to.

I am using NCS v2.2.0 on Windows 10 the nRF52832 is on a custom board, I've looked at central_HR and haven't really gotten anything to work.  I believe gatt_dm will do what I need but I need to figure out why it wont find more than 40 attributes.

Brian

  • Hello Brian,

    I am sorry, but these snippets confuse me. Is it possible to zip and send two applications, one peripheral and one central that I can use to replicate what you are seeing?

    I need to be able to run them on 2 DKs.

    Usually when we get questions about the discovery procedure, I just reference the samples, such as the peripheral_uart and central_uart samples. I suggest you use the bt_gatt_dm_start() instead of bt_gatt_discover() directly, and you don't need to handle the state machine (BT_GATT_ITER_CONTINUE and BT_GATT_ITER_STOP) 

    If you for some reason need to use bt_gatt_discover() directly, it should be fine. It is what bt_gatt_dm_start() does. But in that case, I suggest you look at the implementation of bt_gatt_dm_start() in gatt_dm.c, and implement something similiar.  This one handles the return values (BT_GATT_ITER_CONTINUE and BT_GATT_ITER_STOP).

    It looks like BT_GATT_ITER_CONTINUE should be returned when there are more services/characteristics to discover. BT_GATT_ITER_STOP should be used when you are either done, or if you run into an error.

    But I think you should investigate using bt_gatt_dm_start(), where you set the svc_uuid to NULL to discover all services. Then you call bt_gatt_dm_continue() to discover the next service when you are done handling one in the discovery_completed event.

    Best regards,

    Edvin

  • Hi,

    1) Cant send you code for the peripherial since i dont have it, it was existing firmware i need to connect to and use.  

    2) Seems like the usual answer from support, look at the central UART app, its seems like support doesn't think we research anything.  I've looked at it, I'm new to this, it doesn't really apply since I'm not using a UART and the device I'm connecting to doesn't have a UART for me to connect to to even try.  The 52dk board does and I can load it and it works. now what, the 52dk board doesn't connect to the peripheral I'm trying to scan.  The NRF connect app connects, scans and lists ALL of the services and characteristics and i can send and receive data using that BUT code isn't available for that app to see how it works.

    3) if you can look earlier in this ticket, you'll see that i said i tried the bt_gatt_dm_start but i get an error that there is not enough memory.  i found a post that said to increase 

    CONFIG_BT_GATT_DM_MAX_ATTRS=
    I increased that to 350 since i have so many characteristics.  still fails.  couldnt get any further using that.  This was in the initial post.
    I'll look at the implementation of gatt_dm and maybe ill be able to figure this out.  The documentation is severely lacking and doesn't explain much.
    I am at the point now, where i have been able to discover the services and characteristics but while trying to write, nothing happens.  i saved the handle for the characteristic i wanted to write to (63) and tried a write without response.  data is not getting sent from what i can tell.  If you have any ideas about that, please let em know.
  • Brian, 

    Obviously, I am not saying that you should use the central UART application in your final device. What I meant to say was that you could look into how the central_uart application is handling the discovery procedure. That is not an unusual request from support. 

    The reason I asked you to do this is that you started asking about BT_GATT_ITER_CONTINUE and BT_GATT_ITER_STOP, which are two return values I have never noticed before. This means that they are handled by the bt_gatt_dm module, which is why I never needed to look into them. Therefore, i thought it could be a good idea to use that, as this module seems a lot more comprehendible than implementing the state machine used in bt_gatt_discover(). 

    finkbr said:

    3) if you can look earlier in this ticket, you'll see that i said i tried the bt_gatt_dm_start but i get an error that there is not enough memory.  i found a post that said to increase 

    CONFIG_BT_GATT_DM_MAX_ATTRS=
    I increased that to 350 since i have so many characteristics.  still fails.  couldnt get any further using that.

    So chan you please let me know what makes you think you don't have enough memory? Please note that I do believe that it says so, but I need to know where it says. From what function? Is this printed in the log? Where? 

    You said that you increased CONFIG_BT_GATT_DM_MAX_ATTRS to 350. Did that change anything? Were you able to discover more characteristics than the default CONFIG_BT_GATT_DM_MAX_ATTRS=35 (which is the default value)?

    Is it the log from gatt_dm.c line 299 (NCSv2.3.0)

    LOG_ERR("Not enough memory for service attribute.");

    that you are seeing in your log?

    If so, can you please clarify whether you found more services/characteristics when increeading the CONFIG_BT_GATT_DM_MAX_ATTRS=350?

    Can you confirm that your CONFIG_BT_GATT_DM_MAX_ATTRS is actually increased when you build? If you are using the 52 series (nRF52832), then this should be visible in your build folder:

    build\zephyr\include\generated\autoconf.h

    In there you should see all the definitions that ends up in your build. If some conditions do not apply for a config, it may default back to the default value even if you tried to change it in prj.conf.

    Best regards,

    Edvin

  • yes that is the error i am seeing.  i can see that it is indeed increased to 350 and i can also verify that no more characteristics have been found.

  • We can close this ticket, when i have more specific questions ill open another one. i am travelling for the next few weeks.

Related