N
Just an update of the latest changes. The API of the microATsocket has changed to be closer to the typical usocket API. Also a custom version of getaddrinfo info has been implemented, so the code now looks somehting like:
import microATsocket as socket
from network import LTE
import binascii
lte = LTE()
# attach to network
# ...
#message as bytes
data = bytearray('{data:"testmessage"}')
# create socket instance providing the instance of the LTE modem
sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
sock.setModemInstance(lte)
# getaddrinfo needs to be called on the instance of socket
resolvedIPs = sock.getaddrinfo("google.com", 5683)
# send data to specific IP (dummy IP and port used as example)
sock.sendto(data, resolvedIPs[0][-1])
# receive data from the previously used IP.
# socket is still open from the 'sendto' operation
(resp, address) = sock.recvfrom(1024)
print("Response: from ip:" + address[0] + ", port: " + str(address[1]) + ", data: " + str(binascii.hexlify(bytearray(resp))))