HTTP POST request...Failed. Error code: 20

Wireless communications in Waspmote, topologies, node types...
Post Reply
sirchank
Posts: 7
Joined: Thu Mar 28, 2019 10:05 am
Company: Seawa

HTTP POST request...Failed. Error code: 20

Post by sirchank » Thu Oct 10, 2019 6:37 pm

This is from the example files, with no modification.
It´s kind of same error, connecting to an API:
4G module error opening socket. Error code: 20.
The SIM is unlock, pin test drives properly.
Thx

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: HTTP POST request...Failed. Error code: 20

Post by libelium-dev » Fri Oct 11, 2019 9:38 am

Hi,

Could you please post the output through the serial monitor with debug mode 2 enabled for 4G module? You can enable it inside Wasp4G.h file

Did you set the APN settings?

Regards

sirchank
Posts: 7
Joined: Thu Mar 28, 2019 10:05 am
Company: Seawa

Re: HTTP POST request...Failed. Error code: 20

Post by sirchank » Fri Oct 11, 2019 2:20 pm

Hi, I am using the smart water kit.
I set the apn for a simyo sim, just apn"orangeowrld" user and pass blank.
How exactly have to use debug mode?
Thx

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: HTTP POST request...Failed. Error code: 20

Post by libelium-dev » Fri Oct 11, 2019 2:35 pm

Hi,

Debug mode isn't available in that case. Anyway, please share with us the complete log through the serial monitor.

Could you please check with your sim card provider if the APN settings are correct? Could you please test to configure the apn "gprs-service.com"? Does it work?

Regards

sirchank
Posts: 7
Joined: Thu Mar 28, 2019 10:05 am
Company: Seawa

Re: HTTP POST request...Failed. Error code: 20

Post by sirchank » Sat Oct 12, 2019 9:40 pm

Does not work

H#
Start program
********************************************************************
POST method to the Libelium's test url
You can use this php to test the HTTP connection of the module.
The php returns the parameters that the user sends with the URL.
********************************************************************
*****************************
APN: gprs-service.com
LOGIN:
PASSWORD:
*****************************
1. 4G module ready...
2. HTTP POST request...Failed. Error code: 20
3. Switch OFF 4G module
4. Enter deep sleep...

sirchank
Posts: 7
Joined: Thu Mar 28, 2019 10:05 am
Company: Seawa

Re: HTTP POST request...Failed. Error code: 20

Post by sirchank » Sun Oct 13, 2019 9:41 pm

But i cant understand.
I change my Simyo SIM for an AMENA one. AMENA has same APN as SIMYO : "orangeworld" but user &pass : " orange" .
It worked at first try
But, today i uploaded same code than worked yesterday, and Error Code: 20.
I have made many tries with both Sim cards, and sometimes it works,
Tomorrow i will try with a MOVISTAR SIM, could that be the problem?
Thx

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: HTTP POST request...Failed. Error code: 20

Post by libelium-dev » Mon Oct 14, 2019 9:01 am

Hi,

Both sims should work if they are configured properly. Please try to upload the following code to check the coverage of the network. Just replace the APN settings. Copy here the output through the serial monitor

Code: Select all

/*
    ---  4G_03 - Getting network information ---

    Explanation: This example shows how to switch on the 4G module
    and get the network type and the operator name.

    Copyright (C) 2017 Libelium Comunicaciones Distribuidas S.L.
    http://www.libelium.com

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    Version:           3.1
    Design:            David Gascón
    Implementation:    Alejandro Gállego
*/

#include <Wasp4G.h>

// APN settings
///////////////////////////////////////
char apn[] = "";
char login[] = "";
char password[] = "";
///////////////////////////////////////

uint8_t connection_status;
char operator_name[20];

uint8_t error;

void setup()
{
  USB.ON();
  USB.println(F("Start program\n"));
  
  //////////////////////////////////////////////////
  // 1. sets operator parameters
  //////////////////////////////////////////////////
  _4G.set_APN(apn, login, password);


  //////////////////////////////////////////////////
  // 2. Show APN settings via USB port
  //////////////////////////////////////////////////
  _4G.show_APN();
}


void loop()
{
  //////////////////////////////////////////////////
  // 1. Switch ON the 4G module
  //////////////////////////////////////////////////
  error = _4G.ON();

  if (error == 0)
  {
    USB.println(F("1. 4G module ready"));

    ////////////////////////////////////////////////
    // 1.1. Check connection to network and continue
    ////////////////////////////////////////////////
    connection_status = _4G.checkDataConnection(120);
    
    if (connection_status == 0)
    {
      USB.println(F("1.1. Module connected to network"));

      // delay for network parameters stabilization
      delay(5000);

      //////////////////////////////////////////////
      // 1.2. Get RSSI
      //////////////////////////////////////////////
      error = _4G.getRSSI();
      if (error == 0)
      {
        USB.print(F("1.2. RSSI: "));
        USB.print(_4G._rssi, DEC);
        USB.println(F(" dBm"));
      }
      else
      {
        USB.println(F("1.2. Error calling 'getRSSI' function"));
      }

      //////////////////////////////////////////////
      // 1.3. Get Network Type
      //////////////////////////////////////////////
      error = _4G.getNetworkType();

      if (error == 0)
      {
        USB.print(F("1.3. Network type: "));
        switch (_4G._networkType)
        {
          case Wasp4G::NETWORK_GPRS:
            USB.println(F("GPRS"));
            break;
          case Wasp4G::NETWORK_EGPRS:
            USB.println(F("EGPRS"));
            break;
          case Wasp4G::NETWORK_WCDMA:
            USB.println(F("WCDMA"));
            break;
          case Wasp4G::NETWORK_HSDPA:
            USB.println(F("HSDPA"));
            break;
          case Wasp4G::NETWORK_LTE:
            USB.println(F("LTE"));
            break;
          case Wasp4G::NETWORK_UNKNOWN:
            USB.println(F("Unknown or not registered"));
            break;
        }
      }
      else
      {
        USB.println(F("1.3. Error calling 'getNetworkType' function"));
      }

      //////////////////////////////////////////////
      // 1.4. Get Operator name
      //////////////////////////////////////////////
      memset(operator_name, '\0', sizeof(operator_name));
      error = _4G.getOperator(operator_name);

      if (error == 0)
      {
        USB.print(F("1.4. Operator: "));
        USB.println(operator_name);
      }
      else
      {
        USB.println(F("1.4. Error calling 'getOperator' function"));
      }
    }
  }
  else
  {
    // Problem with the communication with the 4G module
    USB.println(F("4G module not started"));
    USB.print(F("Error code: "));
    USB.println(error, DEC);
  }

  //////////////////////////////////////////////////
  // 2. Switch OFF the 4G module
  //////////////////////////////////////////////////
  _4G.OFF();
  USB.println(F("2. Switch OFF 4G module"));


  //////////////////////////////////////////////////
  // 3. Sleep
  //////////////////////////////////////////////////
  USB.println(F("3. Enter deep sleep..."));
  PWR.deepSleep("00:00:00:10", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF);

  USB.ON();
  USB.println(F("4. Wake up!!\n\n"));

}
Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest