ble_app_interactive using gatt to send command

Hello,

I am using nRF52840 DK to build ble_app_interactive.

Now I have device with NUS,I can connect to device using ble_app_interactive.

I have added NUS into ble_app_interactive,and I tried using gatt to send command.

But it shows the selected service does not contain the characteristic. I am sure that I have NUS in the device,and I can use nRF connect app to see it.

I want to ask if there is any step I did wrong, thank you.

Parents
  • Hello,

    Did you do the service discovery first?

    e.g.

    $ scan on

    $ connect <device address>

    $ gatt services <device address> /* Discover all primary services */

    $ gatt characteristics <device address> 1 /* Discover the characteristics for the NUS service (16-bit UUID = 0x0001)

    $ gatt write command <device address> 2  1 /* Write '1' (i.e. 0x31) to NUS RX characteristic 0x0002  */

    Best regards,

    Vidar

  • Hello,

    I solved the upper question by editting MAX_SERVICES_COUNT and MAX_CHARACTERISTICS_COUNT.

    But there is a new problem when I type gatt services <device address>.

    It shows 

    uart_cli:~$ gatt services F9:28:E7:D2:F5:5B
    gatt services F9:28:E7:D2:F5:5B
    <error> app: Fatal error
    <warning> app: System reset

    and reset the firmware.Is there anything I can fix it?

    Thank you

  • Hello,

    Thanks for the reply.

    Now I get more message.

    It shows

    uart_cli:~$ gatt services F9:28:E7:D2:F5:5B
    gatt services F9:28:E7:D2:F5:5B
    <error> app: ERROR 4 [NRF_ERROR_NO_MEM] at D:\Keil_v5_1\nRF5_SDK_17.1.0_ddde560\ examples\ble_central_and_peripheral\experimental\ble_app_interactive\ble_m.c:105 2
    PC at: 0x0003CB61
    <error> app: End of error report

    Thank you

  • Hello,

    Thanks. So the NO_MEM error is returned by the sd_ble_uuid_vs_add() call. This means you have to increase the size of the vendor specific UUIDs buffer in the Softdevice to allow the app to buffer all the UUIDs from your GATT server . The buffer size is adjusted through the NRF_SDH_BLE_VS_UUID_COUNT setting in sdk_config.h

  • Hello,

    I have modified NRF_SDH_BLE_VS_UUID_COINT setting in sdk_config.h.

    But when I modify the number to 4 or more ,it shows these message.

    <warning> nrf_sdh_ble: Insufficient RAM allocated for the SoftDevice.
    <warning> nrf_sdh_ble: Change the RAM start location from 0x200079E0 to 0x200079F0.
    <warning> nrf_sdh_ble: Maximum RAM size for application is 0x38610.
    <error> nrf_sdh_ble: sd_ble_enable() returned NRF_ERROR_NO_MEM.
    <error> app: ERROR 4 [NRF_ERROR_NO_MEM] at D:\Keil_v5_1\nRF5_SDK_17.1.0_ddde560\examples\ble_central_and_peripheral\experimental\ble_app_interactive\ble_m.c:1713
    PC at: 0x0003DC13
    <error> app: End of error report

    Thank you

  • Hello,

    Sorry, I forgot to add that you may also have to allocate more RAM the Softdevice to support the larger UUID buffer. This is done through the linker configurations here:

    You will need to change RAM_START from 0x200079E0 to 0x200079F0, and RAM_SIZE to 0x38610 as suggested by the log output.

  • Hello,

    Thanks for the reply, it works.

    But there is still a question, when I use nRF Connect , I see below services.

    When I use putty and type gatt services <MAC address>

    I can see 1800 1801 both on PC and nRF connect,but I can only see like UUID 5E5F428E-42EF-428B-AA09-955D99B3780E on nRF connect.

    Is there something I can modify that I will be able to see long UUID on PC?

    Thank you

Reply
  • Hello,

    Thanks for the reply, it works.

    But there is still a question, when I use nRF Connect , I see below services.

    When I use putty and type gatt services <MAC address>

    I can see 1800 1801 both on PC and nRF connect,but I can only see like UUID 5E5F428E-42EF-428B-AA09-955D99B3780E on nRF connect.

    Is there something I can modify that I will be able to see long UUID on PC?

    Thank you

Children
Related