Can cc2541 be the role of observer and peripheral at the same time?

1.2k views Asked by At

I want to use cc2541 to first receive ibeacon packages, and then transmit it to other Central device. But how can cc2541 be the role of observer(or central) and peripheral at the same time? Can anyone offer me a piratical solution? Thank you very much!

1

There are 1 answers

0
Jeff Rowberg On

Using the Bluegiga BLE113 or BLE121LR modules (which are both powered by the CC2541 chipset internally), it is possible using the Bluegiga BLE stack and SDK to run the module as peripheral and observer. The following BGScript snippet demonstrates how you would make a module be connectable and scanning in observation mode simultaneously:

# 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

This is a very basic implementation to demonstrate the concept, and you would need a few other project definition files to go along with it as described in the Bluegiga documentation (e.g. project.bgproj, gatt.xml, hardware.xml), but this at least demonstrates that it is possible. You would also need to implement additional logic to handle passing that data on to a connected central device, not shown here. More information on these devices and the SDK can be found here:

I am not familiar with how you would do this using other stacks such as TI's, but it works out of the box with Bluegiga's latest SDK and their CC2540/CC2541-powered modules.