PDP context and the Socket Connection


#1

Hi forum,

Can any one help me:
1. How to activate OR deactivate the PDP context by using an application?
2. How to open a remote connection via socket by using an application?

Thanks in advance.


#2

I try to send a test message to the server but failed, see the code below:

#include"legato.h"
#include"interfaces.h"

#include <netinet/in.h>
#include <arpa/inet.h>



void upd_client(void)
{
	int client_sockfd;
	int len;
	struct sockaddr_in remote_addr;	//remote address 
	//int sin_size;
	char buf[BUFSIZ];				//transmit buffer
	memset(&remote_addr,0,sizeof(remote_addr));	//clearing
	remote_addr.sin_family = AF_INET;			// IP
	remote_addr.sin_addr.s_addr = inet_addr("xxx.yyy.net");	// remote address IP
	remote_addr.sin_port = htons(9006);			//remote port

	 /* Create socket: IPv4,UDP */
	if((client_sockfd=socket(PF_INET,SOCK_DGRAM,0))<0)
	{
		//
		perror("socket");
	}
	strcpy(buf,"This is a test message for 4G");
	//sin_size = sizeof(struct sockaddr_in);
	 /*send message to remote host*/
	if((len=sendto(client_sockfd,buf,strlen(buf),0,(struct sockaddr *)&remote_addr,sizeof(struct sockaddr)))<0)
	{
		perror("recvfrom");
	}
	close(client_sockfd);
}

the output ERROR logs:

Jan 6 00:07:49 | =ERR= | clientExe[2268] | recvfrom: Network is unreachable

Can you help me? Thank you.

Regards!


#3

Hi,
I think, there is a bug. I have got the same problem.
I set up GPRS correctly.
I called function le_data_Request() - handler returns “Connected”.
Function le_data_GetTechnology() returns LE_DATA_CELLULAR.
But when I try to open socket, I have got “Network is unreachable”.
If I release handler using le_data_Release (HandleDataRequest), I have got WIFICLIENT DISCONNECT.

System tries to connect to my server via WIFI.
When call le_data_Request() again, system uses GPRS and I can send message to my server.
So basically I have to call le_data_Request() twice

			le_data_RequestObjRef_t HandleDataRequest = le_data_Request();
			le_data_Release (HandleDataRequest);
			HandleDataRequest = le_data_Request(); 

I have tried to change Technology rank ( le_data_SetTechnologyRank ) but no effect.


#4

Which version are you running @TheGod ?

Looks like you’re getting a “Connected” notification while it is still going through available technologies.
One thing you can do to make WiFi not available is uninstall wifiService.


#5

Hi,
I use version 16.10.3. Yes, I get “Connected”, le_data_GetTechnology() returns LE_DATA_CELLULAR (Not LE_DATA_WIFI) and it is also correct. But “Network is unreachable” when I try to connect to a server. If I call le_data_Release (HandleDataRequest);, I have got message about WiFi. I use mangoH Green and I don’t have WiFi on it, so I cannot be connected to WiFi :slight_smile:. Also I should not get “WIFICLIENT DISCONNECTED” in my opinion.

In other words, system tells me, that everything is ok and I am connected to the network via GPRS, but I cannot send data.

If it goes through available technologies and WiFi is first (le_data_SetTechnologyRank should be respected but it is not). I shoud get message discconnected and le_data_GetTechnology() == LE_DATA_WIFI. I would know, system tried to connected to WiFi and failed. Information from the system right now is misleading.

I could try to uninstall wifiservice, but I am going to use it in the near future as well. I don’t think it is good solution for the issue.


#6

Well that’s a bit of a mess.
Could you try with a more recent version of Legato by any chance, such as 17.09.0?


#7

Hi,
It is pointless. You have answered my previous thread

When I stopped wifiService, nothing has changed. I still had to call le_data_Request(); twice. I did not have messages about WiFi, it was only difference.