ARMmbed / mbed-os-example-cellular

This is an example based on mbed-os cellular APIs that demonstrates a TCP or UDP echo transaction with a public echo server.
Apache License 2.0
21 stars 44 forks source link

u-blox Nina b112 error + Sara G350 #222

Open tcpipchip opened 3 years ago

tcpipchip commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

getting more progresss! But i need some TIP image

tcpipchip commented 3 years ago

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

I am not using handshaking! DNS is resolving!

tcpipchip commented 3 years ago

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

some suggestion team ?

tcpipchip commented 3 years ago

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

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: /**

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 commented 3 years ago

Enabling tracing might help you diagnose the problem.

tcpipchip commented 3 years ago

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 commented 3 years ago

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

tcpipchip commented 3 years ago

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 commented 3 years ago

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