This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2340R5: 关于CC2340R5的主从一体模式

Part Number: CC2340R5

当我在syscfg中配置 Device Role为 Peripheral + Central 时,把程序烧入模块,只发现广播信号。请问在程序运行时该如何切换当前Role为Peripheral 或者 Central。有没有相关的使用说明?

  • 你好,

    可以看下这个帖子

    https://e2e.ti.com/support/wireless-connectivity/bluetooth-group/bluetooth/f/bluetooth-forum/1226192/cc2340r5-ble-multirole-or-dual-role-capability

    根据您选择的角色,应用程序文件夹中的文件将处于活动状态(例如 app_peripheral.c,...等),其中您将要在其中实现应用程序。

    也建议看下其中的培训

     

  • 当我把 Device Role配置为 Peripheral + Central 时 ,应用程序文件夹的 app.peripheral.c 和 app.central.c 文件都没有正确启用。

    如图。

    看了上面的文档,并没有发现有关设置为 Peripheral + Central 时,Role切换的方式及过程。

  • 没有找到切换当前role的相关资料,只有multi—role比较符合这种情况,我再整理一下思路你看看

  • 这是mutil-role的示例,可以看一下

    https://dev.ti.com/tirex/explore/node?node=A__AHHxRYQ9FYshn5kAnr60wA__com.ti.SIMPLELINK_CC13XX_CC26XX_SDK_BLE5STACK_MODULE__BSEc4rl__LATEST

    这是一个思路

    • The only profile which requires modification is peripheral.c., to remove a check for gapRole_state in GAPRole_StartDevice. This is included in the patch here.



    • In OSAL_SimpleBLESwitch.c the tasksArr must be update to include the central task (GAPCentralRole_ProcessEvent)

    <syntaxhighlight lang='c'> const pTaskEventHandlerFn tasksArr[] = {

     LL_ProcessEvent,                                                  // task 0
     Hal_ProcessEvent,                                                 // task 1
     HCI_ProcessEvent,                                                 // task 2
    
    1. if defined ( OSAL_CBTIMER_NUM_TASKS )
     OSAL_CBTIMER_PROCESS_EVENT( osal_CbTimerProcessEvent ),           // task 3
    
    1. endif
     L2CAP_ProcessEvent,                                               // task 4
     GAP_ProcessEvent,                                                 // task 5
     SM_ProcessEvent,                                                  // task 6
     GATT_ProcessEvent,                                                // task 7
     GAPRole_ProcessEvent,                                             // task 8
     GAPCentralRole_ProcessEvent,                                      // task 9 
     GAPBondMgr_ProcessEvent,                                          // task 10
     GATTServApp_ProcessEvent,                                         // task 11
     SimpleBLESwitch_ProcessEvent                                  // task 12
    

    }; </syntaxhighlight>

    • In OSAL_SimpleBLESwitch.c the central task is initialized/registered with OSAL

    <syntaxhighlight lang='c'>

     /* Profiles */
     GAPRole_Init( taskID++ );
     GAPCentralRole_Init( taskID++ );      //Add Central task here
     GAPBondMgr_Init( taskID++ );
    

    </syntaxhighlight>

    • In simpleBLESwitch.c within the simpleBLESwitch_Handlekeys() function the following line is changed:

    <syntaxhighlight lang='c'>

     //cancel current link request 
     GAPCentralRole_TerminateLink( 0xFFFF );
    

    </syntaxhighlight>

    • In simpleBLESwitch.c in the simpleBLESwitch_Handlekeys() function the following call to the osal timer is changed to use the proper taskID:

    <syntaxhighlight lang='c'>

     osal_start_timerEx( simpleBLESwitch_TaskID, SBP_START_DEVICE_EVT, 500 );
    

    </syntaxhighlight>

    这个是很早版本的一个示例,函数库已经更新,可能不再能通用,你可以看下思路