Bg95 listen on an IP address and ping from windows

I am trying to listen on an IP address on the BG95. I got the static IP and gateway including netmasks but I am unable to reach the address. Could you please share an example of a successful listener and how I can ping it from windows and how to properly decide the IP address to listen to

Can you provide your examples or screenshots?

Thanks for your reply.

Below is a code snippet of I have written to get the ip address. I am using qapi_listen to listen:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ret = qapi_DSS_Get_IP_Addr_Count(_tcp_dss_handle, &len);
if (ret != 0)
{
UART_DEBUG(“%s Get IP address count error\n”, FUNCTION);
goto END;
}

ret = qapi_DSS_Get_IP_Addr(_tcp_dss_handle, info_ptr, len);
if (ret != 0)
{
	UART_DEBUG("%s Get IP address error\n", __FUNCTION__);
	goto END;
}

j = GET_ADDR_INFO_MIN(len, DSS_ADDR_INFO_SIZE);

memset(deviceaddr, 0x00, sizeof(device_addr_t));
for (i = 0; i < j; i++)
{
	UART_DEBUG("%s <--- static IP address information --->\n", __FUNCTION__);
	_tcp_inet_ntoa_addr(&info_ptr[i].iface_addr_s, lbuff, DSS_ADDR_SIZE);
	memcpy(deviceaddr->ipaddr, lbuff, DSS_ADDR_SIZE);
	UART_DEBUG("%s static IP: %s\n", __FUNCTION__, deviceaddr->ipaddr);

	_tcp_inet_ntoa(info_ptr[i].iface_mask, lbuff, DSS_ADDR_SIZE);
	UART_DEBUG("%s IP mask: %s\n", __FUNCTION__, lbuff);

	memset(lbuff, 0, sizeof(lbuff));
	_tcp_inet_ntoa_addr(&info_ptr[i].gtwy_addr_s, lbuff, DSS_ADDR_SIZE);
	memcpy(deviceaddr->gateway, lbuff, DSS_ADDR_SIZE);
	UART_DEBUG("%s Gateway IP: %s\n", __FUNCTION__, deviceaddr->gateway);

	
	_tcp_inet_ntoa(info_ptr[i].gtwy_mask, lbuff, DSS_ADDR_SIZE);
	UART_DEBUG("%s Gateway mask: %s\n", __FUNCTION__, lbuff);

	memset(lbuff, 0, sizeof(lbuff));
	_tcp_inet_ntoa_addr(&info_ptr[i].dnsp_addr_s, lbuff, DSS_ADDR_SIZE);
	UART_DEBUG("%s Primary DNS IP: %s\n", __FUNCTION__, lbuff);

	memset(lbuff, 0, sizeof(lbuff));
	_tcp_inet_ntoa_addr(&info_ptr[i].dnss_addr_s, lbuff, DSS_ADDR_SIZE);
	UART_DEBUG("%s Second DNS IP: %s\n", __FUNCTION__, lbuff);
}

//Also, the following is used for decoding the ip:

int32 _tcp_inet_ntoa
(
uint32_t inaddr, /* IPv4 address to be converted /
char
buf, /* Buffer to hold the converted address /
int32 buflen /
Length of buffer /
)
{
uint8_t
paddr = (uint8_t*)&inaddr;
int32 rc = 0;

if ((NULL == buf) || (0 >= buflen))
{
	rc = -1;
}
else
{
	if (-1 == snprintf((char*)buf, (unsigned int)buflen, "%d.%d.%d.%d",
		paddr[0],
		paddr[1],
		paddr[2],
		paddr[3]))
	{
		rc = -1;
	}
}

return rc;

} /* tcp_inet_ntoa() */

/*
@func
tcp_inet_ntoa
@brief
utility interface to translate ip from “int” to x.x.x.x format.
*/

int32 _tcp_inet_ntoa_addr
(
const qapi_DSS_Addr_t* inaddr, /* IPv4 address to be converted /
char
buf, /* Buffer to hold the converted address /
int32 buflen /
Length of buffer */
)
{
int32 rc = _tcp_inet_ntoa(inaddr->addr.v4, buf, buflen);

return rc;

} /* tcp_inet_ntoa_addr() */
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Thanks in advance.

Regards,
Sebastian

Can you provide the IP and gateway that you have successfully acquired?

The IP and gateway keep changing whenever I restart the module. However below is the latest info:.
IP: 10.226.74.43
Netmask: 255.255.255.248
Gateway: 10.226.74.44
Primary DNS: 194.204 159.1
Secondary DNS: 194.204.152.34

Can you tell me your area? China or any other country?

I am in Poland. I am using an Orange flex Sim card. Perhaps you can recommend a Sim card provider that allows inward connections?

Your case is also common in China and is usually solved in the following ways:
You need to experiment with two modules
Modules A and B need to camp on the same base station cell and obtain the same address segment IP
such as A IP:10.226.74.43,B IP:10.226.74.55
A ping to B or B ping to A
you try

Thanks Herbert. I can try this later but I am under time pressure. So what I will do since I can connect from the module to authenticate to the server is to ask the module to connect and create another listener on the server. Then the server can always post the commands to the module when there is any .

Module or terminal to the server must be able to communicate normally

This is a private IP address, so you’re either behind a NAT or you use your own APN with a tunnel. With NAT a common way to communicate is that you first send a packet to the server and then you can use the source IP address and port to reply, for a limited time (e.g. 1 minute). The IP you’ll see on the server is different from what the module reports, because of NAT.

Yes it is true I already was able to connect from module to server do I will use this feature to solve the problem as described previously.

Thanks Rastislav for making me aware of NAT operations. Because I need to be energy efficient Now what I can do is to instead connect from the module to the server and check a letterbox for any pending commands instead of listening on an IP address on the module so that the server can send me a command with the added advantage that I can scale to many types of LTE networks that allow outbound traffic.