Firefly开源社区

打印 上一主题 下一主题

主从模式的建立连接和发送数据问题

10

积分

0

威望

0

贡献

游客

积分
10

主从模式的建立连接和发送数据问题

发表于 2016-3-14 15:13:19      浏览:4232 | 回复:1        打印      只看该作者   [复制链接] 楼主
把论坛的帖子都看了一遍,还是不太能看懂。如何通过主机写mac地址数据连接从机
回复

使用道具 举报

400

积分

0

威望

0

贡献

注册会员

Rank: 8Rank: 8

积分
400
QQ
发表于 2016-3-15 11:48:23        只看该作者  沙发
主机发起对从设备的链接请求的api可以在app_gap.c中找到:
  1. /*
  2. ****************************************************************************************
  3. * @brief Create connection with the remote BLE device.        *//**
  4. *
  5. * @param[in] addr The address of the remote device to which the connection will be created
  6. * @param[in] addr_type The address type of the remote device, possible values are:
  7. * - ADDR_PUBLIC        
  8. * - ADDR_RAND         
  9. * @param[in] own_addr_type Own address type, possible values are:
  10. * - ADDR_PUBLIC        
  11. * - ADDR_RAND         
  12. * @param[in] conn_intv_min  Minimum of connection interval
  13. * @param[in] conn_intv_max  Maximum of connection interval
  14. * @param[in] cnnn_timeout   Link supervision timeout
  15. * @response  GAP_LE_CREATE_CONN_REQ_CMP_EVT
  16. * @description
  17. *
  18. * This function is used to create a Link Layer connection to a connectable device.
  19. * This is initiated by central device, which will become the master of the link.
  20. *
  21. ****************************************************************************************
  22. */
  23. #if (BLE_CENTRAL)
  24. void app_gap_le_create_conn_req(struct bd_addr *addr, uint8_t addr_type, uint8_t own_addr_type,
  25.                                 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的设备有在广播的话,那么应该是可以连接得上的。
没个性,不签名!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

友情链接 : 爱板网 电子发烧友论坛 云汉电子社区 粤ICP备14022046号-2
快速回复 返回顶部 返回列表