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/CC2650: Password protect access to device

Part Number: CC2650

Tool/software: Code Composer Studio

Hi,

I've been reading through the software development guide and it seems that a randomly generated passcode can be displayed so that it is known that only users who can see that code can access the device. I would like to limit access even more to only trusted users. Is there a way using the gap bond manager to set up a password system so that only people who know that password can access the device? Or would this need to be done at the application level?

Thanks for your help, any insight on how to implement something like this would be appreciated.

Regards,

Ian

  • Hi Ian,

    By default, the Simple Peripheral project uses a static passcode. You can choose not to display it if you'd like. You can look at the "Setup the GAP Bond Manager" in simple_peripheral.c to see how to add a static passkey.
  • Hi Rachel,

    I have been basing my project off the Simple Peripheral sample project however I don't remember ever being asked for a passcode to pair with the sensor tag. I tried replacing the passkey with a 6 digit number, and still was not asked to provide a passcode when pairing with my phone. I've also tried disabling bonding in case I did enter a passcode the first time and it saved the keys in SNV but that also didn't change anything. 

    Could you point me to what needs to be changed to enable the static passcode? My current set up is below.

      // Setup the GAP Bond Manager
      {
        uint32_t passkey = 123456; //0; // passkey "000000"
        uint8_t pairMode =  GAPBOND_PAIRING_MODE_WAIT_FOR_REQ;
        uint8_t mitm = TRUE;
        uint8_t ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY;
        uint8_t bonding = TRUE;
    
        GAPBondMgr_SetParameter(GAPBOND_DEFAULT_PASSCODE, sizeof(uint32_t),
                                &passkey);
        GAPBondMgr_SetParameter(GAPBOND_PAIRING_MODE, sizeof(uint8_t), &pairMode);
        GAPBondMgr_SetParameter(GAPBOND_MITM_PROTECTION, sizeof(uint8_t), &mitm);
        GAPBondMgr_SetParameter(GAPBOND_IO_CAPABILITIES, sizeof(uint8_t), &ioCap);
        GAPBondMgr_SetParameter(GAPBOND_BONDING_ENABLED, sizeof(uint8_t), &bonding);
      }

    I appreciate the help!

    Thanks,

    Ian

  • Whoops,

    My characteristics didn't require authentication. It is working now. Solution is to change GATT_PERMIT_READ or GATT_PERMIT_WRITE, to GATT_PERMIT_AUTHEN_READ or GATT_PERMIT_AUTHEN_WRITE, under the "Profile Attributes - Table" in simple_gatt_profile.c for the characteristic values you want to protect. For example,

    /*********************************************************************
     * Profile Attributes - Table
     */
    
    static gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] = 
    {
      // Simple Profile Service
      { 
        { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
        GATT_PERMIT_READ,                         /* permissions */
        0,                                        /* handle */
        (uint8 *)&simpleProfileService            /* pValue */
      },
    
        // Characteristic 1 Declaration
        { 
          { ATT_BT_UUID_SIZE, characterUUID },
          GATT_PERMIT_READ, 
          0,
          &simpleProfileChar1Props 
        },
    
          // Characteristic Value 1
          { 
            { ATT_BT_UUID_SIZE, simpleProfilechar1UUID },
    		GATT_PERMIT_AUTHEN_READ | GATT_PERMIT_AUTHEN_WRITE,
            0, 
            //&simpleProfileChar1 //is an array now so remove the & as an array is a pointer
    		simpleProfileChar1
          },
    
          // Characteristic 1 User Description
          { 
            { ATT_BT_UUID_SIZE, charUserDescUUID },
            GATT_PERMIT_READ, 
            0, 
            simpleProfileChar1UserDesp 
          }, 

    Also if your doing an iOS app to connect you may need to forget the device in, Settings->Bluetooth-> the blue i beside Simple BLE Peripheral->Forget This Device, before the prompt will appear for you to enter the passcode.

    My "Setup The GAP Bond Manager" block of code is the same as in my previous post.

    Thanks again for the help!

    Ian