|
发表于 2016-3-15 11:48:23
只看该作者
沙发
主机发起对从设备的链接请求的api可以在app_gap.c中找到:- /*
- ****************************************************************************************
- * @brief Create connection with the remote BLE device. *//**
- *
- * @param[in] addr The address of the remote device to which the connection will be created
- * @param[in] addr_type The address type of the remote device, possible values are:
- * - ADDR_PUBLIC
- * - ADDR_RAND
- * @param[in] own_addr_type Own address type, possible values are:
- * - ADDR_PUBLIC
- * - ADDR_RAND
- * @param[in] conn_intv_min Minimum of connection interval
- * @param[in] conn_intv_max Maximum of connection interval
- * @param[in] cnnn_timeout Link supervision timeout
- * @response GAP_LE_CREATE_CONN_REQ_CMP_EVT
- * @description
- *
- * This function is used to create a Link Layer connection to a connectable device.
- * This is initiated by central device, which will become the master of the link.
- *
- ****************************************************************************************
- */
- #if (BLE_CENTRAL)
- void app_gap_le_create_conn_req(struct bd_addr *addr, uint8_t addr_type, uint8_t own_addr_type,
- uint16_t conn_intv_min, uint16_t conn_intv_max, uint16_t cnnn_timeout)
复制代码
其中参数1为从机的广播地址,也就是楼主所说的mac地址,实际上的协议栈里面并没有通过MAC连接从机的api,只有bd_addr,这个地址是固化在NVDS中的。第二个参数是地址类型,共有* - ADDR_PUBLIC &* - ADDR_RAND 两个选项,既然你要制定bd addr,那么必须是ADDR_PUBLIC 。第三个是自身的地址,也是ADDR_PUBLIC 。接下来三个参数都是连接间隔时间参数。设置好之后如果该BD addr的设备有在广播的话,那么应该是可以连接得上的。
|
|