This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[CC2540] GATT_WriteLongValue does not work for values bigger than 121 Bytes

Other Parts Discussed in Thread: CC2540

Hi all,

we are using two CC2540 based devices with the BLE stack 1.4. Both devices are working as network processors (GATT_DB_OFF_CHIP) . One is the server (Peripheral) and one is the client (Central). We try to use the GATT_WriteLongValue (0xFD96) command to transfer data up to 128 bytes, but this does not work.

To figure out what is going on, I tried to transfer smaller packets and this works up to 121 bytes. I can see the "PrepareWriteCommand - PrepareWriteResponse" ping pong and at the end the "ExecuteWriteCommand - ExecuteWriteResponse" ping pong.

But if I try to transfer more than 121 bytes nothing happens!

I also tried the GATT_WriteLongChar (0xFDC2) command but the behavior is the same.

Does anybody have the same issue or a hint what the problem is?

Thank you in advance

Andreas

  • Hello Andreas,
    I am not really sure. Could you try to add a breakpoint to the following case in hci_ext_app.c:
    case GATT_WRITE_LONG_CHAR_DESC: // GATT Write Long Characteristic Descriptor

    Then see what happens when you send the command. Verify that the buffer is allocated, but I guess you would see memory allocation error return code if that happened. If it is the case, maybe increasing the heap size will help.

    FYI: Here is some other considerations about using GATT_WriteLongCharValue in case you find it useful:
    e2e.ti.com/.../359921
  • Hi Eirik,

    thank you for your fast reply!
    I am new to the IAR IDE and the 8051 (normally we use Keil and Cortex mikrocontrollers).
    Do you have a suggestion for the heap configuration?

    At the moment I have the following parameters:
    XDATA: 0xFF
    Far: 0xFFF
    Far22: 0xFFF
    Huge: 0xFFF

    Independently of that, the memory allocation in the GATT_WRITE_LONG_CHAR_DESC case seems to work. I don´t get an memory alloc error as response but an HCI_CommandCompleteEvent. I am not sure how to handle this.

    [STATUS] CONNECTED to C0FFEEC0FFEE (Handle: 0)
    GATTWriteLongValue Connection Handle 0 Length 122
    09:40:57.399 TX:01 96 FD 80 00 00 26 00 00 00 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79
    09:40:57.420 RX:04 0E 04 00 02 03 01
    09:40:57.420 HCI_CommandCompleteEvent
    09:40:57.421 Unknown CommandCompleteEvent 0x302

    Thanks in advance
    Andreas
  • OK, I got it.

    Since the communication in the network processors (GATT_DB_OFF_CHIP) mode runs via the USART, the USART must be able to handle the big packets for a GATT_LongWriteValue/GATT_LongWriteCharValue command.
    I reconfigured some parameters and now it works!

    npi.h
    #define NPI_UART_RX_BUF_SIZE 512 // instead of 128
    #define NPI_UART_TX_BUF_SIZE 512 // instead of 128

    Preprocessor configuration added
    HAL_UART_DMA_RX_MAX=256

    No I am able to write long values up to 248 bytes in one shot. This is the upper limit over the HCI protocol since the pdu size is a 8 bit value!
    But I can live with this.

    Best regards
    Andreas
  • OK, I got it.

    Since the communication in the network processors (GATT_DB_OFF_CHIP) mode runs via the USART, the USART must be able to handle the big packets for a GATT_LongWriteValue/GATT_LongWriteCharValue command.
    I reconfigured some parameters and now it works!

    npi.h
    #define NPI_UART_RX_BUF_SIZE 512 // instead of 128
    #define NPI_UART_TX_BUF_SIZE 512 // instead of 128

    Preprocessor configuration added
    HAL_UART_DMA_RX_MAX=256

    No I am able to write long values up to 248 bytes in one shot. This is the upper limit over the HCI protocol since the pdu size is a 8 bit value!
    But I can live with this.

    Best regards
    Andreas
  • Great!
    BTW: The Heap is defined in Preprocessor options (Project options-> C/C++ compiler -> Preprocessor -> Defined Symbols):
    INT_HEAP_LEN=3000