Home/Support/Support Forum/Cellular Sockets: Sending Data Best Practice
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Cellular Sockets: Sending Data Best Practice

0 votes
I am using a Xbee3 (ZigBee protocol) and a XBee3 Cellular LTE-M/NB-IoT (set to use LET-M only) connected via UART as a gateway to the cloud for a Xbee3 ZigBee network. Since the nature of the gateway is to pass data to the cloud for multiple ZigBee end nodes, it can have multiple cloud pushes in a few second interval sometimes since each end node is setup point to point in a asynchronous network.

I can successfully get one end node to push on a 60second interval without issues, but when I try and add more end nodes I end up with either a timeout or socket leaks.

Question: For each end node cloud push, do I need to go through the socket sequence of connect, send, close or can I leave a socket open for a few minutes and send as many end node pushes as needed during the interval.

Below is a excerpt from my code where I currently connect, send, and close for each end node cloud push. Also, I had to exclude any response via "s.recv(100)" because it was taking ~65seconds for this to process even with excellent cell signal strength. This may be a host issue but either way it was causing an error so I removed it for testing.

def sendUbidotsData(device_label, token, body):
s = usocket.socket()
s.connect(("industrial.api.ubidots.com", 80))
request = bytes(
'POST /api/v1.6/devices/%s HTTP/1.1\r\nHost: industrial.api.ubidots.com\r\nX-Auth-Token: %s\r\nContent-Type: application/json\r\nContent-Length: %s\r\n\r\n%s\r\n' % (
device_label, token, len(body), body), 'utf8')

I started with this tutorial (https://help.ubidots.com/en/articles/3713091-integrate-a-digi-xbee-cellular-3g-modem-to-ubidots-platform-using-micropython) to give you some background on where this came from.

Also, I have reference the Digi documentation here: https://www.digi.com/resources/documentation/digidocs/90002219/default.htm#tasks/t_set_timeout.htm%3FTocPath%3DSocket%2520examples%7C_____5 to try and figure it out as well with no luck.

I am new to the cellular side of Digi and I am trying to get a deeper understanding of how sockets work and best practices so any advice or suggestions would be appreciated.
asked Nov 30, 2020 in Digi Connect Cellular by backpacker87 Community Contributor (51 points)

Please log in or register to answer this question.

1 Answer

0 votes
Try using the sockets 2.0 function on the XBee3 CAT M.

answered Nov 30, 2020 by mvut Veteran of the Digi Community (15,409 points)