10 Replies Latest reply on Jun 10, 2020 5:43 AM by AnjanaM_61

    Pairing with a smartphone (passkey input) ⇒ Deleting bonding information on the smartphone ⇒ Pairing without a passkey when BLE connection is made

    KEKA_4568351

      If you perform BLE connection with a smartphone in the following procedure, pairing with the smartphone will be performed without a passkey.

      I think that WICED's BLE library has a specification that devices that store bonding information are paired without a passkey even if there is no bonding information on the smartphone side. The ring will always require a passkey entry, unless both the device and smartphone (Central / Peripheral) have bonding information.

      I will attach the source of the device. (BLE_test, TEST_board.zip)

       

      I have a question here.

       

      ◆ QA

      1. Is there any awareness of this behavior?

      2. I want to enter the passkey unless both the device and smartphone (Central / Peripheral) have the bonding information. Is it possible to modify the application? After all, is it necessary to change the Bluetooth library?

      3. Do you plan to fix it in future version upgrades?

       

      ◆ Procedure

      1. Start BLE_test program (no bonding information)

      2. Check that there is no "BLE_test" from [Settings]-[Bluetooth] on the smartphone (either iOS or Android is possible).

      3. Start the application (use LightBlue, nRFConnect is also possible) from the smartphone, tap "BLE_test1" from "Peripherals", enter the passkey, and perform pairing.

      4. Delete "BLE_test" from [Settings]-[Bluetooth] on the smartphone.

      5. Launch the smartphone application and tap "BLE_test1" from "Peripherals". You will be connected without inputting the passkey.

      6. "BLE_test" exists in [Settings]-[Bluetooth] on the smartphone.

       

      ◆ Environment

      ● Smartphone

      ・ Device: iPad 4

      ・ IOS: 7.1 (11D167)

      ・ APP: LightBlue 2.4.0

       

      ● Device

      ・ App: BLE_test

      ・ SDK: WICED SDK 6.4.0

       

      <Japanese>

      スマートフォンとペアリング(パスキー入力)⇒スマートフォンのボンディング情報削除⇒BLE接続を行うと、パスキーなしで、ペアリングされる

       

      スマートフォンとBLE接続を以下の手順で行うと、スマートフォンとのペアリングで、パスキーなしでペアリングします。

      WICEDのBLEライブラリが、ボンディング情報を保存しているデバイスは、スマートフォン側にボンディング情報がなくても、パスキーなしでペアリングしている仕様になっているためと思いますが、他社のBLEのペアリングは、デバイス・スマートフォン(Central/Peripheral)の両方にボンディング情報がある場合以外は、パスキー入力が必ず発生します。

      デバイス側のソースを添付いたします。(BLE_test、TEST_board.zip)

       

      ここで、質問があります。

       

      ◆QA

      1.この動作について、認識はありますか。

      2.デバイス・スマートフォン(Central/Peripheral)の両方にボンディング情報がある場合以外は、パスキー入力を行いたいのですが、アプリケーションの修正で可能ですか。やはり、Bluetoothライブラリの変更が必要でしょうか。

      3.今後のバージョンアップで、修正する予定はありますか。

       

      ◆手順

      1.BLE_testプログラムを起動(ボンディング情報なし)

      2.スマートフォン(iOS,Androidどちらでも可)の[設定]-[Bluetooth]から、「BLE_test」がないことを確認する。

      3.スマートフォンから、アプリ(LightBlueを使用、nRFConnectでも可)を起動して、「Peripherals」から、「BLE_test1」をタップ、パスキー入力、ペアリングを行う。

      4.スマートフォンの[設定]-[Bluetooth]から、「BLE_test」を削除する。

      5.スマートフォンのアプリを起動して、「Peripherals」から、「BLE_test1」をタップする。パスキー入力がないまま、そのまま接続されてしまう。

      6.スマートフォンの[設定]-[Bluetooth]に、「BLE_test」が存在する。

       

      ◆環境

      ●スマートフォン

      ・デバイス:iPad 4

      ・iOS:7.1(11D167)

      ・APP:LightBlue 2.4.0

       

      ●デバイス

      ・アプリ:BLE_test

      ・SDK:WICED SDK 6.4.0

        • 1. Re: Pairing with a smartphone (passkey input) ⇒ Deleting bonding information on the smartphone ⇒ Pairing without a passkey when BLE connection is made
          AnjanaM_61

          Hi KEKA_4568351 ,

           

          Please note there is no issue with BLE stack (as peripheral role) of CYW4343

          I don't have iphone with me , only Android. But I think I understood the issue which you are trying to explain.

           

          First of all, I suggest you to go through the pairing process from BT spec.

          In most case Central device will initiate the pairing process . If not , peripheral also can request to initiate pairing process.

          However all this depends on customer application requirements specific.

          As per my understanding , Lightblue app is not initiating a pairing process, that's why we are calling wiced_bt_dev_sec_bond API in BLE_test to initiate the pairing process from peripheral. But with the iOS phone, whenever the peripheral initiates a pairing process , regardless of bonding info exists or not , iphone was sending passkey request . But in previous thread you mentioned you want to avoid this. That's why we added the check in peripheral application "only if device is not bonded , send wiced_bt_dev_sec_bond  API". Now your issue is when bond info is removed from smart phone and bond info exist in peripheral, there is no passkey entry asking. That is because lightblue is not automatically added any pairing initiate. If you test with CySmart android app, you have the option to pair from Central side as well. You can see the box 'Not paired / paired ' when the device lists adv packet. You have several option to move forward:

           

          1. First of all you have to understand the below scenarios -

              - When Central has bond info and peripheral doesn't have bond info - this will result in a pairing failure as per BT Spec. And can cause device disconnection depending on application.  In this case manually you have to remove the bond info from Central and initiate again

            - When Central doesn't have bond info and peripheral have bond info  , there won't be any pairing failure as such. But can initiate the pairing process again. In your application state as we have included the check , this won't happen .

          So its better to remove the bonding information from peripheral side as well if you see bonding info lost from mobile side before initiating the connection.

          For that you may add a switch interrupt to clear the bond info and and use API wiced_bt_dev_delete_bonded_device , also clear the bonded info in nvram.

           

          2. Another way is - If your end application Central device will be a custom app, and in your application if its ok to initiate the pairing process from Central mobile side, then add the pairing request from Central if device not pre-bonded.

           

          Hope this clarifies your doubts.

           

          Regards,

          Anjana

          1 of 1 people found this helpful
          • 2. Re: Pairing with a smartphone (passkey input) ⇒ Deleting bonding information on the smartphone ⇒ Pairing without a passkey when BLE connection is made
            AnjanaM_61

            Also wanted to add one more point.

            In the test application which you shared, handles for storing bonding information only for one device. If you want to save bonding info for more devices , then you have to modify the code such that you save the link keys info of each devices in different locations.

             

            Regards,
            Anjana

            • 3. Re: Pairing with a smartphone (passkey input) ⇒ Deleting bonding information on the smartphone ⇒ Pairing without a passkey when BLE connection is made
              KEKA_4568351

              Thank you very much.

              In the case of Mobile (Central & not Bond) -Device (Peripheral & Bond), it says that the bonding information of Device is deleted by “switch interrupt”. How do you implement “switch interrupt”?

              please tell me.

               

              >  - When Central doesn't have bond info and peripheral have bond info  , there won't be any pairing failure as such. But can initiate the pairing process again. In your application state as we have included the check , this won't happen .

              >So its better to remove the bonding information from peripheral side as well if you see bonding info lost from mobile side before initiating the connection.

              >For that you may add a switch interrupt to clear the bond info and and use API wiced_bt_dev_delete_bonded_device , also clear the bonded info in nvram.

               

              <Japanese>

              ありがとうございます。

              Mobile(Central&not Bond)ーDevice(Peripheral&Bond)のケースで、”switch interrupt”により、Deviceのボンディング情報を削除とありますが、”switch interrupt”は、どのように実装しますか。

              教えてください。

              • 4. Re: Pairing with a smartphone (passkey input) ⇒ Deleting bonding information on the smartphone ⇒ Pairing without a passkey when BLE connection is made
                KEKA_4568351

                If Mobile (Central & not Bond) side knows that there is no bonding information, we think that we can handle it, but please answer.

                 

                <Japanese>

                Mobile(Central&not Bond)側が、ボンディング情報がないということがわかれば、対応ができると思いますが、ご回答お願い致します。

                • 5. Re: Pairing with a smartphone (passkey input) ⇒ Deleting bonding information on the smartphone ⇒ Pairing without a passkey when BLE connection is made
                  AnjanaM_61

                  Hi KEKA_4568351 ,

                   

                  You can add button press by using API wiced_gpio_input_irq_enable .

                  Example:

                  wiced_gpio_input_irq_enable( WICED_BUTTON1, IRQ_TRIGGER_RISING_EDGE, button_press_callback, NULL );

                  In the button press call back , delete the bonding info using API wiced_bt_dev_delete_bonded_device , also clear the bonded info in nvram.

                   

                  Regards,

                  Anjana

                  1 of 1 people found this helpful
                  • 6. Re: Pairing with a smartphone (passkey input) ⇒ Deleting bonding information on the smartphone ⇒ Pairing without a passkey when BLE connection is made
                    KEKA_4568351

                    Thank you very much.

                    "Switch interrupt" was a switch on H/W.

                    Is rebonding possible with the following procedure?

                     

                    ◆ Processing procedure

                    1. Press the pairing switch.

                    2. If the pairing SW is pressed from the GATT event (GATT_CONNECTION_STATUS_EVT) function

                         Delete the bonding DB in advance.

                         wiced_bt_dev_delete_bonded_device

                    3. After that, bonding is performed.

                         wiced_bt_dev_sec_bond

                     

                    <Japanese>

                    ありがとうございます。

                    ”switch interrupt”は、H/W上のスイッチだったのですね。

                    以下の手順で、再ボンディングは、可能でしょうか。

                     

                    ◆処理手順

                    1.ペアリングのスイッチを押下する。

                    2.GATTイベント(GATT_CONNECTION_STATUS_EVT)の関数から、ペアリングのSWが押されていれば

                        事前に、ボンディングDBを削除する。

                        wiced_bt_dev_delete_bonded_device

                    3.その後に、ボンディングを行う。

                        wiced_bt_dev_sec_bond

                    • 7. Re: Pairing with a smartphone (passkey input) ⇒ Deleting bonding information on the smartphone ⇒ Pairing without a passkey when BLE connection is made
                      AnjanaM_61

                      Hi KEKA_4568351 ,

                       

                      Its actually application specific.

                       

                      As I told you before , you can implement the modifications on Central app side as well.

                       

                      If you are modifying on Peripheral side,

                      When Central loose bond info , and peripheral have bond info ,

                      Either you can add Button interrupt to clear the bond info and just continue the normal connection process. As the bond info & nvram content is clear the application logic will automatically call wiced_bt_dev_sec_bond.

                      If not ,  you can just call wiced_bt_dev_sec_bond in button interrupt to initiate the pairing from peripheral . Upon successful pairing , the previous bond info will overwrite. 

                      Its application specific. You can choose the appropriate way .

                       

                      Regards,

                      Anjana

                      1 of 1 people found this helpful
                      • 8. Re: Pairing with a smartphone (passkey input) ⇒ Deleting bonding information on the smartphone ⇒ Pairing without a passkey when BLE connection is made
                        KEKA_4568351

                        I added the part marked with ★ and tried it, but BLE connection is no longer possible.

                        The fix was a failure.

                        Below is a sample code.

                        Please point out any mistakes in the sample code.

                         

                        ◆sample code

                        // GATT event (GATT_CONNECTION_STATUS_EVT)

                        static void BLEctrl_gatt_connection_status_evt(wiced_bt_gatt_connection_status_t *p_status)

                        {

                        ・・・

                            if(WICED_TRUE == p_status->connected) {

                        ・・・

                                // ★pairing push button judgment

                                if(pairing_push_button == WICED_TRUE) {

                                    /* ★Clear the bonding information. */

                                    wiced_bt_dev_delete_bonded_device(p_status->bd_addr);

                                }

                        ・・・

                                // white list judgment

                                if(BLE_CTRLSTS_PERI_WHITELIST & s_ctrl.ctrlSts) {

                                    wiced_bt_dev_set_encryption(p_status->bd_addr, BT_TRANSPORT_LE, NULL);

                                } else {

                                    wiced_result = wiced_bt_dev_sec_bond(p_status->bd_addr, p_status->addr_type, BT_TRANSPORT_LE, 0, NULL);

                                    if(WICED_BT_SUCCESS == wiced_result) {

                                        wiced_bt_dev_set_encryption(p_status->bd_addr, BT_TRANSPORT_LE, NULL);

                                    }

                                }

                            } else {

                        ・・・

                            }

                        }

                         

                        <Japanese>

                        ★印の箇所を追加して試してみましたが、BLE接続ができなくなりました。

                        修正案としては、失敗でした。

                        以下、サンプルコードです。

                        サンプルコードで、間違いがあればご指摘ください。

                        • 10. Re: Pairing with a smartphone (passkey input) ⇒ Deleting bonding information on the smartphone ⇒ Pairing without a passkey when BLE connection is made
                          AnjanaM_61

                          Hi KEKA_4568351 San,

                           

                          I added remove bonding info test in WICED demo app and worked for me. Attached the same. Please test it at your side and let me know if you face any issue.

                           

                          Test results :

                          1. pair and bond to mobile phone

                          2. reset both mobile and device

                          3. remove bond info from mobile

                          4. If you try reconnecting now, the device won't try to pair again as we have not cleared the bond info

                          5. before connecting next time, press SW2 button on board to remove bond info

                          6. try connecting now. As there is no bond info, as per the logic we written in the sample code, the device will send pairing request again

                           

                          Note : The attached is modified version of SDK demo example ble_wifi_introducer. It uses Just works pairing and bond, however you can refer the remove bond info implementation.

                           

                          Regards,

                          Anjana