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.

Stonestreet Bluetopia: L2cap development



Hi,

We are using the Stonestreet One Bluetopia stack for the application development.

We are developing the custom BT profile based on the L2Cap layer. In which we are facing the problem while sending the data to other BT device.

We are using the following API’s for this L2cap layer based communication. In write call we are getting (-38) error and on other end (BT device 2) callback function not getting called.

So if you have any sample application that uses these L2cap layer API’s, please provide us.

Following is the code snippet in which are getting the write failed. Only important lines are shown below.

BT device 1:

1)  After initializing the Bluetooth stack, following API is called.

ret_val=L2CA_Connect_Request(BluetoothStackID, BD_ADDR, L2CAP_PSM_MINIMUM_PSM,L2CA_Event_Callback, (unsigned long)0);

            Display(("L2CAP_CID=%d\r\n",ret_val));

            L2CAP_CID=ret_val;

2)  In the event callback we check for the events.

switch(L2CA_Event_Data->L2CA_Event_Type)

case etConnect_Confirmation:

             L2CA_Get_Current_Channel_Configuration(1,L2CAP_CID, ConfigParams); 

            L2CA_Config_Rq->InMTU=ConfigParams->OutMTU;

            L2CA_Config_Rq->OutFlow=ConfigParams->InFlow;

            L2CA_Config_Rq->OutFlushTO=ConfigParams->OutFlushTO;

            ret_val=L2CA_Config_Request(1,L2CAP_CID,1000,L2CA_Config_Rq);

     break;

case  etConfig_Indication:

           L2CA_Config_Rs=(L2CA_Config_Response_t *)L2CA_Event_Data->Event_Data.L2CA_Connect_Indication;

           L2CA_Config_Rs->OutMTU=L2CA_Event_Data->Event_Data.L2CA_Config_Confirmation->InMTU;

           L2CA_Config_Rs->InFlow=L2CA_Event_Data->Event_Data.L2CA_Config_Confirmation->OutFlow;

           L2CA_Config_Rs->InFlushTO=L2CA_Event_Data->Event_Data.L2CA_Config_Confirmation->OutFlushTO;

ret_val=L2CA_Config_Response(1,L2CAP_CID,result,L2CA_Config_Rs);

                break;

BT device 2:

1)  Here after initializing the Bluetooth stack the channel registered for the callback.

        ret_val=L2CA_Register_Fixed_Channel(3, L2CAP_CHANNEL_IDENTIFIER_CONNECTIONLESS_CHANNEL+1,NULL,L2CA_Event_Callback,0);

        Display(("REG_Fixed_val=%d\r\n",ret_val));

          // Tried by registering PSM

     //ret_val=L2CA_Register_PSM(1,L2CAP_PSM_MINIMUM_PSM,L2CA_Event_Callback, 3);

     //Display(("L2CA_Register_PSM_ret_val=%d\r\n"));

2)  L2CA_Event_Callback is same as mentioned in the BT device 1 point 2.

If you have any sample applications which uses the API’s of L2cap and HCI layer of Blutopia stack. Which gives the idea of sequence of API’s to be called.

Thanks & regards,

