This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How could I use NUS without service discover?

FormerMember
FormerMember

Hi.

I want to make a device which can connect each others and communicate with NUS. I need not to use any other service without NUS. I made nus_c service which is a central side service to use NUS which is peripheral side service. It works good except connection setup time is too long.

Searching and connection is done within 2 second. but Service Discover is too long, it takes a over 5 seconds. I think,I need not discover the service because I already know the service which I use - NUS. And Service Discover tell me only the cccd, rx, tx handle.

Some test shows cccd,rx,tx handle is 15,14,17. And I can use NUS service with this value. Actually I can use NUS service without service discover.

But I cannot find where this value is made? Is this value is fixed for all device ? Can I fix this value at nus.c or nus.h or other files?

PS) I will made a mesh network with NUS and dynamic link. Each module can move and each module can be a central and peripheral at the same time. One module activated by smart phone, and then connect neighbor module as central and the connected neighbor is also activated.

Central device role device can accept 3 peripheral device. Peripheral device can connect to only 1 central device.

Thus the connection time is very important in my project.

Thanks.

  • Hi,

    I think this will help.

    Regards,

    Milan Joshi

  • FormerMember
    0 FormerMember in reply to Milan

    Thanks for your help.

    Actually I have test as your suggest. fixed hanlde. it works. I want to know how could I get the fixed handle. I can get it by some test, but I can't findout why this handle is fixed. Could you tell me where I can find out NUS's rx,tx,cccd?

  • Searching and connection is done within 2 second. but Service Discover is too long, it takes a over 5 seconds. I think,I need not discover the service because I already know the service which I use - NUS. And Service Discover tell me only the cccd, rx, tx handle.

    The proper way to avoid doing service discovery on every connection is to cache attributes, but then you should be bonded. If you are using the Device Manager please see this for more information. If you are using the Peer Manager, you can see from the documentation that it is capable of caching GATT attributes.

    But I cannot find where this value is made? Is this value is fixed for all device ?

    The server on the peripheral has an attribute table with attribute handles. What attibute handle an attribute (service/characteristic/descriptor) is assigned depends on the order it is added to the attribute table. So if you for example add hrs and nus, nus will get different attribute handles depending if you add it before or after hrs. When you add nus the attribute handle is returned sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_nus->service_handle);

  • FormerMember
    0 FormerMember in reply to Petter Myhre

    Great.

    I will not change the sd_ble_gatts_service_add() sequence in my project. In this case, the handle value will be always the same.

    And I will try to add bonding and caching scenario to follow proper way.

    Thanks

Related