Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Unable to Connect LTE

    Scheduled Pinned Locked Moved GPy
    20 Posts 4 Posters 1.5k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • robert-hhR Offline
      robert-hh @pycom_user123
      last edited by

      @pycom_user123 connect follows attach

      P robert-hhR 2 Replies Last reply Reply Quote 0
      • P Offline
        pycom_user123 @robert-hh
        last edited by

        @robert-hh Correct. See my code in the previous reply. I issue the function connect(), which attempts to attach first and then connect.

        1 Reply Last reply Reply Quote 0
        • robert-hhR Offline
          robert-hh @robert-hh
          last edited by

          @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()?

          P 1 Reply Last reply Reply Quote 0
          • P Offline
            pycom_user123 @robert-hh
            last edited by

            @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
            
            T 1 Reply Last reply Reply Quote 0
            • T Offline
              testuser @pycom_user123
              last edited by

              @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.

              robert-hhR P 2 Replies Last reply Reply Quote 0
              • robert-hhR Offline
                robert-hh @testuser
                last edited by

                @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.

                1 Reply Last reply Reply Quote 0
                • P Offline
                  pycom_user123 @testuser
                  last edited by

                  @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.

                  robert-hhR 1 Reply Last reply Reply Quote 0
                  • robert-hhR Offline
                    robert-hh @pycom_user123
                    last edited by

                    @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.

                    P 1 Reply Last reply Reply Quote 0
                    • P Offline
                      pycom_user123 @robert-hh
                      last edited by

                      @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)
                      
                      robert-hhR 2 Replies Last reply Reply Quote 0
                      • robert-hhR Offline
                        robert-hh @pycom_user123
                        last edited by

                        @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.

                        1 Reply Last reply Reply Quote 0
                        • robert-hhR Offline
                          robert-hh @pycom_user123
                          last edited by

                          @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.

                          P 1 Reply Last reply Reply Quote 0
                          • P Offline
                            pycom_user123 @robert-hh
                            last edited by

                            @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?

                            1 Reply Last reply Reply Quote 0

                            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
                            • 1 / 1
                            • First post
                              Last post

                            Pycom on Twitter

                            Pycom