cc2541可以同时担任观察者和外围设备的角色吗?

时间:2014-11-24 06:56:51

标签: hardware bluetooth-lowenergy system-on-chip

我想使用cc2541首先接收ibeacon包,然后将其传输到其他中央设备。 但cc2541如何同时成为观察者(或中心)和外围设备的角色? 任何人都可以给我一个海盗解决方案吗?非常感谢你!

1 个答案:

答案 0 :(得分:1)

使用Bluegiga BLE113或BLE121LR模块(内部均由CC2541芯片组供电),可以使用Bluegiga BLE堆栈和SDK将模块作为外设和观察器运行。以下BGScript片段演示了如何使模块可连接并同时在观察模式下扫描:

# system boot occurs at power-on and reset
event system_boot(major, minor, patch, build, ll_version, protocol, hw)
    call gap_set_mode(gap_general_discoverable, gap_undirected_connectable)
    call gap_discover(gap_discover_observation)
end

# catch new or updated connection
event connection_status(connection, flags, address, address_type, conn_interval, timeout, latency, bonding)
    # new connection will terminate scan, so re-start here to keep it going
    call gap_discover(gap_discover_observation)
end

# catch scan response during discovery
event gap_scan_response(rssi, packet_type, sender, address_type, bond, data_len, data_data)
    # ad payload data will be in "data_data(0:data_len)" buffer
    # one "gap_scan_response" event per observed ad packet
end

这是一个非常基本的实现来演示这个概念,你需要一些其他项目定义文件来配合它,如Bluegiga文档中所述(例如project.bgprojgatt.xml,{ {1}}),但这至少表明它是可能的。您还需要实现其他逻辑来处理将数据传递到已连接的中央设备(此处未显示)。有关这些设备和SDK的更多信息,请访问:

我不熟悉如何使用TI等其他堆栈来实现这一目标,但它与Bluegiga最新的SDK和CC2540 / CC2541驱动的模块一起开箱即用。