frame

Particle Electron -- Help using socket library.... set socket to DGRAM

pmjackson Member
edited August 6 in Troubleshooting
I am able to connect to cellular network.
I can get IP of Zerynth.com
But...

sock = socket.socket(type=socket.SOCK_DGRAM) gives errors
###################################################################################
try:
    # connect to our APN
    gsm.connect_net('xxxxxxxx')
except Exception as e:
    print("ooops, something wrong while connecting :(", e)

    sleep(1000)
print("g350.actived()")
print (g350.activated())
print(g350.gethostbyname("zerynth.com"))
sleep(2000)
    
try:    
# create a tcp socket
    print("sock = socket.socket(type=socket.SOCK_DGRAM)")
    sock = socket.socket(type=socket.SOCK_DGRAM)

# connect the socket to net address XXX.XXX.XXX.XXX port 7777
    print("sock.connect((\"XXX.XXX.XXX.XXX\",7777))")
    sock.connect(("34.202.239.150",7777))

# send something on the socket!
    print(" sock.sendato(\"55\")")
    sock.sendto("55")   
except Exception as e:   
    print("ooops, not send :(", e)
###################################################################################

Debug = True of G350.py
g350.actived()

True
cmd:  AT+UDNSRN=0,"zerynth.com"
-1
-1
-1
-1
-1
-1
+UDNSRN: "108.167.183.127"
OK
108.167.183.127
sock = socket.socket(type=socket.SOCK_DGRAM)
cmd:  AT+USOCTL=0,1
-1
+CME ERROR: operation not allowed
cmd:  AT+USOCTL=1,1
-1
+CME ERROR: operation not allowed
cmd:  AT+USOCTL=2,1
-1
+CME ERROR: operation not allowed
cmd:  AT+USOCTL=3,1
-1
+CME ERROR: operation not allowed
cmd:  AT+USOCTL=4,1
-1
+CME ERROR: operation not allowed
cmd:  AT+USOCTL=5,1
-1
+CME ERROR: operation not allowed
cmd:  AT+USOCTL=6,1
-1
+CME ERROR: operation not allowed
sock.connect(("XXX.XXX.XXX.XXX",7777))
cmd:  AT+USOCO=None,"XXX.XXX.XXX.XXX",7777
-1
+CME ERROR: operation not supported
ooops, not send :( g350Exception @[00A4:0064:0000:0000:0000:0000:0000:0000]

Comments

  • GiacomoGiacomo Member
    Hello @pmjackson ,

    thanks for your report. It seems there is a bug in g350 library for UDP.
    We are running tests to spot other related issues, however in the meantime you can try this (untested) patch: open the g350 driver at dist/r2.0.9/libs/official/ublox/g350/g350.py and add modify from line 687 with this:

                        self.send("AT+USOCR=17")
                        r = self.wait_resp(callback = self._handle_usocr)
                        if r[0] != RESP_OK:
                            break
                        self._sockets[i] = _sockdata(proto,i)
                        self._sockets[i].channel = r[1]

    Let me know if this solves the issue. We will release a bugfix asap.
    Giacomo Baldi
    Zerynth Head of Software Development
  • Hello @Giacomo,

    I tried the patch, it allowed the firmware to run to the next socket command but still has g350Exception.
    cmd:  AT+USOCTL=0,1
    -1
    +CME ERROR: operation not allowed
    cmd:  AT+USOCTL=1,1
    -1
    +CME ERROR: operation not allowed
    cmd:  AT+USOCTL=2,1
    -1
    +CME ERROR: operation not allowed
    cmd:  AT+USOCTL=3,1
    -1
    +CME ERROR: operation not allowed
    cmd:  AT+USOCTL=4,1
    -1
    +CME ERROR: operation not allowed
    cmd:  AT+USOCTL=5,1
    -1
    +CME ERROR: operation not allowed
    cmd:  AT+USOCTL=6,1
    -1
    +CME ERROR: operation not allowed
    sock1
    cmd:  AT+USOCO=None,"XXX.XXX.XXX.XXX",7777
    -1
    +CME ERROR: operation not supported
      
Sign In or Register to comment.

ZERYNTH Community

@ 2016 Zerynth.com, all rights reserved.