at commands socket connection (socket dial[NO CARRIER])



  • def socket_connect(ip, port, timeout_secs):
        # returns: True if connection successful
        print("connecting to ip - {0}, port - {1}".format(ip, port))
    
        # make sure socket is closed
        socket_close()
    
        # socket configuration
        # connID = 1 --> socket connection identifier
        # cid = 1 --> PDP context identifier
        # pktSz = 1500 --> packet size
        # maxTo = 10 --> exchange timeout in secs
        # connTo = 600 --> connection timeout in msecs
        # txTo = 3 --> data sending timeout in hundreds of msecs
        # a = at('AT+SQNSCFG=1,1,1500,10,600,3', 'OK')
        a = at('AT+SQNSCFG=1,1,1500,{0},600,3'.format(timeout_secs))
        if len(a) == 0:
            print("error connecting")
            return False
        
        # socket extended configuration
        # connID = 1 --> socket connection identifier
        # srMode = 1 --> SQNSRING URC data amount mode
        # recvDataMode = 1 --> data in hex
        # keepalive = 0 --> unused
        # listenAutoRsp = 0 --> deactivated
        # sendDataMode = 1 --> data in hex
        a = at('AT+SQNSCFGEXT=1,1,1,0,0,1')
        if len(a) == 0:
            print("error connecting")
            return False
    
        #a = at('AT+SQNSL=1,1,{0}'.format(port))
    
        # socket dial
        # connID = 1 --> socket connection identifier
        # txProt = 0 --> TCP protocol
        # rPort = <port> --> remote host port to contact
        # IPaddr = <ip> --> address of remote host
        # closureType = 0 --> local host closes immediately when remote host has closed
        # lPort = 0 --> UDP port (not used)
        # connMode = 1 --> command mode connection
        # acceptAnyRemote = 0 --> disabled 
        a = at('AT+SQNSD=1,0,{0},"{1}",0,0,1,0'.format(port,ip))
        if len(a) == 0:
            print("error connecting")
            return False
        print("** connection successful **")
        return True
    

    I set the socket config and extend config parameters as follows and the modem's response is 'OK'. It's okay, but I get an error saying '[NO CARRIER]' on socket dial.

    modem command: AT+SQNSD=1,0,42000,"10.164.0.93.255.255.255.255",0,0,1,0
    modem response: ['NO CARRIER']
    

    What could be the reason for this? Can anyone with an idea help me?

    Thank you for your return and advices.


  • Global Moderator

    The NO CARRIER error is related to the Modem not being connected to a network, hence the No carrier. Also, it seems your IP address is not correct as "10.164.0.93.255.255.255.255", I believe it should be "10.164.0.93"


Log in to reply
 

Pycom on Twitter