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.

Set Default PIN Code for Pairing

Hi,

I am trying to connect from msp430 f5438 using an android tablet using bluterm app.I am using SPPLE Demo example.I am trying to modify the PIN number used while pairing.Now the system runs this way i tries to connect from bluterm its asks for say i gave 3456 then in teraterm i gives PINCodeResponse 3456 then its paired.How can i set it to preconfigured PIN number?

I tried to chamge static int PINCodeResponse(ParameterList_t *TempParam) function like this but was of no use

static int PINCodeResponse(ParameterList_t *TempParam)
{
int Result;
int ret_val;
PIN_Code_t PINCode;
GAP_Authentication_Information_t GAP_Authentication_Information;

/* First, check that valid Bluetooth Stack ID exists. */
if(BluetoothStackID)
{
/* First, check to see if there is an on-going Pairing operation */
/* active. */
// if(!COMPARE_NULL_BD_ADDR(CurrentCBRemoteBD_ADDR))
// {
/* Make sure that all of the parameters required for this */
/* function appear to be at least semi-valid. */
// if((TempParam) && (TempParam->NumberofParameters > 0) && (TempParam->Params[0].strParam) && (BTPS_StringLength(TempParam->Params[0].strParam) > 0) && (BTPS_StringLength(TempParam->Params[0].strParam) <= sizeof(PIN_Code_t)))
if(1)
{
/* Parameters appear to be valid, go ahead and convert the */
/* input parameter into a PIN Code. */

/* Initialize the PIN code. */
ASSIGN_PIN_CODE(PINCode, 9, 9, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

// BTPS_MemCopy(&PINCode, TempParam->Params[0].strParam, BTPS_StringLength(TempParam->Params[0].strParam));

/* Populate the response structure. */
GAP_Authentication_Information.GAP_Authentication_Type = atPINCode;
// GAP_Authentication_Information.Authentication_Data_Length = (Byte_t)(BTPS_StringLength(TempParam->Params[0].strParam));
GAP_Authentication_Information.Authentication_Data_Length = 4;
GAP_Authentication_Information.Authentication_Data.PIN_Code = PINCode;

/* Submit the Authentication Response. */
Result = GAP_Authentication_Response(BluetoothStackID, CurrentCBRemoteBD_ADDR, &GAP_Authentication_Information);

/* Check the return value for the submitted command for */
/* success. */
if(!Result)
{
/* Operation was successful, inform the user. */
Display(("GAP_Authentication_Response(), Pin Code Response Success.\r\n"));

/* Flag success to the caller. */
ret_val = 0;
}
else
{
/* Inform the user that the Authentication Response was */
/* not successful. */
Display(("GAP_Authentication_Response() Failure: %d.\r\n", Result));

ret_val = FUNCTION_ERROR;
}

/* Flag that there is no longer a current Authentication */
/* procedure in progress. */
ASSIGN_BD_ADDR(CurrentCBRemoteBD_ADDR, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
}
else
{
/* One or more of the necessary parameters is/are invalid. */
DisplayUsage("PINCodeResponse [PIN Code]");

ret_val = INVALID_PARAMETERS_ERROR;
}
// }
// else
// {
/* There is not currently an on-going authentication operation,*/
/* inform the user of this error condition. */
// Display(("PIN Code Authentication Response: Authentication not in progress.\r\n"));

// ret_val = FUNCTION_ERROR;
// }
}
else
{
/* No valid Bluetooth Stack ID exists. */
ret_val = INVALID_STACK_ID_ERROR;
}

return(ret_val);
}
  • Ganesh,

    Can you post the code for the case atPINCodeRequest as well? You will need to comment out the following lines

    //Display(("\r\n"));
    //Display(("atPINCodeRequest: %s\r\n", Callback_BoardStr));

    //Display(("Respond with: PINCodeResponse\r\n"));

    This thread has a similar query http://e2e.ti.com/support/low_power_rf/f/660/t/211839.aspx 

    Also, can you tell us what is happening on the Android Device's side and whether you get the same behavior when pairing from the settings menu?


    Thanks,

    Stonestreet One.

  • Hi @Stonestreet One Support

    ,

    I followed that thread but didnt work.This is my case at atPINCodeRequest

     case atPINCodeRequest:
                      /* A pin code request event occurred, first display   */
                      /* the BD_ADD of the remote device requesting the pin.*/
                      BD_ADDRToStr(GAP_Event_Data->Event_Data.GAP_Authentication_Event_Data->Remote_Device, Callback_BoardStr);
       //               Display(("\r\n"));
       //               Display(("atPINCodeRequest: %s\r\n", Callback_BoardStr));
    
                      /* Note the current Remote BD_ADDR that is requesting */
                      /* the PIN Code.                                      */
                      CurrentCBRemoteBD_ADDR = GAP_Event_Data->Event_Data.GAP_Authentication_Event_Data->Remote_Device;
    
                      /* Inform the user that they will need to respond with*/
                      /* a PIN Code Response.                               */
                      Display(("Respond with: PINCodeResponse\r\n"));
                      break;
  • Ganesh,

    Can you comment out the 

    Display(("Respond with: PINCodeResponse\r\n"));

    and add a call to the PINCodeResponse function from here.

    Thanks,

    Stonestreet One.


  • Thank you Stonestreet One Support,

    Actually we need to call function like this  PINCodeResponse(NULL);

    and must give the values in quotes

    Just like PIN Number can i do pairing using MAC ID