EasyManua.ls Logo

Digi XBee3 - Software Libraries

Digi XBee3
172 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Getting started with the XBee Smart Modem Development Kit Software libraries
Digi XBee3 Cellular LTE-M Global Smart Modem User Guide
48
The thread that reads the serial port forwards any data received onward to the client socket, and the
thread reading the client socket forwards any data received onward to the serial port. This is
represented in the figure above.
The proxy script needs to be running before running an MQTT publish or subscribe script.
1. With the proxy script running, run the subscribe example from Example: receive messages
(subscribe) with MQTT, but change the connect line from client.connect("m2m.eclipse.org",
1883, 60) to client.connect("127.0.0.1", port=17300, keepalive=20). This connects the
MQTT client to the proxy script, which in turn connects to a broker via the XBee Smart
Modem’s internet connection.
2. Run the publish example from Example: send messages (publish) with MQTT in a third Python
instance (while the publish script is running you will have three Python scripts running at the
same time).
The publish script runs over your computer’s normal Internet connection, and does not use the XBee
Smart Modem. You are able to see your published message appear in the subscribe scripts output
once it is received from the broker via the XBee Smart Modem. If you watch the output of the proxy
script during this process you can see the receptions and transmissions taking place.
The proxy script must be running before you run the subscribe and publish scripts. If you stop the
subscribe script, the socket closes, and the proxy script shows an error. If you try to start the proxy
script after starting the subscribe script, you may also see a socket error. To avoid these errors, it is
best to start the scripts in the correct order: proxy, then subscribe, then publish.
Software libraries
One way to communicate with the XBee device is by using a software library. The libraries available
for use with the XBee Smart Modem include:
n XBee Java library
n XBee Python library
n XBee ANSI C library
n XBee mbed library
The XBee Java Library is a Java API. The package includes the XBee library, its source code and a
collection of samples that help you develop Java applications to communicate with your XBee devices.
The XBee Python Library is a Python API that dramatically reduces the time to market of XBee
projects developed in Python and facilitates the development of these types of applications, making it
an easy process.
The XBee ANSI C Library project is a collection of portable ANSI C code for communicating with the
devices in API mode.

Table of Contents

Related product manuals