4 Replies Latest reply on Oct 22, 2018 7:33 PM by XinghaoZ_26

    Maximum number of devices that can be paired

    user_3572401

      I am using CYBT-343026-EVAL with WICED 6.2 now.

      Could you tell me how many BT-Headset can pairing to this module at the same time?

      If the number can change,could you tell me where can I change it?SheetalJ_96AxLi_1746341TaGo_2353976NAYU_1212731sahi_988451

        • 1. Re: Max pairing decieve number
          XinghaoZ_26

          You need to make some change with the function headset_save_link_keys and headset_read_link_keys if you want to save more pairing information. The following code is a snip about the function. The device can store a fixed number of bonding devices(parameter "num_bond" in the code). The new device will overwrite the old one if the size is full. Please modify your own code with the reference of the snip.

           

          wiced_bool_t headset_save_link_keys(wiced_bt_device_link_keys_t *p_keys)

          {

              uint8_t                     bytes_written = 0, bytes_read;

              wiced_result_t              result;

              uint8_t                     nvram_id = HEADSET_NVRAM_ID;

              wiced_bt_device_link_keys_t keys;

              uint8_t                     i=0;

              uint8_t                     device_saved=0;

              uint8_t                     device_id=0;

           

           

              // there might be a situation where the keys are already saved, for example in dual mode

              // device the br/edr keys can be present when we are doing le pairing

              for(i=0; i<num_bond; i++)

              {

                  bytes_read = wiced_hal_read_nvram(nvram_id+i, sizeof(wiced_bt_device_link_keys_t), (uint8_t *)&keys, &result);

           

           

                  WICED_BT_TRACE("keys.bd_addr:%B p_keys:%B keys static:%B p_keys:%B\n", keys.bd_addr, p_keys->bd_addr, keys.key_data.static_addr, p_keys->key_data.static_addr);

           

           

                  if ((bytes_read == sizeof(wiced_bt_device_link_keys_t)) &&

                  (memcmp(p_keys->bd_addr, keys.bd_addr, BD_ADDR_LEN) == 0))

                  {

                      WICED_BT_TRACE("Device address already exist: %d", nvram_id+i);

                      bytes_written = wiced_hal_write_nvram(nvram_id+i, sizeof(wiced_bt_device_link_keys_t), (uint8_t *)p_keys, &result);

                      device_saved=1;

                      break;

                  }

              }

           

           

              if(device_saved==0)

              {

                  wiced_hal_read_nvram(nvram_id+num_bond,sizeof(uint8_t),(uint8_t *)&device_id, &result);

                  bytes_written = wiced_hal_write_nvram(device_id+nvram_id, sizeof(wiced_bt_device_link_keys_t), (uint8_t *)p_keys, &result);

                  WICED_BT_TRACE("Saved %d bytes at id:%d result:%d\n", bytes_written, device_id, result);

                  device_id++;

                  if(device_id >= num_bond)

                  {

                      device_id=0;

                  }

           

           

                  wiced_hal_write_nvram(nvram_id+num_bond, sizeof(uint8_t), (uint8_t *)&device_id, &result);

           

           

                  return (bytes_written == sizeof (wiced_bt_device_link_keys_t));

              }

           

           

           

           

              // try to figure out what is being updated

          //    if (p_keys->key_data.le_keys_available_mask != 0)

          //    {

          //        WICED_BT_TRACE("updating LE keys\n");

          //        keys.key_data.le_keys_available_mask = p_keys->key_data.le_keys_available_mask;

          //        keys.key_data.ble_addr_type          = p_keys->key_data.ble_addr_type;

          //        keys.key_data.static_addr_type       = p_keys->key_data.static_addr_type;

          //        memcpy (keys.key_data.static_addr, p_keys->key_data.static_addr, sizeof(p_keys->key_data.static_addr));

          //        memcpy (&keys.key_data.le_keys, &p_keys->key_data.le_keys, sizeof(p_keys->key_data.le_keys));

          //    }

          //    else

          //    {

          //        WICED_BT_TRACE("updating BR/EDR keys\n");

          //        keys.key_data.br_edr_key_type       = p_keys->key_data.br_edr_key_type;

          //        memcpy (keys.key_data.br_edr_key, p_keys->key_data.br_edr_key, sizeof(p_keys->key_data.br_edr_key));

          //    }

          //    WICED_BT_TRACE("Saved %d bytes at id:%d result:%d\n", bytes_written, nvram_id, result);

              return WICED_TRUE;

          }

           

           

          /*

          * This function is called to read keys for specific bdaddr

          */

          wiced_bool_t headset_read_link_keys(wiced_bt_device_link_keys_t *p_keys)

          {

              uint8_t                     bytes_read;

              wiced_result_t              result;

              wiced_bt_device_link_keys_t keys;

              uint8_t                     nvram_id = HEADSET_NVRAM_ID;

              uint8_t                     i;

              uint8_t                     find_flag=0;

           

           

              for(i=0; i<num_bond; i++)

              {

                  bytes_read = wiced_hal_read_nvram(nvram_id+i, sizeof(wiced_bt_device_link_keys_t), (uint8_t *)&keys, &result);

           

           

                  WICED_BT_TRACE("keys.bd_addr:%B p_keys:%B keys static:%B p_keys:%B\n", keys.bd_addr, p_keys->bd_addr, keys.key_data.static_addr, p_keys->key_data.static_addr);

           

           

                  if ((bytes_read == sizeof(wiced_bt_device_link_keys_t)) &&

                  (memcmp(p_keys->bd_addr, keys.bd_addr, BD_ADDR_LEN) == 0))

                  {

                      WICED_BT_TRACE("Device address already exist: %d", nvram_id+i);

                      bytes_read = wiced_hal_read_nvram(nvram_id+i, sizeof(wiced_bt_device_link_keys_t), (uint8_t *)p_keys, &result);

                      find_flag=1;

                      return (bytes_read == sizeof (wiced_bt_device_link_keys_t));

                  }

              }

           

           

              if(find_flag == 0)

              {

                  return NULL;

              }

          }

          1 of 1 people found this helpful
          • 2. Re: Max pairing decieve number
            user_3572401

            num_bond is not defined in your change.

            Where should it be defined and what number should it be defined?SheetalJ_96NAYU_1212731TaGo_2353976

            • 3. Re: Max pairing decieve number
              user_3572401

              Whether I can change max number  of pairing device if I changed my own code to your upon code .

              I have tried some way to change Max number of pairing device.

              I changed here.hci_control.h:Line:79

              [#define HCI_CONTROL_AG_NUM_SCB          2           /* Max simultaneous connections to HFs */]

              I changed HCI_CONTROL_AG_NUM_SCB from 2 to 1.

              The result is CYBT-343026-EVAL can only pair to 1 device only at the same time .

              Then I changed HCI_CONTROL_AG_NUM_SCB from 1 to 3.

              The result is CYBT-343026-EVAL can  not pair to 3 device,it just can pair to 2 device only.

              I guess there is a restriction exits somewhere.I am finding it.

              Do you know it?SheetalJ_96TaGo_2353976NAYU_1212731sahi_988451

              • 4. Re: Maximum number of devices that can be paired
                XinghaoZ_26

                num_bond is a macro defination need to be added by yourself. You can define it with 10 for 10 paired devices' infromation to store.