Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

u-blox Nina b112 error + Sara G350 #222

Open
tcpipchip opened this issue Jun 14, 2021 · 14 comments
Open

u-blox Nina b112 error + Sara G350 #222

tcpipchip opened this issue Jun 14, 2021 · 14 comments

Comments

@tcpipchip
Copy link

Sir,
How are you ?
After config

    "nsapi.default-cellular-apn": "\"java.com.br.br\"",
        "nsapi.default-cellular-username":  "\"claro\"",
        "nsapi.default-cellular-password":  "\"claro\"",
        "GENERIC_AT3GPP.tx": "p8",
    "GENERIC_AT3GPP.rx": "p11",
"GENERIC_AT3GPP.baudrate":115200
    },
    "NRF52_DK": {
        "target.macros_add": ["UBX_MDM_SARA_G3XX", "UBX_MDM_SARA_G350"]
    }

I am getting the error

mbed-os-example-cellular
Failed to get_default_instance()

Can you help me ?

@0xc0170
Copy link
Contributor

0xc0170 commented Jun 14, 2021

The error comes from the example

#if MBED_CONF_APP_SOCK_TYPE == NONIP
    NetworkInterface *net = CellularContext::get_default_nonip_instance();
#else
    NetworkInterface *net = CellularContext::get_default_instance();
#endif

You should check what is being returned inside this default instance function (I assume you get into ip one).

@AnttiKauppila
Copy link

Have you configured the modem to provide the default instance?
You need to override and set one of the following to true in your mbed_app.json:
https://github.com/ARMmbed/mbed-os/blob/master/connectivity/drivers/cellular/UBLOX/PPP/mbed_lib.json#L24-L26 for PPP mode or
https://github.com/ARMmbed/mbed-os/blob/master/connectivity/drivers/cellular/UBLOX/AT/mbed_lib.json#L24-L26 for AT mode

@ciarmcom
Copy link
Member

@tcpipchip This issue has an incomplete or old issue template.For future reference please use an up to date clone of the repository before raising issues. Many thanks.

@ciarmcom
Copy link
Member

Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers.
Internal Jira reference: https://jira.arm.com/browse/IOTOSM-4068

@tcpipchip
Copy link
Author

tcpipchip commented Jun 14, 2021

Team!!!!
Thank you for the fast help! I hope soon test in 4 u-blox modem models that i have here! I intend to make blogs about then using the PPP.
Well, getting progress here!

@tcpipchip
Copy link
Author

getting more progresss!
But i need some TIP
image

@tcpipchip
Copy link
Author

tcpipchip commented Jun 14, 2021

Here a link
https://youtu.be/FVG1x1xtzto

I am not using handshaking!
DNS is resolving!

@tcpipchip
Copy link
Author

tcpipchip commented Jun 15, 2021

Hi, i tried too other servers...got connection to the server, but cant send and receive data

some suggestion team ?

@tcpipchip
Copy link
Author

