1 2 Previous Next 29 Replies Latest reply on Mar 10, 2020 1:55 AM by hiko_4316286

    About saving bonding information

    hinu_4327176

      Hello

      After performing (pairing and bonding), if the power is turned from OFF to ON, the key exchange will be performed at the time of connection as if the bonded information was lost.

      The following pairing process is implemented.

        ・ Base application: ble_hello_sensor

        ・GATT connection event (GATT_CONNECTION_STATUS_EVT): At connection
                 wiced_bt_dev_sec_bond() : Pairing start

        ・Device link key update event (BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT)
                 Save link key (wiced_bt_management_evt_data_t paired_device_link_keys_update) to DCT

        ・Device link key request event(BTM_PAIRED_DEVICE_LINK_KEYS_REQUEST_EVT)

                 Output : saved link key

        ・Power OFF→ON  event(BTM_ENABLED_EVT)
                 Set the held link key with wiced_bt_dev_add_device_to_address_resolution_db()

        ・I am using a user passkey when pairing.

        ・Operating environment CYW43438 & WICED-Studio-6.4

       

      If you connect to the central device again after turning the power off and on, the inquiry and key exchange of the user passkey will operate.
      I want to connect to the central device once bonded without re-entering the user passkey.

       

      In Windows10 and iOS terminals, user passkey inquiry and key exchange work.

      On Android devices, user passkey query and key exchange do not work.

       

      Please tell me how to solve the problem.

        • 1. Re: About saving bonding information
          AnjanaM_61

          Hi Hiroaki nunome San,

           

          Can you please clarify the query ?

          Do you mean for Windows 10 and iOS there device is connecting and pairing is successful without re-entering passkey (after power off & On)

          And only for Android , it always asking for passkey entry ?

          If that is the case , can you please make sure the device is bonded properly on Android side? Which android app you are using?

           

          Regards,
          Anjana

          • 2. Re: About saving bonding information
            hinu_4327176

            Hello

             

            I'm sorry I don't understand the BT specifications and ask unknown questions.

             

            In the case of Android (using a communication test application as a central), the following operations are performed.
               Connection & pairing start
                  ↓
               Passkey request
                  ↓
               Pairing completed
                  ↓
               Confirm the completion of pairing and bonding with the communication test application
                  ↓
               Power off and on CYW43438 (peripheral)
                  ↓
               Connection
                  ↓
               Connection successful

               "Device link key update event (BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT)" is not issued for connection after power off & on.

             

            In the case of Windows 10 and iOS (using a communication test application as a central), the following operation is performed.
               Connection & pairing start
                  ↓
               Passkey request
                  ↓
               Pairing completed
                  ↓
               Confirm the completion of pairing and bonding with the communication test application
                  ↓
               Power off and on CYW43438 (peripheral)
                  ↓
               Connection
                  ↓
               Passkey request
                  ↓
               Pairing completed

             

               After the power is turned off and on, a "Device link key update event (BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT)" is issued.

               On iOS, the device link key update stops halfway and the pairing fails.

               Since pairing and bonding are completed, passkey request & device link key update event will not occur in connection after power off & on?

             

            The following parameters are set for pairing.
                .oob_data = BTM_OOB_NONE
                .auth_req = BTM_LE_AUTH_REQ_SC_MITM_BOND
                .max_key_size = 0x10
                .init_keys = BTM_LE_KEY_PENC | BTM_LE_KEY_PID
                .resp_keys = BTM_LE_KEY_PENC | BTM_LE_KEY_PID

            • 3. Re: About saving bonding information
              AnjanaM_61

              Hi,

               

              Can you please provide the project which you are testing and steps to reproduce the issue? So that we can figure out the issue.

               

              Regards,
              Anjana

              1 of 1 people found this helpful
              • 4. Re: About saving bonding information
                hinu_4327176

                Hello

                 

                It is difficult to provide everything because of the project during product development.
                Provide an excerpted project.

                 

                Please wait a little.

                • 5. Re: About saving bonding information
                  hinu_4327176

                  Hello

                   

                  Attach the part of the project you are testing.

                   

                  Central uses the application for BLE communication test on iPhone6.
                    Application:LightBlue (Downloaded from App Store.)

                   

                  Reproduction procedure

                  1) Start Peripheral (apps / BLR_test).

                  2) The advertisement is send.
                        Device name:BLE_test1

                  3) Select (BLE_test1) from the scan results in Central (LightBlue) and connect.
                        Enter the user passkey displayed in the log into Central (LightBlue) and connect.

                  4) (Bluetooth status events) are issued and pairing works normally.
                        event:BTM_PAIRING_IO_CAPABILITIES_BLE_REQUEST_EVT
                          ↓
                        event:BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT
                          ↓
                        event:BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT
                          ↓
                        event:BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT
                          ↓
                        event:BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT
                          ↓
                        event:BTM_PAIRING_COMPLETE_EVT

                  5) Power off and on the Peripheral (apps / BLR_test) and restart.

                  6) The advertisement is send.
                        Device name:BLE_test1

                  7) Select (BLE_test1) from the scan results in Central (LightBlue) and connect.
                        Central(LightBlue):No user passkey request.

                  8) (Bluetooth status events) have been issued.
                        event:BTM_PAIRED_DEVICE_LINK_KEYS_REQUEST_EVT
                          ↓
                        event:BTM_PAIRING_IO_CAPABILITIES_BLE_REQUEST_EVT)
                          ↓ Event publication stops for a while.
                        event:BTM_PAIRING_COMPLETE_EVT
                          ↓ Pairing will be NG. time out?

                   

                  In connection 7), the return value of [wiced_bt_dev_sec_bond ()] is [WICED_BT_PENDING].
                  If bonded, will it be [WICED_BT_SUCCESS]?


                  If the Pairing IO is set to the following settings, the operation result will change when [Disconnect → Reconnect] with Central (LightBlue).
                    (Pairing IO:wiced_bt_dev_ble_io_caps_req_t).local_io_cap = BTM_IO_CAPABILITIES_NONE

                  4) (Bluetooth status events) are issued and pairing works normally.
                        event:BTM_PAIRING_IO_CAPABILITIES_BLE_REQUEST_EVT
                          ↓
                        event:BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT
                          ↓
                        event:BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT
                          ↓
                        event:BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT
                          ↓
                        event:BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT
                          ↓
                        event:BTM_PAIRING_COMPLETE_EVT

                  5) In Central (LightBlue), [Disconnect → Reconnect].

                  6) (Bluetooth status events) have been issued.
                        event:BTM_PAIRING_IO_CAPABILITIES_BLE_REQUEST_EVT)
                          ↓ Event publication stops for a while.
                        event:BTM_PAIRING_COMPLETE_EVT
                          ↓ Pairing will be NG. time out?

                   

                  In connection 6), the return value of [wiced_bt_dev_sec_bond ()] is [WICED_BT_PENDING].
                  If bonded, will it be [WICED_BT_SUCCESS]?


                  I am confused.
                  I don't know how to reconnect after pairing and bonding with the iPhone.
                  Please give me some advice.

                  • 6. Re: About saving bonding information
                    AnjanaM_61

                    HI Hiroaki nunome San,

                     

                    I don't see you have saved the paired link keys in BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT.

                     

                    Can you please save the keys in this event and try ?

                    Please refer to ble_wifi_introducer demo in SDK for reference.

                     

                    If you are confused with the event flow during disconnect and reconnect after pairing & bonding, please refer to table under 4B.7 WICED Bluetooth Firmware Architecture in the attached doc for clarification.

                     

                    Thanks,

                    Anjana

                    • 7. Re: About saving bonding information
                      hinu_4327176

                      Hello

                       

                      In the source code posted on 1/21, the link key is stored in the following way.

                       

                        1)BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT
                            : Save the link key in a variable.
                        2)BTM_PAIRING_COMPLETE_EVT
                            :When pairing is completed successfully, save the link key saved in the variable to NVRAM.
                             ※The link key last notified by BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT is stored in NVRAM.

                       

                      Attach the simplified source code.
                      The same phenomenon as the source code posted on 1/21 occurs.

                       

                      [Outline of processing]
                        1)GATT_CONNECTION_STATUS_EVT
                            : Execute wiced_bt_dev_sec_bond () when connected.

                       

                        2)BTM_PAIRING_IO_CAPABILITIES_BLE_REQUEST_EVT
                            : Set pairing_io_capabilities_ble_request

                       

                        3)BTM_PAIRED_DEVICE_LINK_KEYS_UPDATE_EVT
                            : Save paired_device_link_keys_update to NVRAM.
                              Save to DCT_APP_SECTION with wiced_dct_write ()
                              ※ble_wifi_introducer/ Saving paired_device_link_keys_request.
                                Judged that the method of retaining paired_device_link_keys_update is correct.

                       

                        4)BTM_ENABLED_EVT
                            : Set the link key saved in NVRAM with wiced_bt_dev_add_device_to_address_resolution_db()

                       

                        5)BTM_PAIRED_DEVICE_LINK_KEYS_REQUEST_EVT
                            : Set the link key saved in NVRAM to paired_device_link_keys_request

                       

                        6)BTM_SECURITY_REQUEST_EVT
                            : Execute wiced_bt_ble_security_grant()


                        The source code posted on 1/21 is also implemented with reference to ble_wifi_introducer.
                        Are there any other events that need to be processed?

                       

                      Thanks

                      • 8. Re: About saving bonding information
                        hinu_4327176

                        Hello

                         

                        Did you reproduce this problem with the project you provided?

                         

                        As a hint to solve the problem, is there a sample program that has a track record of operation other than [ble_wifi_introducer /]?

                        1)Pairing & bonding
                        2)Power OFF⇒ON & reconnect to bonded device

                         

                        Thanks

                        • 9. Re: About saving bonding information
                          HiNa_2357246

                          Hi Hinu-san,

                           

                          >BLE_test.zip

                          This simple reproduction project seems to have additional debug logs.

                          Could you attach a log for reproducing the issue for analysis?

                           

                          Thanks

                          • 10. Re: About saving bonding information
                            hinu_4327176

                            Hello

                             

                            Attach a log of when the problem was reproduced.

                             

                            It will be helpful if you can give us advice that can solve the problem

                             

                            Thanks

                            • 11. Re: About saving bonding information
                              HiNa_2357246

                              February 28, 2020 8:46 PM

                              E-mail To hinu_4327176 from HiNa_2357246

                               

                              -----

                               

                              ログで気になる点は以下です。

                              [2020-02-28 15:16:57.594] !!!!!!!!!!!!!!!!!!!!!!!!!! management event 21

                               

                              これは,

                              BTM_LOCAL_IDENTITY_KEYS_REQUEST_EVT

                              になりますが, ble_ctrl.c では,

                              result = WICED_BT_NO_RESOURCES;

                              を返すだけのコードになっています。

                               

                              これは,自分の鍵情報を持っていないということを示しますので,

                              これを受け取った BT スタックは,新規で鍵を生成します。

                              初回は,このコードで良いと思いますが,2 回目以降は,以前の

                              鍵を使用する必要があるかと思います。この鍵を変えてしまうと,

                              正常に通信できずに新規の扱いになってしまう可能性があります。

                               

                              実際に,

                              [2020-02-28 15:15:33.490] !!!!!!!!!!!!!!!!!!!!!!!!!! management event 20

                              のところで,

                              BTM_LOCAL_IDENTITY_KEYS_UPDATE_EVT

                              のイベントが通知されていますが, NV RAM に保存するような

                              コードも書かれていないようですので,この部分も対応する

                              必要があるかと思います。

                               

                              具体的には,

                              ------------------

                              UPDATE_EVT では,

                              p_event_data->local_identity_keys_update

                              を NVRAM に保存する。

                              REQUEST_EVT では,

                              NVRAM にデータがあれば,それを読み出し

                              p_event_data->local_identity_keys_request

                              に格納して WICED_BT_SUCCESS を result として返す。

                              データが無ければ,今のまま。(WICED_BT_SUCCESS 以外を result

                              として返す)。

                              ------------------

                              という処理を追加して,動作を見て頂けますでしょうか。

                              • 12. Re: About saving bonding information
                                HiNa_2357246

                                Hi Anjana-san,

                                 

                                I received an urgent question from customer.

                                Please check the following.

                                 

                                -Did the issue reappear at your desk with the sample source code attached with Reply 5?

                                  Please tell us the current analysis status.

                                 

                                -Customer requires a sample program that works correctly for this issue. Is it possible to provide samples?

                                  If possible, is it possible to release by end of this week?

                                 

                                Regards,

                                Nagao.

                                • 13. Re: About saving bonding information
                                  HiNa_2357246

                                  March 3, 2020 10:24 AM

                                  E-mail To hinu_4327176 from HiNa_2357246

                                   

                                  改善は見られなかったとのこと、承知いたしました。

                                  お手数ですが下記のメールで頂いているサイプレス社へのリクエスト等は

                                   

                                  Community上でも同じ内容でリクエスト頂く様お願いします。

                                   

                                  以下、Communityへ添付されているソースコードの確認結果です。

                                   

                                  ソースコードを見ると,Cypressの評価ボードではなく,

                                  独自のボード(platform/TEST_board)に合わせた設定になっているようです。

                                  サイプレス社には貴社ボードがございませんので、Cypressの評価ボード上で

                                  再現できる環境としなければボード環境の合わせこみにかなりの工数が割かれる可能性があります。

                                   

                                  解析を進めるために,追加でお願いがあります。

                                   

                                  1. 1. Air sniffer でのログ取得

                                      Frontline 社や Ellisys 社での Air Sniffer が使えるようであれば,ログの取得をお願いいたし

                                      ます。この情報が分かると,解析が加速します。

                                   

                                  1. 2. 対抗機の Snoop 情報

                                      対抗機側で HCI Snoop ログの取得はできませんでしょうか。少なくとも,少し前の Android スマホ

                                      では,「設定」「開発者オプション」の下でHCI snoop ログの ON/OFF が設定でき, ON に

                                      した場合には, SDCARD に保存されると思います。

                                   

                                  1. 3. 今回,お願いしていた変更を行ったときのソースとログ

                                      期待した動作をしているのかを見たいと思いますのでソースとログをお願いいたします。

                                  UPDATE と REQUEST でやり取りしているデータの内容がログに出ていると確実に制御できているかを

                                      確認できると思います。

                                   

                                  1. 4. 一部,ソースコードの変更

                                      CDC には,ソースが 2 種類上がっていますが,

                                      そのうちの一方には,好ましくない設定になる恐れのあるコードがあります。

                                  BLEctrl_pairing_io_capabilities_ble_request_evt()

                                      で, local_io_cap に BTM_IO_CAPABILITIES_NONE

                                      が設定される場合がありますが,この設定では

                                      auth_req = BTM_LE_AUTH_REQ_SC_MITM_BOND は

                                      使用できません。 MITM の設定を外してください。

                                  お手数ですが下記のメールで頂いているサイプレス社へのリクエスト等は

                                  Community上でも同じ内容でリクエスト頂く様お願いします。

                                  • 14. Re: About saving bonding information
                                    hiko_4316286

                                    Hello

                                     

                                    1. What is the status of the analysis of malfunctions and how to handle them?

                                        Did the problem Reproduce in the source code submitted on February 20?

                                        If reproduced, what is the status of the cause analysis?

                                        When is the proposal for the countermeasures?

                                    2. The submission of operable sample software requested on February 25 should be received on March 4.

                                     

                                    Thanks

                                    1 2 Previous Next