Send broadcast data

In previous generations, the socket Python module was used to send broadcast data to all the XBee nodes of the network:

  1. Create a socket with the required XBee options.
  2. Bind it to the desired end point, cluster ID, and profile ID.
  3. Only explicit data can be sent as you have to specify end point, cluster ID, and profile ID when building the destination address. Also, you must specify the broadcast address in the destination address.

In the new XBee gateways, the way data is broadcast to all XBee devices in the network is totally different. Using the digidevice.xbee Python module, you can send data to any remote XBee using the local XBee instance. You can also broadcast explicit data to a specific end point, cluster ID, and profile ID.

Standard data broadcast

Once you have the local XBee instance:

  1. Invoke the send_data_broadcast(data) method specifying the data to broadcast.
New API
from digidevice import xbee
  
DATA_TO_SEND = "Hello, World!"
  
device = xbee.get_device()
try:
    device.open()
    device.send_data_broadcast(DATA_TO_SEND)
finally:
    if device.is_open():
        device.close()
    

Explicit data broadcast

Once you have the local XBee instance:

  1. Invoke the send_expl_data_broadcast(data, source_end_point, dest_end_point, cluster_id, profile_id) method specifying the data to broadcast, the end points, the cluster ID, and the profile ID.
New API
from digidevice import xbee
  
DATA_TO_SEND = "Hello, World!"
SRC_ENDPOINT = 0xA0
DEST_ENDPOINT = 0xA1
CLUSTER_ID = 0x1554
PROFILE_ID = 0x1234
  
device = xbee.get_device()
try:
    device.open()
    device.send_expl_data_broadcast(DATA_TO_SEND, SRC_ENDPOINT, DEST_ENDPOINT, CLUSTER_ID, PROFILE_ID)
finally:
    if device.is_open():
        device.close()