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.

MSP430F5xx and CC2564b - HFP mode auto connect

Other Parts Discussed in Thread: MSP430F5438, MSP-FET

Hi,

I search on the forum before to post, but I found nothing clear about this issue, and it looks like I am not the only one with this need.

I am at the edge of a project based on MSP430 and CC2564b. I am using the HFP demo as a basis.

The thing is that I need to enter the passkey and initiate the process with my smartphone each time I want to connect it with my Bluetooth device.

My goal is to make it autoconnect with the receiver already paired when the code start. i.e. After starting I check if the known host is in range and connect it if possible.

Is a function like that implemented in Bluetopia? Do you have at least a code example to implement in my project? Or even a guideline to proceed?

I am using BLuetopia stack for MSP+CC2564b v1.5R2.

Thank you in advance,

Best regards

Anthony

  • Hi,

    You need to save the Linkkey information to persistent store, and reuse it on boot up.
    Please see "LinkKeyInfo" in the HFP demo app.

    As for the auto connection, you can issue a connect to the remote BD Address. If the device is not available, the connect will timeout after Page timeout interval. The page timeout interval is configurable (HCI_Write_Page_Timeout() - default: 5 seconds) .

    Regards,
    Gigi Joseph.
  • Hi,

    Thanks for the input.

    After my first pairing using the PIN code, I store the whole LinkKeyInfo struct (i.e. the BD_ADDR and the LinkKey value).

    On the next boot up, I load it in the LinkKeyInfo struct, and then I call GAP_Initiate_Bonding (with the known BD_ADDR). After that I have the event etAuthentication with the event type atLinkKeyRequest. In this one I see that I have a linkKey stored, and I send the GAP_Authentication_Response with it. And then nothing happen... My smartphone never got connect with my device.

    If I don't load the LinkKeyInfo struct on boot up I can see an "ask for pairing" pop up on the smartphone when I call GAP_initiate_Bonding, which means that the GAP_initiate_Bonding is properly call and that the callback can see clearly if I have an existing value in the LinkKeyInfo struct or not.

    But if I ask a connection from the smartphone, I have a really fast connection, and the PIN code is not asked (which mean that the linkKeyInfo was entirely correct).

    I also try to change the value of the page timeout per your recommandation but nothing change.

    Of course I chek all the function call return value and it's always successful.

    It looks like I am close to my goal, but I missed a part which make the link established between the smartphone and my device when the request is initiated by my device. Any clue about that? Did I missed a function call mandatory?

    Thanks for the help,
    Anthony
  • Hi,

    If you want to initiate auto connection from the DUT to the smartphone, then after boot up, you need to do a SDP to get the smartphone port number (then cancel SDP) and initiate the connection using the API HFRE_Open_Remote_Audio_Gateway_Port()
  • Hi,

    Thanks for the input, but I am not sure to follow everything.

    In order to not pair again I have to load the linkKeyInfo at boot up, this part is okay.
    After the authentification is finished, I want to use the SDP function in the callback atAuthenticationStatus if everything is okay on the previous step.
    So I look at the SDP function in the HFRE API and I don't find anything to get the port number on the smartphone side... Actually I really can't find how to get that before to call HFRE_Open_Remote_Audio_Gateway_Port (with the same parameter as HFRE_Open_HandsFree_Server_Port but with the good port number I assume?). Can you point me the function needed to do that?

    In addition, can I open my local port using HFRE_Open_HandsFree_Server_Port ? Is it okay to open both (as I register a SDP record using HFRE_Register_HandsFree_SDP_Record after my local port is opened)? I would like to do that in order to allow an other device to pair if needed (even if I need only one connection at a time).

    Thanks for the support,
    Regards,
    Anthony
  • Hi,

    Yes, and also to have the BD address of the remote device.

    Using SDP_Service_Search_Attribute_Request() API you can do the SDP, you can download the Tiva SDK and have a look at MAP and PBAP demo's for reference.

    I don't see any problem if you have the server port ID opened, when you use HFRE_Open_Remote_Audio_Gateway_Port(), you get client port ID.
  • Hi,

    Yes I also have the BD address of the remote device (a smartphone in my case).

    So after the atAuthenticationStatus in my GAP event callback (saying that my device and the smartphone connection is okay as I have loaded the linkkeyInfo correctly) I send a SDP_Service_Search_Attribute_Request().

    I also added in the project the SDP callback with all the possibilities, and after my SDP_Service_Search_Attribute_Request call I goes into the callback properly. My problem is that I always have a rdConnectionError.

    I take a look at the Tiva example too.

    Just to check I call the function like that :
    SDP_Service_Search_Attribute_Request(BluetoothStackID, TargetADDR, 1 ,&SDPUUIDEntry, 1, &AttributeID, SDP_Event_Callback, (unsigned long)0);
    with:
    SDP_Attribute_ID_List_Entry_t AttributeID;
    AttributeID.Attribute_Range = (Boolean_t)TRUE;
    AttributeID.Start_Attribute_ID = 0;
    AttributeID.End_Attribute_ID = 65335;

    SDP_UUID_Entry_t SDPUUIDEntry;
    SDPUUIDEntry.SDP_Data_Element_Type = deUUID_16;
    ASSIGN_SDP_UUID_16(SDPUUIDEntry.UUID_Value.UUID_16, 0x11, 0x1E); // as 0x111E is the HFP profile indentifier in Bluetooth Core

    Is everything looks good for you?
    In the previous post you said to cancel the SDP, I don't follow this point. If I cancel my request where I get the port to be used?
    Do I need to call a GAP function to connect or wathever before to call the SDP service search attribute request?

    And after the SDP is okay, I have to get the port in the event rdServiceAttributeResponse and call :
    HFRE_Open_Remote_Audio_Gateway_Port(BluetoothStackID,TargetADDR, - The port I get using the SDP - , HFRE_SUPPORTED_FEATURES, 0, NULL,HFRE_Event_Callback, (unsigned long)0);

    Thank you,
    Anthony
  • Hi,

    You can take the same implementation, But in the UUIDTable array add the below, as you need to query the remote AG port number

    "Audio gateway", { 0x00, 0x00, 0x11, 0x1F, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB } },
  • Hi,

    Thank you the UUID was not okay, thanks for the good one.
    I found also that I have the rdConnectionError because I was doing the GAP_Initiate_Bonding before the SDP_Service_Search_Attribute_Request.

    Now After I boot up and initialized my Bluetooth stack, I send the SDP_Service_Search_Attribute_Request And then I got a rdServiceSearchAttributeResponse.
    (with UUID: SDPUUIDEntry.SDP_Data_Element_Type = deUUID_128;
    ASSIGN_SDP_UUID_128(SDPUUIDEntry.UUID_Value.UUID_128, 0x00, 0x00, 0x11, 0x1F, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); )

    You can see the parameter I got here: drive.google.com/.../view

    I have the Number_Service_Record set to 1 as I change my development smartphone (now I am with a 4.4.2 smartphone, and with the other in 4.2 I always have 0 in this field). Do you see that before?
    I take a look at processors.wiki.ti.com/.../CC256x_TI%E2%80%99s_Bluetooth_Stack_Basic_HFGAGDemo_APP as they are looking for the remote audio port too but I don't have the same thing..

    I really don't know where to find the port number in it.. For the SDP_Data_Element_Length I was expected 2 as I need an unsigned int but it's 4. Is it normal?
    the SDP_Data-Element_Type in the child is deNIL, is it normal too?

    After that I assume that I will only have to call
    HFRemoteServerPort = HFRE_Open_Remote_Audio_Gateway_Port(BluetoothStackID,TargetADDR, myRemoteSPort , HFRE_SUPPORTED_FEATURES, 0, NULL,HFRE_Event_Callback, (unsigned long)0);
    In the HFRE API the event throwing back is etHFRE_Port_Open_Confirmation but in the stack I only have etHFRE_Open_Port_Confirmation. Can you confirm that it's normal and a difference with the PDF against the source code?
    I tried that with several info from the SDP request, I always have a HFRE port set to 18 and no callback needed..

    Thanks to let me know if everything here is clean and should be okay for you.

    Regards,
    Anthony
  • Hi,

    It looks fine, the port id will be the last parameter of the Attribute ID 4. 

    Please see the attached file (reference.zip ) for reference, where you can initiate the connection to the smart phone from the DUT.

    NOTE : This file does not implement auto connect, But implements initiating the connection from the DUT (CC256x acting as handsfree) to Smart phone, and use it only for reference, don't use it directly.

  • Hi

    Thanks for the source, I have almost all the same thing, it looks like I am close to my target..

    For the port number, yes I am looking to the Attribute ID 4, but I can't find it...
    drive.google.com/.../view
    It looks like I have only an attribute ID of 0 and 8

    After the HFRE_Open_Remote_Audio_Gateway_Port is called with the good port number I will have both device connected, right?

    Thanks again..
    Anthony
  • Hi,

    It looks like I am bad parsing the result in SDP_Response_Data

    I make the function work on my eval board with your code..

    I will keep you posted, and thanks for the help

    Best regards
    Anthony
  • Hi,

    Yes. can you print it to the console like in the file I have provided (you can run the SDP from the console SERVICEDISCOVERY <inquiry index> <12(audio gateway)>).
    please make sure you are parsing it right
  • Hi,

    Yes I done that and make it functionnal (also according processors.wiki.ti.com/.../CC256x_TI%E2%80%99s_Bluetooth_Stack_Basic_HFGAGDemo_APP)

    I am checking with my project what I missed.

    Thanks for the prompt feedback

    Anthony
  • Hi,

    I finnaly get the good port number, mainly by checking how the display function works.
    Now I have all the parameter needed for the function HFRE_Open_Remote_Audio_Gateway_Port.
    My issue now.. is that I have always the error -1004 when I called the function. (i.e. (-1004) BTHFRE_ERROR_INSUFFICIENT_RESOURCES ).

    At what ressources point I need to check in order to go over it? Do you have a checklist for this point? A list of known issue?

    It looks like I am really close to the target, thank you very much for that.

    Best regards,
    Anthony
  • Hi,

    Please make sure all the parameters (BDaddress, stack-id, port number, callback, ...) you are passing are correctly.
    As you were able to make it functional from the console, It should work from the code as well (for auto-connect)
  • Hi,

    After a lot of test on my PCBA with my code and also on the eval board with your code I have the following result:

    On the eval board (using the MSP430F5438 kit) If I call the HFRE_Open_Remote_Audio_Gateway_Port func in the SDP callback it fails with the error 40 (always).

    In my code, If I am in debug (using IAR), I never succeed to get a good return for the function HFRE_Open_Remote_Audio_Gateway_Port (called in the SDP callback too, I have the error 1004).

    But In my implementation, if I don't open my local HFServer, and I call the HFRE_Open_Remote_Audio_Gateway_Port in the SDP callback without being in debug mode (ie. PCBA running with the product power supply with the MSP-FET unplugged) it works ! (I have the request on the phone, I need to finish the implementation in order to accomplish the full connection process).

    Does it means something for you? I am really confused with the thing that the return is okay when I am with the MSP-FET unplugged. Sure I double checked each time that the parameter are okay.

    Thanks for the feedback, I will keep you posted and update the post tomorrow.

    Regards,

    Anthony

  • Hi,

    After several additional test, with my code I have the PINCode request, the linkKeyCreation callback in the GAP, but never the Authentification status which means that the authentification is finished.
    Beside of that I Also never have the etHFRE_Open_Port_Confirmation (I use the LED on my PCBA in order to check that as I can't debug and have a call to open remote audio gateway okay.

    Any thought?

    Thank you
    Anthony
  • Hi,

    The issue was BTPS_MEMORY_BUFFER_SIZE value, I had to make it bigger (it's 4500 now). Now it works and I have the Open port etHFRE_Open_Port_Confirmation, but nothing happend after that, on the smartphone the device is connected but without any voice service (it appear as a device only) and nothing happen, I only have a etHFRE_Close_Port_Indication after 30 to 1 minute..
  • Hi,

    Thanks for the good feedback, I solve my last bug only in changing BTPS_MEMORY_BUFFER_SIZE to 4500.
    Thank you for the great support, it's working now, the last thing to check in addition of my last post in order to make it works is to check that the remoteClientPortID is well used and put where it's needed (instead of HFREportID).
    Can you say me what is the "size" limit for the BTPS_MEMORY_BUFFER_SIZE, and what is the impact on the library ? I am debogging the whole product right nom (testing that everything is fine) and I am curiour to know this point.

    Thanks for the help and I hope that this post will help others as it is really a good guide to go through this.

    Best regards
    Anthony
  • Hi,

    It depends on the memory available.