Open tcpipchip opened 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).
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
@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.
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
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!
getting more progresss! But i need some TIP
Here a link https://youtu.be/FVG1x1xtzto
I am not using handshaking! DNS is resolving!
Hi, i tried too other servers...got connection to the server, but cant send and receive data
some suggestion team ?
Sir Can you see if am i doing something wrong ? `/*
/ configuration choices in mbed_app.json /
static constexpr char SOCKET_TYPE[] = "TCP";
static constexpr char SOCKET_TYPE[] = "UDP";
static constexpr char SOCKET_TYPE[] = "CellularNonIP";
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: /**
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() {
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);
return true;
}
bool connect_socket() {
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);
}
return true;
}
nsapi_error_t send_test_data() { const char *echo_string = "TEST";
return _socket.sendto(_socket_address, (void*)echo_string, strlen(echo_string));
return _socket.send((void*)echo_string, strlen(echo_string));
}
nsapi_error_t receive_test_data() { char receive_buffer[4];
return _socket.recvfrom(&_socket_address, (void*)receive_buffer, sizeof(receive_buffer));
return _socket.recv((void*)receive_buffer, sizeof(receive_buffer));
}
private: NetworkInterface &_net;
TCPSocket _socket;
SocketAddress _socket_address;
UDPSocket _socket;
SocketAddress _socket_address;
CellularNonIPSocket _socket;
};
int main() { printf("\nmbed-os-example-cellular\n"); wait_us(1000000);
trace_open();
NetworkInterface *net = CellularContext::get_default_nonip_instance();
NetworkInterface *net = CellularContext::get_default_instance();
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
Tested in 4 modems
Enabling tracing might help you diagnose the problem.
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!
Must i try to change to PAP or CHAP to works ? Did you try already with NRF52 ?
Today i did try the AT mode same problem looks that the server is no ECHOing the my TEST data too :( very very very weird
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 ?
If i remove the printf("%s\n","EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"); fail
By the. the parameter on printf must be a LONG string :( "EEEEEEEEEEEEEEEEEEEEEEEEEEEE.... and "platform.stdio-buffered-serial": true, to work
Sir, How are you ? After config
I am getting the error
mbed-os-example-cellular Failed to get_default_instance()
Can you help me ?