请教专家:
目前我们的程序是在Multi_Role例程(采用1.40.00.45版本SDK)的基础上修改得到的。现在我们需要Long Range的支持,所以希望改用1.50.00.71版本的SDK。尝试在项目配置里做一些修改都没有成功,也没有找到相关的资料介绍这方面(有一些其他情景的迁移介绍,但似乎帮助不大)。请问哪里有升级SDK版本相关的介绍呢?
另外,1.50.00.71版本的SDK里带的例程好像没有Multi_Role,隐隐有些担心Long Range和Multi_Role暂时无法共存,烦请TI的专家确认,谢谢!
Viki Shi:
请参考这边的移植指南file:///C:/ti/simplelink_cc2640r2_sdk_1_50_00_58/docs/blestack/ble_user_guide/html/ble-stack-3.x-guide/migration.html
Eggsy Pang:
可以共存,下载新的SDK
Susan Yang:
是可以共存的。使用BLE5协议栈的话,您还是可以访问BLE 4.x功能,而且其与4.x设备具有互操作性。
goodluck:
回复 Viki Shi:
非常感谢回答。
我发现这个文档比较有帮助:file:///C:/ti/simplelink_cc2640r2_sdk_1_50_00_71/docs/ble5stack/ble_user_guide/html/ble-stack-5.x-guide/ble5stack1.00.01-to-ble5stack1.01.00.html
按照文档中的描述做了相应的修改,另外排除了一些问题之后,工程编译通过了,也可以用手机扫描到程序的广播包,看起来peripheral功能是正常的。可是central功能却不正常。烦请帮忙看一下原因是什么。目前的现象是一旦启动scan,程序就崩掉。怀疑是central功能没有被正确配置,于是检查我们程序的主task的初始化函数,还有GAP_DEVICE_INIT_DONE_EVENT事件的处理代码,并且与simple_central例程的相应部分作对比。可是我们的配置项只多不少,而且多的部分是从旧版SDK代码移植过来得到的,似乎也没什么问题。
还怀疑过原来的GapRole task里面做过些什么,可是检查该task的初始化函数和GAP_DEVICE_INIT_DONE_EVENT事件的处理代码之后,发现主要都是在处理advertiser部分的功能,对central应该没太大影响。但另外还有一些IRK,SRK相关的代码,会不会影响central功能就不清楚了,请求确认。
另外,scan操作是按照file:///C:/ti/simplelink_cc2640r2_sdk_1_50_00_71/docs/ble5stack/ble_user_guide/html/ble-stack-5.x/gap.html#gap里面的描述来改的。主要流程:接收UART命令 -> 处理命令,向主task发送start scan事件 -> 主task处理事件,调用GapScan_enable()开始扫描。
最后,请问multi role的实现是否有什么需要特别注意的地方?为了解决上面的问题,我们可以从哪些方面着手排查?谢谢!
goodluck:
回复 Eggsy Pang:
非常感谢回答。
目前我们移植后的central功能有问题,请问可否参照我上面的回复帮忙看一下?谢谢!
goodluck:
回复 Susan Yang:
非常感谢回答。
目前我们移植后的central功能有问题,请问可否参照我上面的回复帮忙看一下?谢谢!
goodluck:
回复 goodluck:
保险起见,附上主task初始化代码和GAP_DEVICE_INIT_DONE_EVENT事件的处理代码。
//******************************************************************************************************************************
主task初始化:
{ICall_registerApp(&selfEntity, &syncEvent);appMsgQueue = Util_constructQueue(&appMsg);// Setup the GAP{// Set advertising interval the same for all scenariosuint16_t advInt = DEFAULT_ADVERTISING_INTERVAL;GAP_SetParamValue(GAP_ADV_PARAM_PRIMARY_INTERVAL_MIN, advInt);GAP_SetParamValue(GAP_ADV_PARAM_PRIMARY_INTERVAL_MAX, advInt);// Scan interval and window the same for all scenariosGapScan_setPhyParams(SCAN_PRIM_PHY_1M, SCAN_TYPE_PASSIVE,DEFAULT_SCAN_INT, DEFAULT_SCAN_WIND);// Set connection parametersGapInit_setPhyParam(INIT_PHY_1M,INIT_PHYPARAM_SCAN_INTERVAL, DEFAULT_SCAN_INT);GapInit_setPhyParam(INIT_PHY_1M,INIT_PHYPARAM_SCAN_WINDOW, DEFAULT_SCAN_WIND);GapInit_setPhyParam(INIT_PHY_1M,INIT_PHYPARAM_CONN_INT_MIN, DEFAULT_CONN_INT);GapInit_setPhyParam(INIT_PHY_1M,INIT_PHYPARAM_CONN_INT_MAX, DEFAULT_CONN_INT);GapInit_setPhyParam(INIT_PHY_1M,INIT_PHYPARAM_SUP_TIMEOUT, DEFAULT_CONN_TIMEOUT);GapInit_setPhyParam(INIT_PHY_1M,INIT_PHYPARAM_CONN_LATENCY, DEFAULT_CONN_LATENCY);// Accept all parameter update requestsGAP_SetParamValue(GAP_PARAM_LINK_UPDATE_DECISION, GAP_UPDATE_REQ_ACCEPT_ALL);// Register to receive GAP and HCI messagesGAP_RegisterForMsgs(selfEntity);}{// Allocate memory for index to connection handle mapif (connHandleMap = ICall_malloc(sizeof(connHandleMapEntry_t) * maxNumBleConns)){// Init index to connection handle mapfor (uint8_t i = 0; i < maxNumBleConns; i++){connHandleMap[i].connHandle = CONNHANDLE_INVALID;}}// Allocate memory for per connection discovery informationif (discInfo = ICall_malloc(sizeof(discInfo_t) * maxNumBleConns)){// Init index to connection handle map to 0'sfor (uint8_t i = 0; i < maxNumBleConns; i++){memset(&discInfo[i], 0, sizeof(discInfo[i]));}}}// GATT{// Set the GAP CharacteristicsGGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName);// Initialize GATT Server ServicesGGS_AddService(GATT_ALL_SERVICES);// GAP //GATTServApp_AddService(GATT_ALL_SERVICES);// GATT attributes //DevInfo_AddService();// Device Information ServiceCustomProfile_AddService();#if defined (BLE_V42_FEATURES) && (BLE_V42_FEATURES & PRIVACY_1_2_CFG)// Initialize GATT ClientGATT_InitClient();GGS_SetParamValue(GGS_DISABLE_RPAO_CHARACTERISTIC); #endif // BLE_V42_FEATURES & PRIVACY_1_2_CFG// Setup Profile Characteristic Values{uint8_t charValue[CUSTOMSERVICE_CHAR_LEN] = { 0 };CustomProfile_SetParameter(CUSTOMSERVICE_CTRL_CHAR, CUSTOMSERVICE_CHAR_LEN,charValue);}// Register callback with Custom ProfileCustomProfile_RegisterAppCBs(&customProfileCBs);/*-----------------CLIENT------------------*/// Initialize GATT ClientVOID GATT_InitClient();// Register for GATT local events and ATT Responses pending for transmissionGATT_RegisterForMsgs(selfEntity);// Register to receive incoming ATT Indications/NotificationsGATT_RegisterForInd(selfEntity);}// Setup the GAP Bond Manager{uint8_t pairMode = GAPBOND_PAIRING_MODE_INITIATE;uint8_t mitm = FALSE;uint8_t ioCap = GAPBOND_IO_CAP_NO_INPUT_NO_OUTPUT;uint8_t bonding = TRUE;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);// Register and start Bond ManagerVOID GAPBondMgr_Register(&bondMgrCBs);}//Initialize GAP layerGAP_DeviceInit(GAP_PROFILE_PERIPHERAL | GAP_PROFILE_CENTRAL, selfEntity);#if !defined (USE_LL_CONN_PARAM_UPDATE)HCI_LE_ReadLocalSupportedFeaturesCmd(); #endif // !defined (USE_LL_CONN_PARAM_UPDATE) }//******************************************************************************************************************************
GAP_DEVICE_INIT_DONE_EVENT事件的处理:
case GAP_DEVICE_INIT_DONE_EVENT:{ //bStatus_t status = FAILURE;// Store max pdu sizestoreMaxPduSize = pEvent->initDone.dataPktLen;// Set device info characteristicDevInfo_SetParameter(DEVINFO_SYSTEM_ID, DEVINFO_SYSTEM_ID_LEN, pEvent->initDone.devAddr);uint8_t temp8;uint16_t temp16;// Register callback to process Scanner eventsGapScan_registerCb(app_scanCb, NULL);// Set Scanner Event MaskGapScan_setEventMask(GAP_EVT_SCAN_DUR_ENDED | GAP_EVT_SCAN_DISABLED |GAP_EVT_ADV_REPORT);// Set Scan PHY parametersGapScan_setPhyParams(DEFAULT_SCAN_PHY, SCAN_TYPE_PASSIVE,SCAN_PARAM_DFLT_INTERVAL, SCAN_PARAM_DFLT_INTERVAL);// Set Advertising report fields to keeptemp16 = ADV_RPT_FIELDS;GapScan_setParam(SCAN_PARAM_RPT_FIELDS, &temp16);// Set Scanning Primary PHYtemp8 = DEFAULT_SCAN_PHY;GapScan_setParam(SCAN_PARAM_PRIM_PHYS, &temp8);// Do not filter duplicate advertising reportstemp8 = SCAN_FLT_DUP_DISABLE;GapScan_setParam(SCAN_PARAM_FLT_DUP, &temp8);temp16 = SCAN_FLT_PDU_COMPLETE_ONLY;GapScan_setParam(SCAN_PARAM_FLT_PDU_TYPE, &temp16);// Temporary memory for advertising parameters for set #1. These will be copied// by the GapAdv moduleGapAdv_params_t advParamLegacy = GAPADV_PARAMS_LEGACY_SCANN_CONN;// Create Advertisement set #1 and assign handleGapAdv_create(&app_advCallback, &advParamLegacy,&advHandleLegacy); //SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Load advertising data for set #1 that is statically allocated by the appGapAdv_loadByHandle(advHandleLegacy, GAP_ADV_DATA_TYPE_ADV,sizeof(advertData), advertData); //SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Load scan response data for set #1 that is statically allocated by the appGapAdv_loadByHandle(advHandleLegacy, GAP_ADV_DATA_TYPE_SCAN_RSP,sizeof(scanRspData), scanRspData); //SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Set event mask for set #1GapAdv_setEventMask(advHandleLegacy,GAP_ADV_EVT_MASK_START_AFTER_ENABLE |GAP_ADV_EVT_MASK_END_AFTER_DISABLE |GAP_ADV_EVT_MASK_SET_TERMINATED);// Enable legacy advertising for set #1GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); //SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Use long range params to create long range set #2GapAdv_params_t advParamLongRange = GAPADV_PARAMS_AE_LONG_RANGE_CONN;// Create Advertisement set #2 and assign handleGapAdv_create(&tpms_core_advCallback, &advParamLongRange,&advHandleLongRange); //SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Load advertising data for set #2 that is statically allocated by the appGapAdv_loadByHandle(advHandleLongRange, GAP_ADV_DATA_TYPE_ADV,sizeof(advertData), advertData); //SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Load scan response data for set #2 that is statically allocated by the appGapAdv_loadByHandle(advHandleLongRange, GAP_ADV_DATA_TYPE_SCAN_RSP,sizeof(scanRspData), scanRspData); //SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);// Set event mask for set #2GapAdv_setEventMask(advHandleLongRange,GAP_ADV_EVT_MASK_START_AFTER_ENABLE |GAP_ADV_EVT_MASK_END_AFTER_DISABLE |GAP_ADV_EVT_MASK_SET_TERMINATED);// Enable long range advertising for set #2GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); //SIMPLEPERIPHERAL_ASSERT(status == SUCCESS);}break;