Sir
Can you see if am i doing something wrong ?
`/*

  • Copyright (c) 2017 ARM Limited. All rights reserved.
  • SPDX-License-Identifier: Apache-2.0
  • Licensed under the Apache License, Version 2.0 (the License); you may
  • not use this file except in compliance with the License.
  • You may obtain a copy of the License at
  • http://www.apache.org/licenses/LICENSE-2.0
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an AS IS BASIS, WITHOUT
  • WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.
    */

#include "mbed.h"
#include "CellularNonIPSocket.h"
#include "UDPSocket.h"
#include "TCPSocket.h"
#include "cellular_demo_tracing.h"

/* configuration choices in mbed_app.json */
#define UDP 0
#define TCP 1
#define NONIP 2

#if MBED_CONF_APP_SOCK_TYPE == TCP
static constexpr char SOCKET_TYPE[] = "TCP";
#elif MBED_CONF_APP_SOCK_TYPE == UDP
static constexpr char SOCKET_TYPE[] = "UDP";
#elif MBED_CONF_APP_SOCK_TYPE == NONIP
static constexpr char SOCKET_TYPE[] = "CellularNonIP";
#endif
static const char ECHO_HOSTNAME[] = MBED_CONF_APP_ECHO_SERVER_HOSTNAME;

class CellularDemo {
static constexpr uint8_t RETRY_COUNT = 3;

public:
CellularDemo(NetworkInterface &network)
: _net(network)
{ }

~CellularDemo() { }

/** Run the cellular demo. */
void run()
{
    /* sim pin, apn, credentials and possible plmn are taken automatically from json
     * when using NetworkInterface::set_default_parameters() */
    _net.set_default_parameters();

    nsapi_size_or_error_t ret = NSAPI_ERROR_NO_CONNECTION;

    if (connect_cellular()) {
        /* ping echo server */
        if (!test_send_and_receive()) {
            printf("Sending and received data failed.\n");
            wait_us(1000000);
        }

        ret = _net.disconnect();

        if (ret != NSAPI_ERROR_OK) {
            printf("Disconnect failed (error: %d).\n", ret);
            wait_us(1000000);
        }
    }

    if (ret == NSAPI_ERROR_OK) {
        printf("Success. Exiting\n");
        wait_us(1000000);
    } else {
        printf("Failure. Exiting\n");
        wait_us(1000000);
    }
}

private:
/**
* For UDP or TCP it opens a socket with the given echo server and performs an echo transaction.
* For Cellular Non-IP it opens a socket for which the data delivery path is decided
* by network's control plane CIoT optimisation setup, for the given APN.
*/
bool test_send_and_receive()
{
nsapi_size_or_error_t ret;

    ret = _socket.open(&_net);

    if (ret != NSAPI_ERROR_OK) {
        printf("%sSocket.open() fails, code: %d\n", SOCKET_TYPE, ret);
        wait_us(1000000);
        return false;
    }

    _socket.set_timeout(15000);

    if (!resolve_hostname()) {
        return false;
    }

    if (!connect_socket()) {
        return false;
    }

    ret = send_test_data();


    if (ret < 0) {
        printf("%sSocket.send() fails, code: %d\n", SOCKET_TYPE, ret);
        wait_us(1000000);
        return false;
    } else {
        printf("%s: Sent %d Bytes to %s\n", SOCKET_TYPE, ret, ECHO_HOSTNAME);
        wait_us(1000000);
    }

    ret = receive_test_data();

    if (ret < 0) {
        printf("%sSocket.recv() fails, code: %d\n", SOCKET_TYPE, ret);
        wait_us(1000000);
        return false;
    } else {
        printf("Received from echo server %d Bytes\n", ret);
        wait_us(1000000);
    }

    _socket.close();

    if (ret != NSAPI_ERROR_OK) {
        printf("%sSocket.close() fails, code: %d\n", SOCKET_TYPE, ret);
        wait_us(1000000);
        return false;
    }

    return true;
}

/** Connects to the Cellular Network */
bool connect_cellular()
{
    printf("Establishing connection\n");
    wait_us(1000000);

    /* check if we're already connected */
    if (_net.get_connection_status() == NSAPI_STATUS_GLOBAL_UP) {
        return true;
    }

    nsapi_error_t ret;

    for (uint8_t retry = 0; retry <= RETRY_COUNT; retry++) {
        ret = _net.connect();

        if (ret == NSAPI_ERROR_OK) {
            printf("Connection Established.\n");
            wait_us(1000000);
            return true;
        } else if (ret == NSAPI_ERROR_AUTH_FAILURE) {
            printf("Authentication Failure.\n");
            wait_us(1000000);
            return false;
        } else {
            printf("Couldn't connect: %d, will retry\n", ret);
            wait_us(1000000);
        }
    }

    printf("Fatal connection failure: %d\n", ret);
    wait_us(1000000);

    return false;
}

/** Connects to the Cellular Network */
bool resolve_hostname()
{

#if MBED_CONF_APP_SOCK_TYPE != NONIP
nsapi_error_t ret = _net.gethostbyname(ECHO_HOSTNAME, &_socket_address);

    if (ret != NSAPI_ERROR_OK) {
        printf("Couldn't resolve remote host: %s, code: %d\n", ECHO_HOSTNAME, ret);
        wait_us(1000000);
        return false;
    }

    _socket_address.set_port(MBED_CONF_APP_ECHO_SERVER_PORT);

#endif
return true;
}

bool connect_socket()
{

#if MBED_CONF_APP_SOCK_TYPE == TCP
nsapi_error_t ret = _socket.connect(_socket_address);
if (ret < 0) {
printf("TCPSocket.connect() fails, code: %d\n", ret);
wait_us(1000000);
return false;
} else {
printf("TCP: connected with %s server\n", ECHO_HOSTNAME);
wait_us(1000000);
}
#endif
return true;
}

nsapi_error_t send_test_data()
{
    const char *echo_string = "TEST";

#if MBED_CONF_APP_SOCK_TYPE == UDP
return _socket.sendto(_socket_address, (void*)echo_string, strlen(echo_string));
#else
return _socket.send((void*)echo_string, strlen(echo_string));
#endif
}

nsapi_error_t receive_test_data()
{
    char receive_buffer[4];

#if MBED_CONF_APP_SOCK_TYPE == UDP
return _socket.recvfrom(&_socket_address, (void*)receive_buffer, sizeof(receive_buffer));
#else
return _socket.recv((void*)receive_buffer, sizeof(receive_buffer));
#endif
}

private:
NetworkInterface &_net;

#if MBED_CONF_APP_SOCK_TYPE == TCP
TCPSocket _socket;
SocketAddress _socket_address;
#elif MBED_CONF_APP_SOCK_TYPE == UDP
UDPSocket _socket;
SocketAddress _socket_address;
#elif MBED_CONF_APP_SOCK_TYPE == NONIP
CellularNonIPSocket _socket;
#endif
};

int main() {
printf("\nmbed-os-example-cellular\n");
wait_us(1000000);

trace_open();

#if MBED_CONF_APP_SOCK_TYPE == NONIP
NetworkInterface *net = CellularContext::get_default_nonip_instance();
#else
NetworkInterface *net = CellularContext::get_default_instance();
#endif

if (net) {
    CellularDemo example(*net);
    example.run();
} else {
    printf("Failed to get_default_instance()\n");
    wait_us(1000000);
}

trace_close();

return 0;

}
`

