4

CH57x/CH58x/CH59x主从机主动发起断连 - 小舟从此逝_1

 7 months ago
source link: https://www.cnblogs.com/frontier/p/18004843
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

CH57x/CH58x/CH59x主从机主动发起断连

如果在做应用的时需要同时使用使用两块板子分别做主从机或者使用一块板子做单独的从机;

这是我们需要按下某个按键或者发送某条指令主机或者从机主动断开与对方的连接且设备不需要复位;

主机端我们可以调用这样一个函数:

GAPRole_TerminateLink(centralConnHandle)在程序中  centralConnHandle = pEvent->linkCmpl.connectionHandle;

注意:不要传入这个handle centralCharHdl  这个是服务的句柄;我们需要传入的是连接句柄centralConnHandle

从机端我们可以调用同样的函数:

 GAPRole_TerminateLink(peripheralConnList.connHandle);

接下来举个简单的使用例子:

在从机中使用,当通道一的write服务发数据过来后从机主动断开连接

3020110-20240203155211990-1485267021.png
3020110-20240203155254560-442904138.png

 我们可以看到断连的原因是0x16即本地断开(从机主动断连)。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK