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.

CCS/CC2564MODN: etGATT_Server_Device_Buffer_Empty not called

Part Number: CC2564MODN

Tool/software: Code Composer Studio

I'd like to write to a characteristic as in the SPPLE example (I took that example code and modified it for my own purposes) using the function call

Result = GATT_Write_Without_Response_Request(
BluetoothStackID, ConnectionID,
DeviceInfo_->ClientInfo.Rx_Characteristic,
(Word_t) DataCount,
&SPPLEBufferNotify[TransmitIndex]);

However, when I send too much data I get the return value: BTPS_ERROR_INSUFFICIENT_BUFFER_SPACE. So, I'm sending too many packets obviously. The Bluetopia documentation says that the user has to wait for the callback etGATT_Connection_Device_Buffer_Empty to be called before sending more data. So I expected to get this callback whenever the queue becomes empty but it seems like that this callback is never called, so the question is why? I also expect this callback if I don't have an overflow, if I send, let's say, just 50 bytes, but this is not the case. 

First, I did everything in the etGATT_Server_Write_Request callback. But then I thought that the etGATT_Connection_Device_Buffer_Empty callback will probably be missed if I stick there so I just set a flag to execute the sending process in the main file where a scheduler is set up. However, etGATT_Connection_Device_Buffer_Empty was called neither. Also, as soon as the error BTPS_ERROR_INSUFFICIENT_BUFFER_SPACE triggers, it keeps returning that error, so that I have to restart the device, why does it get stuck there?

Thanks in advance

Pascale

  • Hi Pascale,

    If you refer to the SPPLEDemo, the etGATT_Connection_Device_Buffer_Empty event is under the GATT_Connection_Event_Callback and not the GATT_ServerEventCallback.

    BR,
    Vihang
  • Ok, my bad. Yeah the device is acting as server, so calling 

    Result = GATT_Handle_Value_Notification(
    BluetoothStackID, SPPLEServiceID, ConnectionID,
    SPPLE_RX_AND_TX_CHARACTERISTIC_ATTRIBUTE_OFFSET,
    (Word_t) DataCount,
    &SPPLEBufferNotify[TransmitIndex]);

    which should call etGATT_Server_Device_Buffer_Empty() in GATT_ServerEventCallback(). But this isn't happening. So I'mstill having the same problem as described beforehand.

    Thanks

  • Hi Pascale,

    I do see the etGATT_Connection_Device_Buffer_Empty event popping up for the GATT_Handle_Value_Notification() API in the default SPPLEDemo. Have you made any major changes to this part of the demo?

    Best regards,
    Vihang
  • Thanks for your reply. Actually, I went back to a just slightly changed version of the original one (other pinout). However, I expect etGATT_Server_Device_Buffer_Empty to be called, not etGATT_Connection_Device_Buffer_Empty. In my setup, the device is acting as a server whil the tablet (running LightBlue) is running as a client. So I do the steps as described in the SPPLEDemo-Wiki.

    SPP+LE>Server
    
    SPP+LE>RegisterSPPLE 
    Sucessfully registered SPPLE Service.

    SPP+LE>AdvertiseLE 1
    GAP_LE_Advertising_Enable success.

    Afterwards, I enable listen to notifications on the TX and RX Credits Characteristic and do the following as in the description:
    1. Open the Tx Credits Characteristic (0xBA04C4B2-892B-43BE-B69C-5D13F2195392).
    2. Choose "Write new value".
    3. Type 6400. (100 credits = 0x0064 little-endian)
    4. Choose Done.
    5. Press the back button in the top left corner

    Then I enter into the console:

    SPP+LE>LESend 5cfc3252180b 100
    
    Send Complete, Sent 100.

    GATT_Set_Queuing_Parameters(BluetoothStackID, (unsigned int)NumberLEPackets, (unsigned int)(NumberLEPackets-1), FALSE); has
    NumberLEPackets set to 7, and I added a Display call to detect the callback after GATT_Handle_Value_Notification() is going to be called.

    static void BTPSAPI GATT_ServerEventCallback(unsigned int BluetoothStackID, GATT_Server_Event_Data_t *GATT_ServerEventData, unsigned long CallbackParameter)
    {
    int LEConnectionIndex;
    Byte_t Temp[2];
    Word_t Value;
    Word_t PreviousValue;
    Word_t AttributeOffset;
    DeviceInfo_t *DeviceInfo;

    /* Verify that all parameters to this callback are Semi-Valid. */
    if((BluetoothStackID) && (GATT_ServerEventData))
    {
    switch(GATT_ServerEventData->Event_Data_Type)
    {
    case etGATT_Server_Device_Buffer_Empty:
    Display(("etGATT_Server_Device_Buffer_Empty\r\n"));
    break;
    case etGATT_Server_Read_Request:
    /* Verify that the Event Data is valid. */
    if(GATT_ServerEventData->Event_Data.GATT_Read_Request_Data)
    {

    I'm also tracking the etGATT_Connection_Device_Buffer_Empty callback, which isn't called either.

    Any ideas?

    Thanks,

    Pascale




  • Ok, I realized that tha callback is called only if an buffer overflow exists.