找回密码
 立即注册

微信扫码登录

查看: 124|回复: 2

[BLE SDK] TLSR825x tc_ble_single_sdk SMP issue

[复制链接]

1

主题

1

回帖

23

积分

英勇黄铜

积分
23
发表于 7 天前 | 显示全部楼层 |阅读模式 来自 欧洲和中东地区
Information
说明:   建议参照本版块置顶帖内容输入必要信息
芯片型号: TLSR825x512
SDK及版本: tc_ble_single_sdk-3.4.3.0_Patch_0001
本帖最后由 Malkavian22 于 2026-6-4 02:08 编辑

TLSR8258 (TLSR825x), tc_ble_single_sdk, ACL central master, SMP passkey entry (MITM, Level 3 и LESC Level 4) fails right after Pairing Request с RivieraWaves slave (CMT4531); Just Works (Level 2) is working.

Slave: CMT4531
Cfg:

/*  connection config  */
#define MIN_CONN_INTERVAL                   15                                         /**< Minimum connection interval (15 ms) */
#define MAX_CONN_INTERVAL                   30                                         /**< Maximum connection interval (30 ms). */
#define SLAVE_LATENCY                       0                                          /**< Slave latency. */
#define CONN_SUP_TIMEOUT                    5000                                       /**< Connection supervisory timeout (5000ms). */

#define FIRST_CONN_PARAMS_UPDATE_DELAY      (5000)                                     /**<  Time of initiating event to update connection params (5 seconds). */

//sec config
#define SEC_PARAM_IO_CAPABILITIES           GAP_IO_CAP_DISPLAY_ONLY                     /**< No I/O capabilities. (@enum gap_io_cap) */
#define SEC_PARAM_OOB                       0                                           /**< Out Of Band data not available. */
#define SEC_PARAM_KEY_SIZE                  16                                          /**< Minimum encryption key size. 7 to 16 */
#define SEC_PARAM_BOND                      1                                           /**< Perform bonding. */
#define SEC_PARAM_MITM                      1                                           /**< Man In The Middle protection not required. */
#define SEC_PARAM_LESC                      1                                           /**< LE Secure Connections not enabled. */
#define SEC_PARAM_KEYPRESS                  0                                           /**< Keypress notifications not enabled. */
#define SEC_PARAM_IKEY                      GAP_KDIST_IDKEY                             /**< Initiator Key Distribution. (@enum gap_kdist) */
#define SEC_PARAM_RKEY                      GAP_KDIST_ENCKEY                            /**< Responder Key Distribution. (@enum gap_kdist) */
#define SEC_PARAM_SEC_MODE_LEVEL            GAP_SEC1_AUTH_PAIR_ENC                      /**< Device security requirements (minimum security level). (@enum see gap_sec_req) */

//bond conifg
#define MAX_BOND_PEER                       5
#define BOND_STORE_ENABLE                   0
#define BOND_DATA_BASE_ADDR                 0x0103B000


//LESC
#define CFG_ECCH                (1)
#define BLE_APP_SEC_CON         (1)


Master init:

void user_init(void)
{
        //random number generator must be initiated here( in the beginning of user_init_nromal)
        //when deepSleep retention wakeUp, no need initialize again
#if(MCU_CORE_TYPE == MCU_CORE_825x || MCU_CORE_TYPE == MCU_CORE_827x)
        random_generator_init();  //this is must
#endif

        //        debug init
        #if(UART_PRINT_DEBUG_ENABLE)
                tlkapi_debug_init();
                blc_debug_enableStackLog(STK_LOG_DISABLE);
        #endif

        blc_readFlashSize_autoConfigCustomFlashSector();

        /* attention that this function must be called after "blc_readFlashSize_autoConfigCustomFlashSector" !!!*/
        blc_app_loadCustomizedParameters_normal();

        u8  mac_public[6];
        u8  mac_random_static[6];
        //for 512K Flash, flash_sector_mac_address equals to 0x76000
        //for 1M  Flash, flash_sector_mac_address equals to 0xFF000
        blc_initMacAddress(flash_sector_mac_address, mac_public, mac_random_static);
        //tlkapi_send_string_data(APP_LOG_EN,"[APP][INI]Public Address", mac_public, 6);

        ////// Controller Initialization  //////////
        blc_ll_initBasicMCU();
        blc_ll_initStandby_module(mac_public);                                //mandatory
        blc_ll_initScanning_module(mac_public);                         //scan module:                  mandatory for BLE master,
        blc_ll_initInitiating_module();                                                //initiate module:          mandatory for BLE master,
        blc_ll_initConnection_module();                                                //connection module  mandatory for BLE slave/master
        blc_ll_initMasterRoleSingleConn_module();                        //master module:          mandatory for BLE master,

        rf_set_power_level_index (MY_RF_POWER_INDEX);

        ////// Host Initialization  //////////
        blc_gap_central_init();                                                                                //gap initialization
        blc_l2cap_register_handler (app_l2cap_handler);                            //l2cap initialization
        blc_hci_registerControllerEventHandler(controller_event_callback); //controller hci event to host all processed in this func

        //bluetooth event
        blc_hci_setEventMask_cmd (HCI_EVT_MASK_DISCONNECTION_COMPLETE | HCI_EVT_MASK_ENCRYPTION_CHANGE);

        //bluetooth low energy(LE) event
        blc_hci_le_setEventMask_cmd(  HCI_LE_EVT_MASK_CONNECTION_COMPLETE  \
                                                            | HCI_LE_EVT_MASK_ADVERTISING_REPORT \
                                                            | HCI_LE_EVT_MASK_CONNECTION_UPDATE_COMPLETE \
                                                            | HCI_LE_EVT_MASK_DATA_LENGTH_CHANGE \
                                                            | HCI_LE_EVT_MASK_CONNECTION_ESTABLISH ); //connection establish: telink private event

        //ATT initialization
        blc_att_setRxMtuSize(MTU_SIZE_SETTING);//65 //set MTU size, default MTU is 23 if not call this API

        #if (MTU_SIZE_SETTING > ATT_MTU_MAX_SDK_DFT_BUF)
                blc_l2cap_initMtuBuffer(app_l2cap_rx_fifo, ACL_L2CAP_BUFF_SIZE, app_l2cap_tx_fifo, ACL_L2CAP_BUFF_SIZE);
        #endif

                blm_smp_configPairingSecurityInfoStorageAddr(flash_sector_master_pairing);
                                blm_smp_registerSmpFinishCb(app_host_smp_finish);
                                blc_gap_registerHostEventHandler(app_host_event_callback);
                                blc_gap_setEventMask( GAP_EVT_MASK_SMP_PARING_BEAGIN
                                                                        | GAP_EVT_MASK_SMP_PARING_SUCCESS
                                                                        | GAP_EVT_MASK_SMP_PARING_FAIL
                                                                        | GAP_EVT_MASK_SMP_TK_DISPLAY
                                                                        | GAP_EVT_MASK_SMP_TK_REQUEST_PASSKEY
                                                                        | GAP_EVT_MASK_SMP_CONN_ENCRYPTION_DONE );


                                blc_smp_setSecurityLevel(Authenticated_LE_Secure_Connection_Pairing_with_Encryption);  // Level 4
                                blc_smp_setPairingMethods(LE_Secure_Connection);     //  LESC (SC)
                                
                                blc_smp_enableSecureConnections(1);
                                blc_smp_setBondingMode(Bondable_Mode);
                                blc_smp_enableAuthMITM(1);                            //  MITM
                                blc_smp_setIoCapability(IO_CAPABILITY_KEYBOARD_ONLY);
                                blc_smp_setEcdhDebugMode(non_debug_mode);


                                flash_erase_sector(flash_sector_master_pairing); //for test
                                blc_smp_central_init();
                                blm_host_smp_setSecurityTrigger(MASTER_TRIGGER_SMP_FIRST_PAIRING);//MASTER_TRIGGER_SMP_AUTO_CONNECT

        /* set scan parameter and scan enable */
        blc_ll_setScanParameter(SCAN_TYPE_PASSIVE, SCAN_INTERVAL_100MS, SCAN_INTERVAL_100MS, OWN_ADDRESS_PUBLIC, SCAN_FP_ALLOW_ADV_ANY);
        blc_ll_setScanEnable (BLC_SCAN_ENABLE, DUP_FILTER_DISABLE);


        /* Check if any Stack(Controller & Host) Initialization error after all BLE initialization done.
         * attention that code will stuck in "while(1)" if any error detected in initialization, user need find what error happens and then fix it */
        blc_app_checkControllerHostInitialization();
}


        int app_host_event_callback(u32 h, u8 *para, int n)
        {
                (void)n;
                u8 event = h & 0xFF;
                switch(event)
                {
                case GAP_EVT_SMP_PAIRING_BEGIN:
                        reg_gpio_pa_setting1 ^= BIT(25);
                   // SMP
                        break;
                case GAP_EVT_SMP_TK_REQUEST_PASSKEY:
                        blc_smp_setTK_by_PasskeyEntry(MASTER_SMP_PASSKEY);
                        reg_gpio_pa_setting1 ^= BIT(28);
                        //reg_gpio_pa_setting1 ^= BIT(25);
                        break;

                case GAP_EVT_SMP_PAIRING_FAIL:
                        central_smp_pending = 0;
                        break;

                case GAP_EVT_SMP_PAIRING_SUCCESS:
                        //reg_gpio_pa_setting1 ^= BIT(28);
                        central_smp_pending = 0;
                        break;
                }
                return 0;
        }

}


GAP_EVT_SMP_PAIRING_BEGIN did'n start

48

主题

321

回帖

1205

积分

版主

积分
1205
发表于 7 天前 | 显示全部楼层 来自 上海
https://doc.telink-semi.cn/doc/e ... urity%29#master-smp

The highest level of the master SMP function currently supported is LE security mode1 level2.

点评

Is there ANY SDK version or library for TLSR8258 where master (central) SMP supports MITM / Level 3-4 (passkey entry)? Or a patch/roadmap?  发表于 7 天前
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Telink forum ( 沪ICP备17008231号-1 |沪公网安备31011502403548号 )

GMT+8, 2026-6-11 14:37 , Processed in 0.091674 second(s), 24 queries .

Powered by Discuz! 隐私政策

泰凌微电子版权所有 © 。保留所有权利。 2024

快速回复 返回顶部 返回列表