Unable to Connect LTE
-
Hardware version: GPy 1.0
Software version: v1.8.6-849-df9f237 on 2019-05-14
Not sure of the firmware version of the modem -
@pycom_user123 That's a pretty old version of the firmware, but this is probably not the issue, band 42 is not listed as part of the supported bands in the GPy data sheet.
-
@jcaron Okay I've replaced the Amarisoft sim to a Verizon one which uses band 13. I've also adjusted the code but I'm still having issues with attaching. Any ideas?
import socket import time from network import LTE import ssl import machine from network import WLAN wlan = WLAN(mode=WLAN.STA) lte = LTE() def connect(): print('lte.attach()', end='') lte.attach() while not lte.isattached(): print('.', end='') time.sleep(0.25) print('Connecting to LTE network', end='') lte.connect() while not lte.isconnected(): print('.', end='') time.sleep(0.25) print('LTE is connected') def disconnect(): lte.disconnect(); lte.dettach(); def at(s): print(lte.send_at_cmd(s)) def google(): s = socket.socket() ss = ssl.wrap_socket(s) i = socket.getaddrinfo('www.google.com', 443)[0][-1] print('Connecting to socket...') ss.connect(i) print('Send...') ss.send(b"GET / HTTP/1.0\r\n\r\n") print(ss.recv(4096)) print('Close...') ss.close() def wifi(): wlan.init(mode=WLAN.STA, antenna=WLAN.INT_ANT) nets = wlan.scan() for net in nets: if net.ssid == 'Test': print('Network found!') wlan.connect(net.ssid, auth=(net.sec, 'Test1234'), timeout=5000) while not wlan.isconnected(): #machine.idle() # save power while waiting print('.', end='') time.sleep(0.5) print('WLAN connection succeeded!') break -
@pycom_user123 I strongly recommend you update to a more recent firmware version (and modem firmware as well). 1.8.6 is nearly 2 years old, lots has changed/been fixed since then.
-
@jcaron When I update the device through the Pycom firmware updater it updates to v1.8.6. Is this the latest version my board can handle? If not, where can I find a more up to date version of the firmware?
-
Update: The attach seems to work now, however I am still unable to connect. I get the following response.
>>> connect() lte.attach()Connecting to LTE networkTraceback (most recent call last): File "<stdin>", line 1, in <module> File "boot.py", line 22, in connect OSError: the requested operation failed >>> lte.attach() >>> lte.isattached() True >>> lte.isconnected() False -
@pycom_user123 connect follows attach
-
@robert-hh Correct. See my code in the previous reply. I issue the function connect(), which attempts to attach first and then connect.
-
@robert-hh I see lte.attach(), but no lte.connect(). Does your code wait in the function connect() after sending lte.attach(), until attach succeeded, before issuing lte.connect()?
-
@robert-hh Alright now I've successfully connected but I'm getting the following error when I try to run the google() function.
>>> lte.attach() >>> lte.isattached() True >>> lte.connect(cid=3) >>> lte.isconnected() True >>> google() Connecting to socket... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "boot.py", line 40, in google OSError: [Errno 113] EHOSTUNREACH -
@pycom_user123 transmissions like this can be very finicky. The functions do quite a bit of work to parse everything into exactly the right format with authorizations, acknowledgements, payloads, etc... Add in all of the formatting changes as everything is translated into hex, binary, etc....
Something as small as
s = socket.socket() ss = ssl.wrap_socket(s) i = socket.getaddrinfo('www.google.com', 443)[0][-1] print('Connecting to socket...') ss.connect(i) print('Send...') ss.send(b"GET / HTTP/1.0\r\n\r\n") print(ss.recv(4096)) print('Close...') ss.close()versus
s = socket.socket() s = ssl.wrap_socket(s) s.connect(socket.getaddrinfo('www.google.com', 443)[0][-1]) s.send(b"GET / HTTP/1.0\r\n\r\n") print(s.recv(4096)) s.close()can somehow result in a slightly different message being sent because
s.connect(socket.getaddrinfo('www.google.com', 443)[0][-1])is treated slightly differently than
i = socket.getaddrinfo('www.google.com', 443)[0][-1] s.connect(i)because of some small difference between floats, doubles, integers, strings, booleans, etc... I'd recommend starting with the Pycom documentation examples, or examples on the forums that are verified to be working.
-
@testuser That is an interesting observation you talk of. Can you give an example of that which is reproducible? The two statement you highlight should make exactly the same call, and if not, I would consider it as a bug, which should be fixed. For that, examples are essential.
-
@testuser The google() function works when I'm connected using wifi, so I don't think the function is the issue. I did retry using the code exactly as its written in the example as you suggest, but got the same error unfortunately.
-
@pycom_user123 Using my FiPy and an 1nce SIM, the google() function fails at getaddrinfo(), but replacing the symbolic address 'www.google.com' with the numeric '172.217.22.110' value succeeds, and I get data back from the server.
This error at resolving names was discussed before.
And yes: I disabled WiFi before the test. With WiFi, getaddrinfo() works. -
@robert-hh Still getting the same error when I change 'google.com' to its numeric value. I tried just getaddrinfo and it seems to work, so perhaps the issue as is with the s.connect() component.
>>> print(socket.getaddrinfo('172.217.22.110', 443)[0][-1]) ('172.217.22.110', 443) -
@pycom_user123 Forgot to mention: My firmware is 1.20.0.rc11.1.
What I wanted to tell is, that your function google() generally works, but each provider may have different omissions. -
@pycom_user123 After setting DNS servers manually with:
socket.dnsserver(0,'8.8.8.8') socket.dnsserver(1,'4.4.4.4')also getaddrinfo() works.
-
@robert-hh It still doesn't seem to work for me even after setting the DNS servers. Aside from this method is there another way I can verify my connection?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login