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.

CC2640R2F主从机代码合并问题

Other Parts Discussed in Thread: CC2640R2F

Dear All,

针对CC2640R2F主从机代码合并,现通过修改stack_library->TOOLS->build_config.opt文件下配置为-DHOST_CONFIG=PERIPHERAL_CFG+CENTRAL_CFG后,从机已可以进行正常广播,可以正常被连接。

但是发现从机注册的服务无法正常使用,即无法通过注册的服务进行数据收发操作,请问需要修改什么地方么?感觉服务没有注册上,但是注册服务的API返回都是success,  主机进行数据收发还是正常的。

    以下为从机初始化属性所用函数

    

   这个初始化在单独使用从机配置-DHOST_CONFIG=PERIPHERAL_CFG的时候是正常的(跟原始demo的初始化相同)。

  • 主从机代码合并?您具体想实现什么功能呢?
  • Dear Susan,
    做模块,提供给终端客户使用。请帮忙给下建议,十分感谢!
  • 不是有主从一体的例子吗? 直接用就好了.

    C:\ti\simplelink_cc2640r2_sdk_1_40_00_45\examples\rtos\CC2640R2_LAUNCHXL\blestack\multi_role

    Multi Role

    Introduction

    This project demonstrates the capabilities of the Texas Instruments BLE stack to function in multiple simultaneous connection roles. Specifically, the project is capable of functioning as a master and a slave simultaneously, in any combination, while maintaining up to 8 connections. The project is capable of connecting to any central/peripheral device. Any type of legacy pairing/bonding is possible. Parameter updates are supported. Connections can be established in any role. The project supports multiple simultaneous GATT discoveries and/or pairings/bondings.

    Hardware Prerequisites

    The default Multi Role configuration uses the LAUNCHXL-CC2640R2. This hardware configuration is shown in the below image:

    For custom hardware, see the Running the SDK on Custom Boards section of the BLE-Stack User’s Guide for Bluetooth 4.2.

    Software Prerequisites

    For information on what versions of Code Composer Studio and IAR Embedded Workbench to use, see the Release Notes located in the docs/blestack folder. For information on how to import this project into your IDE workspace and build/run, please refer to The CC2640R2F Platform section in the BLE-Stack User’s Guide for Bluetooth 4.2.

    Assumptions/Considerations

    In this document, the terms master/central and slave/peripheral are used synonymously. It is assumed that the master/central devices are GATT clients and slave/peripheral devices are GATT servers. Once the connection limit (set with the MAX_NUM_BLE_CONNS preprocessor define) is reached, the multi_role device won’t be allowed to advertise/scan until there is a disconnection.

    When connected in the master role, the multi_role device will query the slave device for the simpleGATTProfile service in order to demo some basic GATT procedures (read/write characteristic). However, it is not necessary for the slave device to contain this service in order for a connection to be established. That is, it is possible for the peripheral devices in the system to have differing attribute tables since the multi_role device will perform a service/characteristic discovery after each connection is formed.

    Due to the large amount of functionality in this project, it is rather RAM-constrained. If the project is configured for too many connections (via the MAX_NUM_BLE_CONNS preprocessor define) and also security, it is possible for heap allocation failures to occur which will break the stack. Therefore, the project should be stress-tested for its intended use case to verify that there are no heap issues by including the HEAPMGR_METRICS preprocessor define. See the Debugging section of the BLE-Stack User’s Guide for Bluetooth 4.2 for more information on how to do this.

    In order to provide more RAM to allow for more connections/security, there is an additional project configuration for both the IAR and CCS projects to use the cache as RAM. See the Using the Cache as RAM section of the BLE-Stack User’s Guide for Bluetooth 4.2. Of course, using the cache as RAM comes at the tradeoff of potential increased processing time and thus higher power consumption.

    When at least one connection is already formed, in order to allow enough processing time to scan for a new connection, the minimum possible connection interval (in milliseconds) that can be used is:

    12.5 + 5*n

    where n is the amount of current connections. For example, if there are currently four connections, all four connections must use a minimum connection interval of 12*5 + 5*4 = 32.5 ms in order to allow scanning to occur to establish a new connection.

    Usage

    The multi_role project uses the two buttons on the CC2640R2 LaunchPad to accept user input and outputs information through the UART. This document will use PuTTY to serve as the display for the output of the CC2640R2 LaunchPad. Note that any other serial terminal can be used. The following default parameters are used for the UART peripheral for display:

    UART ParamDefault Values
    Baud Rate 115200
    Data length 8 bits
    Parity None
    Stop bits 1 bit
    Flow Control None

    Upon powering on or resetting the device, the user will see the main menu. When in the main menu, the left button will scroll through the possible actions, which are:

    • Scan
    • Advertise

    Other options will become available once devices are scanned, and again once a connection is formed.

    The device will report upon startup that it is initialized, advertising, and connected to 0 devices:

    The right button is used to select one of the available options. Each option will be covered in the following sections.

    Selecting this option will toggle advertising on and off. When advertising is off, it will display “Ready to Advertise”. This device will send out connectable advertisements.

    Scan

    Selecting this option will start a device discovery to search for advertising devices. It will then display the number of devices found:

    Connect

    The option to connect to a device will now become available (note that options other than scan and advertise will be preceded with a “+”). Selecting this option will bring you to the “Connect” menu, where you can scroll through the discovered devices:

    A device can then be selected to initiate a connection. The connect option can be chosen again to connect with additional peripheral devices. The terminal window will display the number of devices that are connected to the Multi Role device:

    At this point, all menu options are present. The following options can be chosen:

    • Scan
    • Advertise
    • Connect
    • GATT Read/Write
    • Connection Update
    • Disconnect

    GATT Read/Write

    Pressing the right button from the main menu while “GATT Read/Write” is shown will enter the “GATT Read/Write” menu. Here, the left button is used to browse through connected devices. When a device is selected with the right button, a GATT read/write of simple profile characteristic 1 will be sent to the connected device. Each time a device is chosen, the action toggles between read and write with the write value incrementing by 1. It is also possible to browse to and select “Upper Menu” to return to the main menu.

    Connection Update

    Pressing the right button from the main menu while “Connection Update” is shown will enter the “Connection Update” menu. Here, the left button is used to browse through connected devices. When a device is selected with the right button, a connection parameter update is sent to the connected device with the following parameters:

    • 100 ms minimum connection interval
    • 187.5 ms maximum connection interval
    • 0 slave latency
    • 2 seconds supervision timeout

    It is also possible to browse to and select “Upper Menu” to return to the main menu.

    Disconnect

    Pressing the right button from the main menu while “Disconnect” is shown will enter the “Disconnect” menu. Here, the left button is used to browse through connected devices. When a device is selected with the right button, a link termination request will be sent to the connected device:

    It is also possible to browse to and select “Upper Menu” to return to the main menu.

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and embedded processors, along with software, tools and the industry‘s largest sales/support staff.

    © Copyright 1995-2017 Texas Instruments Incorporated. All rights reserved.