I am using GPy board to have an IOT device connect to it via WIFI and have internet connectivity on the device via LTE-M connection. Here is what I have done so far:
At power up, the GPy board comes up as WIFI AP (default).
I can successfully connect to the Verizon Cellular Network as evident by 'isconnected' and 'isattached' commands coming as TRUE.
I have written a socket server which does the following:
a. Listens to incoming client sockets and accepts the connection.
b. Whatever data is received from the sockets and it is sent out.
At this point, I can connect my cell phone to GPY WIFI AP. (I can see the socket connection being accepted in log.)
But I am not getting any internet connectivity on my cell phone i.e. I cannot load emails, web pages etc.
Any idea what might be happening? My suspicion is that there is something missing in my socket server implementation. I read data from sockets and write the received data back to sockets. But am I really sending data out to the LTE-M socket? Not sure.
Please let me know what do you guys think?
My socket server code is below along with the FW version.
Any help is much appreciated!
Thanks,
SYED
===========================================
import os
os.uname()
(sysname='GPy', nodename='GPy', release='1.20.0.rc13', version='v1.9.4-94bb382 on 2019-08-22', machine='GPy with ESP32')
===========================================
import socket
import ssl
import time
import sys
import select
from network import LTE
lte = LTE(carrier="verizon", cid=3) # instantiate the LTE object
lte.attach(band=13, apn="VZWINTERNET", type=LTE.IP) # attach the cellular modem to a base station
while not lte.isattached():
time.sleep(0.25)
print('Attaching...')
print ('Attached!')
lte.connect() # start a data session and obtain an IP address
while not lte.isconnected():
time.sleep(0.25)
print('Connecting...')
print ('Connected!')
CONNECTION_LIST = [] # list of socket clients
RECV_BUFFER = 1024 # Advisable to keep it as an exponent of 2
PORT = 8888
Add server socket to the list of readable connections
CONNECTION_LIST.append(server_socket)
while 1:
Get the list sockets which are ready to be read through select
read_sockets,write_sockets,error_sockets = select.select(CONNECTION_LIST,[],[])
for sock in read_sockets:
#New connection
if sock == server_socket:
#Handle the case in which there is a new connection received through server_socket
client_socket, addr = server_socket.accept()
CONNECTION_LIST.append(client_socket)
print ('Client socket connected @ ' + addr[0] + ':' + str(addr[1]))
#Some incoming message from a client
else:
data = sock.recv(RECV_BUFFER)
#echo back the client message
if data:
sock.send(data)
#client disconnected, so remove from socket list
else:
sock.close()
print ('Client socket removed')
CONNECTION_LIST.remove(sock)
Hi,
I am using GPy board to have an IOT device connect to it via WIFI and have internet connectivity on the device via LTE-M connection. Here is what I have done so far:
Thanks, SYED
===========================================
===========================================
import socket import ssl import time import sys import select
from network import LTE
lte = LTE(carrier="verizon", cid=3) # instantiate the LTE object lte.attach(band=13, apn="VZWINTERNET", type=LTE.IP) # attach the cellular modem to a base station
while not lte.isattached(): time.sleep(0.25) print('Attaching...') print ('Attached!')
lte.connect() # start a data session and obtain an IP address
while not lte.isconnected(): time.sleep(0.25) print('Connecting...') print ('Connected!')
CONNECTION_LIST = [] # list of socket clients RECV_BUFFER = 1024 # Advisable to keep it as an exponent of 2 PORT = 8888
Create socket
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) print ('Server socket created')
Bind socket
server_socket.bind(('', PORT)) print ('Server socket bind')
Listen socket
server_socket.listen(1) print ('Server socket listen')
Add server socket to the list of readable connections
CONNECTION_LIST.append(server_socket)
while 1:
Get the list sockets which are ready to be read through select
server_socket.close() print ('Socket closed')