TI中文支持网
TI专业的中文技术问题搜集分享网站

CC2540 获取连接过程中的状态

请问各位TI工程师和网友们:

在CC2540作为从机和手机连接时,能否可以获取连接过程中的状态,比如扫描应答,连接请求应答。有没有这样的函数接口呢?谢谢!

Viki Shi:

没有这样的状态查询API,需要自己实现。如下是CC2640R2F上的方法,供参考:

在simple_peripheral.h中有

/// @brief GAP Peripheral Role States.
typedef enum
{
GAPROLE_INIT = 0, //!< Waiting to be started
GAPROLE_STARTED, //!< Started but not advertising
GAPROLE_ADVERTISING, //!< Currently Advertising
GAPROLE_ADVERTISING_NONCONN, //!< Currently using non-connectable Advertising
GAPROLE_WAITING, //!< Device is started but not advertising, is in waiting period before advertising again
GAPROLE_WAITING_AFTER_TIMEOUT, //!< Device just timed out from a connection but is not yet advertising, is in waiting period before advertising again
GAPROLE_CONNECTED, //!< In a connection
GAPROLE_CONNECTED_ADV, //!< In a connection + advertising
GAPROLE_ERROR //!< Error occurred – invalid state
} gaprole_States_t;

可以在simple_peripheral.c中的回调函数 SimpleBLEPeripheral_processStateChangeEvt 中进行修改

user4775285:

回复 Viki Shi:

感谢回复!
但是这几个状态中应该也没有被从设备被扫描到,或者应答连接请求的状态吧?

Viki Shi:

回复 user4775285:

收到扫描应答会在simpleBLECentralEventCB()的GAP_DEVICE_INFO_EVENT里进行处理

user4775285:

回复 Viki Shi:

感谢!
我这边用的是从机设备连接手机蓝牙,想在simpleBLEperipheral例程中有没有这样的事件处理函数呢?

user4775285:

回复 Viki Shi:

我看了下代码,simpleBLEperipheral例程中peripheralStateNotificationCB()这个函数有类似的状态处理,但是调试了下并没有收到扫描命令的状态

YiKai Chen:

用SimpleBLEPeripheral例程為例,你可以在peripheralStateNotificationCB里去获取连接过程中的状态

Viki Shi:

回复 user4775285:

主机才作扫描啊

赞(0)
未经允许不得转载:TI中文支持网 » CC2540 获取连接过程中的状态
分享到: 更多 (0)