nrf51822 --- 从机主动断开蓝牙连接
2016-03-10 17:29
387 查看
1.目的
从机主动断开蓝牙连接
2.分析
实际应用当中,时常需要需从机主动断开蓝牙,防止不明主机连接的情况
3.平台:
协议栈版本:SDK10.0.0
编译软件:keil 5.14
硬件平台:nrf51822最小系统
例子:SDK 10.0.0\examples\ble_peripheral\ble_app_uart\pca10028\s110\arm4
4.步骤
首先,要知道主动断开连接的API :
/**@brief Disconnect (GAP Link Termination).
*
* @details This call initiates the disconnection procedure, and its completion will be communicated to the application
* with a @ref BLE_GAP_EVT_DISCONNECTED event.
*
* @param[in] conn_handle Connection handle.
* @param[in] hci_status_code HCI status code, see @ref BLE_HCI_STATUS_CODES (accepted values are @ref BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION and @ref BLE_HCI_CONN_INTERVAL_UNACCEPTABLE).
*
* @retval ::NRF_SUCCESS The disconnection procedure has been started successfully.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
* @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation (disconnection is already in progress).
*/
SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code));
{
err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);
APP_ERROR_CHECK(err_code);
}
从机调用这个就可以断开蓝牙。
从机主动断开蓝牙连接
2.分析
实际应用当中,时常需要需从机主动断开蓝牙,防止不明主机连接的情况
3.平台:
协议栈版本:SDK10.0.0
编译软件:keil 5.14
硬件平台:nrf51822最小系统
例子:SDK 10.0.0\examples\ble_peripheral\ble_app_uart\pca10028\s110\arm4
4.步骤
首先,要知道主动断开连接的API :
/**@brief Disconnect (GAP Link Termination).
*
* @details This call initiates the disconnection procedure, and its completion will be communicated to the application
* with a @ref BLE_GAP_EVT_DISCONNECTED event.
*
* @param[in] conn_handle Connection handle.
* @param[in] hci_status_code HCI status code, see @ref BLE_HCI_STATUS_CODES (accepted values are @ref BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION and @ref BLE_HCI_CONN_INTERVAL_UNACCEPTABLE).
*
* @retval ::NRF_SUCCESS The disconnection procedure has been started successfully.
* @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
* @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
* @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation (disconnection is already in progress).
*/
SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code));
{
err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_CONN_INTERVAL_UNACCEPTABLE);
APP_ERROR_CHECK(err_code);
}
从机调用这个就可以断开蓝牙。
相关文章推荐
- Zookeeper可以干什么?
- CAF(C++ actor framework)(序列化之复杂类,分析 还有自己不懂的细思恐极函数实现)(三)
- -bash: ssh: command not found 报错的解决方法
- iOS 手机定位 获取当前城市
- 【J2EE】:Java EE应用的组件
- Myeclipse离线安装svn插件
- linux内核,驱动,应用程三者的概念和之间的关系
- Scala Playframework 访问HTTPS网站证书错误解决方案
- TODO list
- pat1031:查验身份证
- 蓝桥杯--历届试题 翻硬币(贪心)
- 剑指offer 斐波那契数列
- jQuery Ajax
- Android hdpi,xhdpi,xxhdpi一些你没注意到的事
- 基于TCP协议的通信模型
- Zookeeper的集群配置和Java测试程序
- AlphaGo:用机器学习技术古老的围棋游戏掌握AlphaGo: Mastering the ancient game of Go with Machine Learning
- JS键盘码值表
- JAVA高级程序设计学习计划
- springbooot之freemarker