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.

CC2564MODA: Open two bluetooth stack

Part Number: CC2564MODA
Other Parts Discussed in Thread: CC256XSTBTBLESW

Hello everyone,

I’m working on a Bluetooth project, I have managed to use some protocol (HFP, A3DP), and actually, I would like to know if I’ts possible to open 2 different Bluetooth stack. I have test to open 2 stack, don’t have any problem for the first one, but with the second one I have an error (BTPS_ERROR_HCI_DRIVER_ERROR) on this function: BSC_Initialize(). And I have the same error if I reverse the 2 stack.

I am working with Bluetopia and I’m using the SKD available here www.ti.com/.../CC256XSTBTBLESW

BR,

Alexandre

  • Hi Alexandre,

    No, the Bluetopia library cannot be initialized more than once, so you cannot have two instances of it running at the same time.

    If you are trying to use two or more profiles together, you will need to combine the application functionality into one single Bluetopia stack application. Please take a look at this appnote for an overview of how the implementation process will look like:

    https://www.ti.com/lit/swra637/

    Let me know if you need more clarification or have further questions on using the Bluetopia stack provided with the CC2564MODA.

    Regards,

    Michael

  • Hello Michael,

    Thank you for your reply, but your link doesn't seems to work for me. (err 404 not found)

    BR,

    Alexandre

  • I have manage to find the pdf, but I have one more question, it is possiblle to combine the functionality of A3DP SRC and A3DP SNK in one single application ?

    Best Regards,

    Alexandre

  • Hi Alexandre,

    It is possible to combine it into one application, but keep in mind that you cannot run both A3DP SRC and A3DP SNK at the same time. You will need to use the unassisted A2DP mode if you want to run both SRC and SNK at the same time in your application.

    Regards,

    Michael

  • Thanks for your help,

    I did not see the possibility to setup a device in SRC mode with A2DP, do you know if it is possible? or do I need to set up the SRC in A3DP and the SNK in A2DP?

    Best Regards,

    Alexandre

  • Hi Alexandre,

    It is possible to setup the CC2564MODA as a A2DP SRC. Setting up the SRC in A3DP and the SNK in A2DP is possible, but it'll likely be simpler for you to do A2DP for both roles.

    In terms of an example demonstrating A2DP SRC, it appears that the AUDDemo provided with the CC256XSTBTBLESW doesn't have the SRC functionality implemented. I've attached some code from the CC256XM4BTBLESW SDK that has the SRC functionality implemented. Please refer to the full M4 SDK for further reference.

    /cfs-file/__key/communityserver-discussions-components-files/538/A2DPDemo.c

    /cfs-file/__key/communityserver-discussions-components-files/538/AudioEncoder.c

    /cfs-file/__key/communityserver-discussions-components-files/538/AudioEncoder.h

    Regards,

    Michael

  • Thanks for your help I will look that!

    Last question, with A2DP I will be able to have a bi-directional communication if I combine SRC and SNK in the same application?

    Best Regards,

    Alexandre

  • Hi Alexandre,

    You should be able to run both a2dp src and snk in the same application, but I would advise against using it as a bidirectional communication link as the audio latency when using a2dp is very high. HFP is a better profile to use for bidirectional audio.

    Regards,

    Michael

  • Hi again,

    I have already tried to use the HFP for the bidirectional communication. But I have some issue with the HFP Audiogateway protocol. I have managed to open the audio gateway, but I seems that I need to send an incoming call notification to enable the audio flow, but the “SendCallWaitingNotification” function return me an error message “ERROR INVALID_OPERATION”.

    Do you know by any chance why I have this error?

    Best Regards,

    Alexandre

  • Hi Alexandre,

    No, I do not know why SendCallWaitingNotification results in ERROR INVALID_OPERATION. I do recall there was a thread a few months ago where I was investigating this, but the debug results were inconclusive.

    Looking at the source code for the SendCallWaitingNotification function, there are a few possibilities for what could be causing that error to be returned. See below:

       /* This function is responsible for Sending Call Waiting             */
       /* Notifications to the Remote Device.  This function may only be    */
       /* performed by Audio Gateways which have Call Waiting Notification  */
       /* Enabled and have a valid Service Level Connection.  This function */
       /* accepts as its first input parameter the HFRE Port ID.  The final */
       /* parameter is the Phone Number required as one of the parameters   */
       /* within this response.  This parameter should be a pointer to a    */
       /* NULL terminated string (if specified) and must have a length less */
       /* than HFRE_PHONE_NUMBER_LENGTH_MAXIMUM.  This function returns zero*/
       /* if successful or a negative return error code if there was an     */
       /* error.                                                            */
       /* * NOTE * It is valid to either pass a NULL for the PhoneNumber    */
       /*          parameter of a blank string to specify that there is no  */
       /*          phone number present.                                    */
    int BTPSAPI HFRE_Send_Call_Waiting_Notification(unsigned int BluetoothStackID, unsigned int HFREPortID, char *PhoneNumber)
    {
    #if BTPS_CONFIGURATION_HFRE_SUPPORT_AUDIO_GATEWAY_ROLE
    
       int         ret_val;
       char        OutputBuffer[32+HFRE_PHONE_NUMBER_LENGTH_MAXIMUM];
       HFREInfo_t *HFREInfo;
    
       /* Make sure that the passed in parameters seem semi-valid.          */
       /* * NOTE * It is possible that the Phone Number can be empty so we  */
       /*          need to check for this case.                             */
       if((BluetoothStackID) && (HFREPortID) && ((!PhoneNumber) || ((PhoneNumber) && (BTPS_StringLength(PhoneNumber) <= HFRE_PHONE_NUMBER_LENGTH_MAXIMUM))))
       {
          /* Lock the Bluetooth Stack to gain exclusive access to this      */
          /* Bluetooth Protocol Stack.                                      */
          if(!BSC_LockBluetoothStack(BluetoothStackID))
          {
             /* Wait for access to the Hands-Free profile information list. */
             if(BSC_AcquireListLock())
             {
                if((HFREInfo = SearchHFREEntry(&HFREInfoList, HFREPortID)) != NULL)
                {
                   /* Release the List Lock that we acquired earlier.       */
                   BSC_ReleaseListLock();
    
                   /* This action is only performed by the Audio Gateway.   */
                   if(HFREInfo->AudioGateway)
                   {
                      /* We are an Audio Gateway , now make sure that the   */
                      /* Service Level Connection is in a state such that we*/
                      /* can send this command.                             */
                      if(HFREInfo->ServiceLevelConnectionState == csConnected)
                      {
                         /* We are in a state in which we can send this     */
                         /* command, now check to make sure that Call       */
                         /* Waiting Notification has been activated.        */
                         if(HFREInfo->CallWaitingNotificationActivated)
                         {
                            /* Call Waiting Notification has been activated,*/
                            /* build the packet and send it out.            */
                            BTPS_SprintF(OutputBuffer, "%s%s%s\"%s\",%s,%s%s", HFRE_RESPONSE_PREFIX_SUFFIX,
                                                                               HFRE_CALL_WAITING_NOTIFICATION_COMMAND,
                                                                               HFRE_RESPONSE_MODIFIER_SEMI_SPACE,
                                                                               PhoneNumber?PhoneNumber:"",
                                                                               HFRE_CALL_WAITING_TYPE_OF_ADDRESS,
                                                                               HFRE_CALL_WAITING_CLASS,
                                                                               HFRE_RESPONSE_PREFIX_SUFFIX);
    
                            if((ret_val = SPP_Data_Write(BluetoothStackID, HFREInfo->SPPPortID, (Word_t)BTPS_StringLength(OutputBuffer), (Byte_t *)OutputBuffer)) > 0)
                               ret_val = 0;
                         }
                         else
                            ret_val = BTHFRE_ERROR_INVALID_OPERATION;
                      }
                      else
                         ret_val = BTHFRE_ERROR_INVALID_OPERATION;
                   }
                   else
                      ret_val = BTHFRE_ERROR_INVALID_OPERATION;
                }
                else
                {
                   /* Release the List Lock that we acquired earlier.       */
                   BSC_ReleaseListLock();
    
                   ret_val = BTHFRE_ERROR_NOT_INITIALIZED;
                }
             }
             else
                ret_val = BTHFRE_ERROR_NOT_INITIALIZED;
    
             /* UnLock the previously locked Bluetooth Stack.               */
             BSC_UnLockBluetoothStack(BluetoothStackID);
          }
          else
             ret_val = BTHFRE_ERROR_INVALID_BLUETOOTH_STACK_ID;
       }
       else
          ret_val = BTHFRE_ERROR_INVALID_PARAMETER;
    
       /* Return the result to the caller.                                  */
       return(ret_val);
    
    #else
    
       return(BTPS_ERROR_FEATURE_NOT_AVAILABLE);
    
    #endif
    }

    The main two situations that make sense are:

    1. The enable call waiting function isn't actually successful in enabling call waiting notifications

    2. The service level connection between the audio gateway and the handsfree device isn't in a connected state.

    Even though the source code is not available to you, if you were to run your application in debug mode you should be able to see the function symbols as you step through your application. If you step through and debug your application as you run that SendCallWaitingNotification command, can you verify that the ERROR INVALID_OPERATION error was indeed first returned from the HFRE_Send_Call_Waiting_Notification()? If you check and share the callstack of your device when that error is returned that would be helpful.

    Regards,

    Michael