Getting always this error
image

Tested in 4 modems

@paul-szczepanek-arm
Copy link
Member

Enabling tracing might help you diagnose the problem.

@tcpipchip
Copy link
Author

tcpipchip commented Jun 19, 2021

hi @paul-szczepanek-arm

weird that there that PPP CONNECTION is estabilshed, the DNS resolver work, make the SOCKET CONNECTION, but not send and receive.
To me, looks some UART problem, but i dont know what...
Something weird, because in the main.cpp, i had to include after each printf, and wait_us(1000000); otherwise, overrun on my uart receive
printf("Disconnect failed (error: %d).\n", ret);
wait_us(1000000);

Btw something is happeing in the MODEM UART too

If i enable the trace, i have the UART OVERRUN and i can see anything :(

Now i am testing on SARA G450 connected to a NINA B112 (NRF52832)

Do the PPP is using handshacking ?

Thanks!

@tcpipchip
Copy link
Author

Must i try to change to PAP or CHAP to works ?
Did you try already with NRF52 ?

@tcpipchip
Copy link
Author

Today i did try the AT mode
image
same problem
looks that the server is no ECHOing the my TEST data too :(
very very very weird

@tcpipchip
Copy link
Author

tcpipchip commented Jul 6, 2021

I found something very interesting!
If you put in

UBLOX_AT__celularStack.cpp the following instruction

 printf("%s\n","EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE");

UBLOX_AT_CellularStack::UBLOX_AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device) :
AT_CellularStack(atHandler, cid, stack_type, device)
{
// URC handlers for sockets

 printf("%s\n","EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE");

_at.set_urc_handler("+UUSORD:", callback(this, &UBLOX_AT_CellularStack::UUSORD_URC));
_at.set_urc_handler("+UUSORF:", callback(this, &UBLOX_AT_CellularStack::UUSORF_URC));
_at.set_urc_handler("+UUSOCL:", callback(this, &UBLOX_AT_CellularStack::UUSOCL_URC));
_at.set_urc_handler("+UUPSDD:", callback(this, &UBLOX_AT_CellularStack::UUPSDD_URC));

}

Blocks my UART (console)...

But....all AT commands sent to MODEM work perfectly now, i can see now the ECHO! See the picture

Can you give some tip about ?
image

If i remove the
printf("%s\n","EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE");
fail
image

By the. the parameter on printf must be a LONG string :( "EEEEEEEEEEEEEEEEEEEEEEEEEEEE.... and
"platform.stdio-buffered-serial": true,
to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants