I’m using an external sim card with which I have use the command line cm data connect and use netcat to reach my server correctly,
however when I try to create an app that uses le_data API it indicates the connection is stablished but cant reach my server.
I have tried these things:
1.- Remove le_data API from my application. Start the connection with command line cm data connect, then start my app just to verify that application can reach my server which is done correctly.
2.- Remove the code that connects with my server and just use le_data API. Use cm data to verify the state of the connection which it says is connected, but it behaves as if it were not. Any attempt to reach my server or any other results in an error, either with the application code (commented) or with ping in the command line interface.
root@swi-mdm9x28-wp:~# cm data
Index: 1
APN: internet.itelcel.com
PDP Type: IPV4V6
Connected: yes
Auth type: PAP
User name: webgpr
Password: webgprs2002
Interface: rmnet_data0
Family[IPv4]: inet
IP[IPv4]: 10.82.150.48
Gateway[IPv4]: 10.82.150.49
Dns1[IPv4]: 10.182.35.36
Dns2[IPv4]: 10.233.16.4
root@swi-mdm9x28-wp:~# ping google.com
ping: bad address ‘google.com’
root@swi-mdm9x28-wp:~# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
ping: sendto: Network is unreachable
root@swi-mdm9x28-wp:~#
(1) happens with this code:
COMPONENT_INIT
{
int status;
LE_INFO("test init");
socketFd = socket(AF_INET,SOCK_STREAM,0);
if (socketFd == -1)
{
LE_INFO("socket creation failed...\n");
return;
}
else
{
LE_INFO("Socket successfully created..\n");
}
memset(&servaddr,0, sizeof(servaddr));
// assign IP, PORT
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = inet_addr(SERVER_ADDR);
servaddr.sin_port = htons(MYPORT);
// connect the client socket to server socket
status = connect(socketFd, (SA*)&servaddr, sizeof(servaddr));
if (status != 0)
{
LE_INFO("connection with the server failed... %d \n",status);
return;
}
else
{
LE_INFO("connected to the server..\n");
}
memset(dataRx,0,100);
read(socketFd, dataRx, 100);
LE_INFO("Received data: %s", dataRx);
}
(2) happens with this code:
static bool WaitingForConnection;
static le_data_RequestObjRef_t ConnectionRef;
static void TimeoutHandler(le_timer_Ref_t timerRef)
{
if (WaitingForConnection)
{
LE_ERROR("Couldn't establish connection after " STRINGIZE(TIMEOUT_SECS) " seconds");
exit(EXIT_FAILURE);
}
}
static void ConnectionStateHandler(const char *intfName,bool isConnected,void *contextPtr)
{
if (isConnected)
{
LE_INFO("Connected!\n");
/*
int status;
WaitingForConnection = false;
socketFd = socket(AF_INET,SOCK_STREAM,0);
if (socketFd == -1)
{
LE_INFO("socket creation failed...\n");
return;
}
else
{
LE_INFO("Socket successfully created..\n");
}
memset(&servaddr,0, sizeof(servaddr));
// assign IP, PORT
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = inet_addr(SERVER_ADDR);
servaddr.sin_port = htons(MYPORT);
// connect the client socket to server socket
status = connect(socketFd, (SA*)&servaddr, sizeof(servaddr));
if (status != 0)
{
LE_INFO("connection with the server failed... %d \n",status);
return;
}
else
{
LE_INFO("connected to the server..\n");
}
memset(dataRx,0,100);
read(socketFd, dataRx, 100);
LE_INFO("Received data: %s", dataRx);
*/
}
}
COMPONENT_INIT
{
le_timer_Ref_t timerPtr = le_timer_Create("Connection timeout timer");
le_clk_Time_t interval = {TIMEOUT_SECS, 0};
le_timer_SetInterval(timerPtr, interval);
le_timer_SetHandler(timerPtr, &TimeoutHandler);
WaitingForConnection = true;
le_timer_Start(timerPtr);
LE_INFO("test init");
le_data_AddConnectionStateHandler(&ConnectionStateHandler, NULL);
LE_INFO("Requesting connection...");
ConnectionRef = le_data_Request();
}
does any one knows what the problem can be?, any help is really appreciated.