![Digi XBee3 XB3M1 Скачать руководство пользователя страница 62](http://html1.mh-extra.com/html/digi/xbee3-xb3m1/xbee3-xb3m1_user-manual_2496407062.webp)
XBee connection examples
Get started with MQTT
Digi XBee3 Cellular LTE-M/NB-IoT Global Smart Modem User Guide
62
print("Sending payload to modem...")
bytes_wr = ser.write(data)
# Write payload to modem via
UART/serial
print("Wrote {} bytes to modem".format(bytes_wr))
def main():
setup()
# Setup the serial port and socket
global clisock, svrsock
if (not clisock):
# Accept a connection on 'svrsock' to open 'clisock'
print("Awaiting ACCEPT on server sock...")
(clisock,cliaddr) = svrsock.accept()
# Accept an incoming
connection
print("Connection accepted on socket")
# Make thread for ComReader
comthread = threading.Thread(target=ComReaderThread)
comthread.start()
# Start the thread
# Make thread for SockReader
sockthread = threading.Thread(target=SockReaderThread)
sockthread.start()
# Start the thread
main()
Note
This script is a general TCP-UART proxy, and can be used for other applications or scripts that
use the TCP protocol. Its functionality is not limited to MQTT.
Note
You can easily copy and paste code from the
. Use caution with the
PDF version, as it may not maintain essential indentations.
This proxy script waits for an incoming connection on localhost (
127.0.0.1
), on port
17300
. After
accepting a connection, and creating a socket for that connection (
clisock
), it creates two threads,
one that reads the serial or COM port that the XBee Smart Modem is connected to, and one that
reads the socket (
clisock
), that the MQTT client is connected to.
With:
n
The proxy script running
n
The MQTT client connected to the proxy script via localhost (
127.0.0.1
)
n
The XBee Smart Modem connected to the machine via USB and properly powered
n
AP
,
DL
, and
DE
set correctly
the proxy acts as an intermediary between the MQTT client and the XBee Smart Modem, allowing the
MQTT client to use the data connection provided by the device.
Think of the proxy script as a translator between the MQTT client and the XBee Smart Modem. The
following figure shows the basic operation.
Содержание XBee3 XB3M1
Страница 1: ...Digi XBee3 Cellular LTE M NB IoT Smart Modem User Guide ...
Страница 13: ...Digi XBee3 Cellular LTE M NB IoT Global Smart Modem User Guide 13 RF Exposure 250 CE mark Europe 251 ...
Страница 110: ...Antenna recommendations Antenna placement 111 Digi XBee3 Cellular LTE M NB IoT Global Smart Modem User Guide 110 ...