Ravi

  • Hello Ravi,


    We are working on a response and hope to send it to you sometime today.

    Best Regards,

    Stonestreet One. 

  • Thanks,

    I have one more query related to HCITRANS layer. I have tried bluetooth communication using the API's of HCITRANS layer but the data is not receiving at another end.

    Following code is implemented in the SPP demo application provided by blutopia stack. And new API's like “HciTestW” and “HciTestR” are added as command, so i execute it from command line.

    1)      AT Board 1:

    At one board “HciTestW” is called and in which the “HCITR_COMOpen” and “HCITR_COMWrite” routines are called and get the expected return values.

    2)      At Board 2:

    At board 2, the “HciTestR” is called in which the “HCITR_COMOpen” and “HCITR_COMProcess” routines are called and get the expected return values.

    But at board 2 we are not getting the callback called, it may be not receiving the data from another board. Please suggest if any thing missing.

    HCITRANS Layer Code Snippet:

    unsigned int HCITransportID=0;

    void BTPSAPI COMDataCallback( unsigned int HCITransportID, unsigned int DataLength, unsigned char *DataBuffer , unsigned long CallbackParameter)

    {

      Display(("Callbk called for open com port\r\n"));

       Display(("\n%s ..\r\n", __func__ )); 

       Display(("\nReceived Data:: Len %d \r\n%s\r\n",DataLength, DataBuffer));

    }

    static int HciTestW(ParameterList_t *TempParam)

    {

       unsigned int ret_val = 0;

       //char test_str[]={0x1A,0x00,0x41,0x00,0x09,0xEF,0x2D,'H','E','L','L','L','O',0x2E};//"HELLO";

       char test_str[] = "Hello world\r\n";

       HCI_COMMDriverInformation_t COMMDriverInformation;

       Display(("\n%s ..\r\n", __func__ ));

       BSC_Shutdown(BluetoothStackID);

       if(HCITransportID!=0)

          HCITR_COMClose(HCITransportID);

       COMMDriverInformation.BaudRate = 115200;

       COMMDriverInformation.COMDeviceName = NULL;

       COMMDriverInformation.COMPortNumber = 1;

       COMMDriverInformation.DriverInformationSize = sizeof(COMMDriverInformation);

       COMMDriverInformation.InitializationDelay = 100;

       COMMDriverInformation.Protocol = cpUART;

        HCITransportID = HCITR_COMOpen(&COMMDriverInformation,COMDataCallback,3); //Maven

        Display(("HCITR_COMOpenRT_VALUE=%d\r\n",HCITransportID));

        ret_val=HCITR_COMWrite(HCITransportID, sizeof(test_str),test_str); 

        Display(("HCITR_COMWRITE_RT_VALUE=%d\r\n",ret_val));

    }

    static int HciTestR(ParameterList_t *TempParam)

    {

       unsigned int ret_val = 0;

       HCI_COMMDriverInformation_t COMMDriverInformation;

       Display(("\n%s ..\r\n", __func__ ));

       BSC_Shutdown(BluetoothStackID);

       if(HCITransportID!=0)

          HCITR_COMClose(HCITransportID);

       COMMDriverInformation.BaudRate = 115200;

       COMMDriverInformation.COMDeviceName = NULL;

       COMMDriverInformation.COMPortNumber = 1;

       COMMDriverInformation.DriverInformationSize = sizeof(COMMDriverInformation);

       COMMDriverInformation.InitializationDelay = 100;

       COMMDriverInformation.Protocol = cpUART;

        HCITransportID = HCITR_COMOpen(&COMMDriverInformation,COMDataCallback,3); //Maven

        Display(("HCITR_COMOpenRT_VALUE=%d\r\n",HCITransportID)); 

        HCITR_COMProcess(HCITransportID);   

        Display(("Waiting ..\r\n"));

    In these API first Bluetooth stack is made shutdown(   BSC_Shutdown(BluetoothStackID);). If we keep this Bluetooth stack initialized then we get error in “HCITR_COMOpen” as (-1).

    Thanks & regards,

    Ravi

     

     

  • Ravi,

    Not very clear about this. Did you implement these functions? 

    Do you want to communicate from one board to other? You will have to either talk over L2CAP or using SPP after you establish a connection to the remote device. Sorry if we misunderstood the question here. 

    Best Regards,

    Stonestreet One. 

  • Hi,

    HCITR_COMOpen, HCITR_COMProcess and HCITR_COMWrite are the standard routines available in the HCITRANS.c, HCITRANS.h files.

    And the HCITRANS.pdf is referred for to have the communication between two boards on the HCI transport layer.

    This pdf is available in the "CC256x MSP430 Bluetopia SDK\v1.2.1\Documentation".

    Thanks & regards,

    Ravi

  • Hello Ravi,

    I was asking about HCITestR and HCITestW functions. 

    HCITRANS is used to open a transport to communicate with the Bluetooth chip. This is implemented and working in the release that you have. 

    The communication between two experimenter boards over Bluetooth happens over higher layers, if that was your aim.

    Apologize if I misunderstood but just wanted to check what you were trying to test with these functions.

    Best regards,

    Stonestreet One.  

  • Hi,

    Yes, that routines HCITestR and HCITestW are newly implemented.

    I am trying to use the HCITRANS layer for the communication between two boards without initializing BT stack. so "HCITR_COMOpen" is used at both boards and at one board “HCITR_COMWrite” is called and at other board “HCITR_COMProcess” is called. But at other end not receiving any data.

    The routine BSC_Shutdown(BluetoothStackID); is called at the time of initialization. So the COM open occurs successful.

    Thanks & regards,

    Ravi

  • Hello Stonestreet One,

    I am currently working on sending some data between two boards using L2CAP level. Could you send some example code to exchange some data between two devices using Bluetopia L2CAP API? Or give some info on order of API calls needed to communicate at L2CAP level?

    Best regards,

    kapi