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

    Fipy + Pytrack v1.18.1.r4 + SNQNS Firmware CATM1-39592 - Verizon Socket Connection OSERROR:-1

    Scheduled Pinned Locked Moved Support & Troubleshooting
    fipyverizonlte-msocket connect
    7 Posts 2 Posters 894 Views 3 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.
    • W Offline
      wghirakawa
      last edited by

      Been trying this for several days, even reset SQNS Modem back to factory settings using at command to make sure that there are no issues. I am able to get ipaddress using the socket.getaddrinfo() function but, as far as connecting to the socket using the return addrinfo, i get an OSERROR:-1. Below is the code I am attempting to execute.

      import socket
      import ssl
      import time
      from network import LTE
      
      print('creating LTE object - carrier verizon')
      # lte = LTE()
      lte = LTE(carrier="verizon")
      # lte = LTE(carrier="at&t")         # instantiate the LTE object
      print('resetting modem, may take up to 5 secs...')
      lte.reset()
      print('attaching...')
      lte.attach()        # attach the cellular modem to a base station
      # lte.attach(band=13)        # attach the cellular modem to a base station
      
      while not lte.isattached():
          print('waiting for isattached...')
          time.sleep_ms(1000)
      
      print('connecting...')
      # lte.connect()       # start a data session and obtain an IP address
      lte.connect(cid=3)    # cid=3 for verizon - start a data session and obtain an IP address
      while not lte.isconnected():
          print('waiting for isconnected...')
          time.sleep_ms(500)
      
      print('create socket')
      s = socket.socket()
      
      print("Connect to: www.ces-web.com")
      sockaddr = socket.getaddrinfo('www.google.com', 80)[0][-1]
      
      #print("Connect to: www.google.com")
      #s = ssl.wrap_socket(s)
      #sockaddr = socket.getaddrinfo('www.google.com', 443)[0][-1]
      
      print("socket address: {}".format(sockaddr))
      
      s.connect(sockaddr)
      print("send GET request")
      s.send(b"GET / HTTP/1.0\r\n\r\n")
      print("receive response")
      print(s.recv(16))
      s.close()
      print("socket closed")
      lte.disconnect()
      print("disconnected")
      lte.dettach()
      print("dettached")
      lte.deinit()
      print("deinit")
      
      

      The response I get when executing s.connect() is as follows.

      Traceback (most recent call last):
        File "<stdin>", line 38, in <module>
      OSError: -1
      

      Need help please! @Xykon & @rskoniec

      If everyone in the world could do their passion, the world would be an unbelievable place!

      1 Reply Last reply Reply Quote 0
      • D Offline
        danielm
        last edited by

        Try it with 1.18.1.r6.

        W 1 Reply Last reply Reply Quote 0
        • W Offline
          wghirakawa
          last edited by wghirakawa

          Will try with r6. Thanks @danielm

          If everyone in the world could do their passion, the world would be an unbelievable place!

          1 Reply Last reply Reply Quote 0
          • W Offline
            wghirakawa @danielm
            last edited by

            @danielm where can I find r6. I tried doing the development version via the pycom firmware updater and it only download b5.

            If everyone in the world could do their passion, the world would be an unbelievable place!

            D 1 Reply Last reply Reply Quote 0
            • D Offline
              danielm @wghirakawa
              last edited by

              @wghirakawa
              It is a pre-release which is available for download here:
              https://github.com/pycom/pycom-micropython-sigfox/releases/tag/v1.18.1.r6

              W 1 Reply Last reply Reply Quote 0
              • W Offline
                wghirakawa @danielm
                last edited by

                @danielm r6 pre-release Did not work either. Please see code and output below.

                import socket
                import ssl
                import time
                from network import LTE
                
                print('creating LTE object - carrier verizon')
                # lte = LTE()
                lte = LTE(carrier="verizon")
                # lte = LTE(carrier="at&t")         # instantiate the LTE object
                print('resetting modem, may take up to 5 secs...')
                print('attaching...')
                lte.attach()        # attach the cellular modem to a base station
                # lte.attach(band=13)        # attach the cellular modem to a base station
                
                while not lte.isattached():
                    print('waiting for isattached...')
                    time.sleep_ms(1000)
                
                print('connecting...')
                # lte.connect()       # start a data session and obtain an IP address
                lte.connect(cid=3)    # cid=3 for verizon - start a data session and obtain an IP address
                while not lte.isconnected():
                    print('waiting for isconnected...')
                    time.sleep_ms(500)
                
                print('create socket')
                s = socket.socket()
                
                print("Connect to: www.ces-web.com")
                sockaddr = socket.getaddrinfo('www.google.com', 80)[0][-1]
                
                #print("Connect to: www.google.com")
                #s = ssl.wrap_socket(s)
                #sockaddr = socket.getaddrinfo('www.google.com', 443)[0][-1]
                
                print("socket address: {}".format(sockaddr))
                
                s.connect(sockaddr)
                print("send GET request")
                s.send(b"GET / HTTP/1.0\r\n\r\n")
                print("receive response")
                print(s.recv(16))
                s.close()
                print("socket closed")
                lte.disconnect()
                print("disconnected")
                lte.dettach()
                print("dettached")
                lte.deinit()
                print("deinit")
                
                >>> import os
                >>> os.uname
                <function>
                >>> os.uname()
                (sysname='FiPy', nodename='FiPy', release='1.18.1.r6', version='v1.8.6-849-a8966d1 on 2018-11-23', machine='FiPy with ESP32', lorawan='1.0.2', sigfox='1.0.1')
                >>> Running test.py
                
                >>>
                >>>
                creating LTE object - carrier verizon
                resetting modem, may take up to 5 secs...
                attaching...
                waiting for isattached...
                waiting for isattached...
                waiting for isattached...
                waiting for isattached...
                waiting for isattached...
                waiting for isattached...
                waiting for isattached...
                waiting for isattached...
                waiting for isattached...
                waiting for isattached...
                connecting...
                create socket
                Connect to: www.ces-web.com
                socket address: ('172.217.164.100', 80)
                Traceback (most recent call last):
                  File "<stdin>", line 39, in <module>
                OSError: -1
                >
                Pycom MicroPython 1.18.1.r6 [v1.8.6-849-a8966d1] on 2018-11-23; FiPy with ESP32
                Type "help()" for more information.
                >>>
                >>> import sqnsupgrade
                >>> sqnsupgrade.
                reconnect_uart  crc             LTE             __name__
                VERSION         UART            uart            detect_error
                info            sqnsupgrade     struct          time
                SD              sys             os              sysname
                run             print_welcome   release         stp
                >>> sqnsupgrade.VERSION
                '1.2.0'
                >>> sqnsupgrade.info()
                <<< Welcome to the SQN3330 firmware updater [1.2.0] >>>
                >>> FiPy with firmware version 1.18.1.r6
                Your modem is in application mode. Here is the current version:
                UE5.0.0.0d
                LR5.1.1.0-39529```

                If everyone in the world could do their passion, the world would be an unbelievable place!

                D 1 Reply Last reply Reply Quote 0
                • D Offline
                  danielm @wghirakawa
                  last edited by

                  @wghirakawa
                  The code seems to be ok. I don't have access to Cat M1 network (only NB-IoT available here) so I cannot test with the same Sequans firmware.

                  Are you able to perform communication on the same APN and with the same SIM using different hardware?

                  @iwahdan could you please take a look?

                  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