Python for Begginers - Zigbee sockets examples

Im reading the Zigbee Socket example in the Digi Python Programming Guide (pg. 37) and cant seem to figure out where to get the endpoint, profile id, and cluster id from. Sorry for the basic question, i’m new to this. Can somebody lend a hand please?

It is a little complex due to the new terminology but once you get oriented everything is alright.

If you are using bind() you bind to a thing called an endpoint. An endpoint is specified by a number between 0 and 240 (in decimal). Endpoints allow a radio to send and receive messages to and from multiple local applications. An analog for this in the Internet world is the concept of a TCP/IP port number.

With XBee radios there are two special endpoints: 0x0 and 0xe8. 0x0 is the “ZCL” endpoint and contains several “clusters” for gathering statistics and configuraton information as defined in the ZigBee Device Profile of the ZigBee specification. 0xe8 (decimal 232) is the “data endpoint” of the XBee Application. For example, clusters on this endpoint allow you to send a message to a remote node so that it may be emitted from the remote node’s serial port. Another example of a packet you may receive on endpoint 0xe8 is an automated remote sensor reading.

All endpoints have a “profile identifier” that informs an application how to format and interpret data. If you speak to endpoint 0xe8 of an XBee node you will always use profile id 0xc105–the XBee profile.

Clusters are little numeric identifiers that specify how the remote node should interpret the data packet. In the former example, sending a packet to an XBee with a profile ox 0xc105 and cluster 0x11 tells the remote XBee to transmit the packet out its serial port. If you send a packet to endpoint 0xe8, profile 0xc105, and cluster 0x12 the packet will loopback to the sender. This is often used for testing link connectivity.

The easiest way to learn about addressing is to try a few examples yourself. Try binding to 0xe8 and sending a frame from a remote XBee to your application. Are you able to receive it? Try binding to a different endpoint. What happens?


Very helpful info! Thanks heaps Jordan! I havent tried the examples yet cos i’m still trying to learn how to program.

Is there a list you use to choose what modules you can include? The line that says “from socket import *”, what is * for?

Hi! I’m trying to communicate with a Xbee board. I sent a packet, and i got it back, i think because my destination address is like this:

0xe8, 0xc105, 0x11)

perhaps it’s because of the 0x11 cluster.

What do i want to do? I want to send an AT command to the board and read the reply, but I don’t know how to do it. I have to do it with Python, from a ConnectPort x2 gateway. I tried something like this:


(s is my socket) , my goal is to do a Device Discovery from every board, without broadcast hops, to read the answers and extract the RSSI of each received packet from every discovered node.

Thanks in advance!!

The line “from socket import *” instructs the Python interpreter to take all of the names included in the socket module and make them available for use in the current environment–in this case, your application.

Functions such as socket() (which creates sockets) and names such as “AF_XBEE” (which is used to create XBee sockets) are included in the socket module.

I think you will probably find this page useful:

Be aware that you can interactively use Python in order to learn either by running Python on your local computer or by telneting to the Digi device and typing “python” at the command line interface. It is very useful for experimentation!


Thanks Jordan!
One more question please. I understand that at the beginning of some applications (depending on what it is), you may have to import certain modules, so you use the “import” command or “from __ import __” … is there a library that i can use to guide me on knowing what modules i have to import in order to make my application work? How do i know the different modules i can import?

In the python programming guide, it says “The Format of the tuple is: (address_string, endpoint, profile_id, cluster_id)”. And i saw this was being used like this:
0xe8, 0xc105, 0x11)
For the address string, is that mac address of a node? Is the only way to find this mac address is by running that pc companion application or the gateway demo application in the drop in networking kit?

What you want to do is send your Remote AT commands using the DDO (“Digi Device Objects”) interface. See: