Part Number:LAUNCHXL-CC26X2R1
Hi,
我现在有两块LAUNCHXL-CC26X2R1评估板A和B,修改了rtls_slave example代码,让A实现仅仅发送unconnectable unscanable undirect的 ble 5.0 extend periodic adv packet。
修改了simple_central example代码,参考 "ble5 stack user guide"实现了scan Synchronize with a periodic advertising train。但是问题是没有GAP_SCAN_PERIODIC_ADV_SYNC_EST_EVENT上报,
即无法建立Periodic Advertising同步。
我简单介绍下我的环境:
step1:在ccs10的工程选项中添加了ARM Linker pre-define macro “”“USE_PERIODIC_SCAN”;
step2:初始化GAP_PROFILE_CENTRAL角色
static void SimpleCentral_init(void) {BLE_LOG_INT_TIME(0, BLE_LOG_MODULE_APP, "APP : ---- init ", SC_TASK_PRIORITY);// ******************************************************************// N0 STACK API CALLS CAN OCCUR BEFORE THIS CALL TO ICall_registerApp// ******************************************************************// Register the current thread as an ICall dispatcher application// so that the application can send and receive messages.ICall_registerApp(&selfEntity, &syncEvent);// Create an RTOS queue for message from profile to be sent to app.appMsgQueue = Util_constructQueue(&appMsg);GGS_AddService(GATT_ALL_SERVICES);// GAP// Register with GAP for HCI/Host messages (for RSSI)GAP_RegisterForMsgs(selfEntity);BLE_LOG_INT_TIME(0, BLE_LOG_MODULE_APP, "APP : ---- call GAP_DeviceInit", GAP_PROFILE_CENTRAL);// Initialize GAP layer for Central role and register to receive GAP eventsGAP_DeviceInit(GAP_PROFILE_CENTRAL, selfEntity, addrMode, &pRandomAddress);dispHandle = Display_open(Display_Type_UART, NULL);Display_printf(dispHandle, SC_ROW_SEPARATOR_1, 0, "===================="); }
step3:先设置scan参数,此时不发送scan_enable。然后发送
GapScan_PeriodicAdvCreateSync,其中sid以及广播设备地址已知直接指定
static void SimpleCentral_processGapMsg(gapEventHdr_t *pMsg) {switch (pMsg->opcode){case GAP_DEVICE_INIT_DONE_EVENT:{uint8_t temp8;uint16_t temp16;gapDeviceInitDoneEvent_t *pPkt = (gapDeviceInitDoneEvent_t *)pMsg;BLE_LOG_INT_TIME(0, BLE_LOG_MODULE_APP, "APP : ---- got GAP_DEVICE_INIT_DONE_EVENT", 0);// Setup scanning// For more information, see the GAP section in the User's Guide:// https://www.ti2k.com/wp-content/uploads/2022/03/DeyiSupport_Bluetooth_ Register callback to process Scanner eventsGapScan_registerCb(SimpleCentral_scanCb, NULL);// Set all Scanner Event MaskGapScan_setEventMask(GAP_EVT_SCAN_EVT_MASK);// Set Scan PHY parametersGapScan_setPhyParams(SCANNED_PHY_1M, SCAN_TYPE_PASSIVE,SCAN_PARAM_DFLT_INTERVAL , SCAN_PARAM_DFLT_WINDOW );// Set all Advertising report fields to keeptemp16 = SCAN_PARAM_ALL_RPT_FIELDS;GapScan_setParam(SCAN_PARAM_RPT_FIELDS, &temp16);// Set Scanning Primary PHYtemp8 = SCANNED_PHY_1M;GapScan_setParam(SCAN_PARAM_PRIM_PHYS, &temp8);// Set LL Duplicate Filtertemp8 = SCAN_FLT_DUP_ENABLE;GapScan_setParam(SCAN_PARAM_FLT_DUP, &temp8);// Set PDU type filter -// Only 'Connectable' and 'Complete' packets are desired.// It doesn't matter if received packets are// whether Scannable or Non-Scannable, whether Directed or Undirected,// whether Scan_Rsp's or Advertisements, and whether Legacy or Extended.//temp16 = SCAN_FLT_PDU_CONNECTABLE_ONLY | SCAN_FLT_PDU_COMPLETE_ONLY;//temp16 = SCAN_FLT_PDU_EXTENDED_ONLY;temp16 = SCAN_FLT_PDU_NONCONNECTABLE_ONLY;BLE_LOG_INT_TIME(0, BLE_LOG_MODULE_APP, "APP : ---- GapScan_setParam", 0);GapScan_setParam(SCAN_PARAM_FLT_PDU_TYPE, &temp16); #ifdef USE_PERIODIC_SCAN// this is a periodic advertisementGapScan_PeriodicAdvCreateSyncParams_t pSyncParams;//uint8 t_addr[6]={0xCB,0x98,0x2D,0x5E,0x8A,0xF8};pSyncParams.options = SCAN_PERIODIC_DO_NOT_USE_PERIODIC_ADV_LIST |SCAN_PERIODIC_REPORTING_INITIALLY_DISABLED;pSyncParams.advAddrType = ADDRTYPE_PUBLIC; // only ADDRTYPE_PUBLIC and ADDRTYPE_RANDOM are allowed//osal_memcpy(pSyncParams.advAddress, t_addr, B_ADDR_LEN);pSyncParams.advAddress[5] = 0xF8;pSyncParams.advAddress[4] = 0x8A;pSyncParams.advAddress[3] = 0x5E;pSyncParams.advAddress[2] = 0x2D;pSyncParams.advAddress[1] = 0x98;pSyncParams.advAddress[0] = 0xCB;pSyncParams.skip = 0; // should be between 0 and SCAN_PERIODIC_SKIP_MAXpSyncParams.syncTimeout = 1000; // synchronization timeout for the periodic advertising train is 1000*10ms = 10s// should be between SCAN_PERIODIC_TIMEOUT_MIN and SCAN_PERIODIC_TIMEOUT_MAXpSyncParams.syncCteType = SCAN_PERIODIC_CTE_TYPE_ALL;uint8_t status = GapScan_PeriodicAdvCreateSync(0x01, &pSyncParams);Display_printf(dispHandle, SC_ROW_SCAN_3, 0, "PeriodicAdvCreateSync status! 0x%x",status); #endifbreak;}case GAP_SCAN_CREATE_SYNC_EVENT:{GapScan_PeriodicAdvEvt_t *pPkt = (GapScan_PeriodicAdvEvt_t *)pMsg;uint8_t status;Display_printf(dispHandle, SC_ROW_SCAN_EVT_5, 0, "GAP_SCAN_CREATE_SYNC_EVENT Status 0x%x",pPkt->status);if(pPkt->status == SUCCESS){status = GapScan_enable(0, 0, 0);//if(SUCCESS != status){Display_printf(dispHandle, SC_ROW_SCAN_EVT_2, 0, "GapScan_enable again status 0x%x",status);}}}break;case GAP_SCAN_PERIODIC_ADV_SYNC_EST_EVENT:{Display_printf(dispHandle, SC_ROW_SCAN_EVT_3, 0, "GAP_SCAN_PERIODIC_ADV_SYNC_EST_EVENT");}break;case GAP_SCAN_PERIODIC_ADV_SYNC_LOST_EVENT:{Display_printf(dispHandle, SC_ROW_SCAN_EVT_7, 0, "GAP_SCAN_PERIODIC_ADV_SYNC_LOST_EVENT");}break;default:break;} }
step4:生成GAP_SCAN_CREATE_SYNC_EVENT后,开启scan_enable
等待GAP_SCAN_PERIODIC_ADV_SYNC_EST_EVENT。
现在就是GAP_SCAN_PERIODIC_ADV_SYNC_EST_EVENT一直没有出现,我检查了代码、读了文档手册不知道问题出现在哪?请给予帮助,万分感谢
Kevin Qiu1:
启用Periodic Advertising同步, 你应该按照ble5 stack user guide中的Generic Access Profile (GAP)章节的说明修改simple_peripheral例程
rtls_slave也是启用了Periodic Advertising,配合使用rtls_master例程
按照Task1中的option4设置应该也能看到https://www.ti2k.com/wp-content/uploads/2022/03/DeyiSupport_Bluetooth_node
,
user5860584:
你好,我已经按照ble5 stack user guide中的Generic Access Profile (GAP)章节的说明修改simple_peripheral例程,但是不起作用,我还是收不到GAP_SCAN_PERIODIC_ADV_SYNC_EST_EVENT。整个过程对我来看像个黑盒子,您可以提供详细的command操作流吗?我对照重新尝试下
,
Kevin Qiu1:
操作流程就是GAP章节的步骤,直接使用rtls_master例程步骤会简单一些