BG96. TCP Client demo fails on connect

So, moving forward got to data sending from device and got stuck.
I used example from BG96MAR04A03M1G_02.003.01.003 , tcp_client. It starts well, initializes DDS, sent APN and receive IP. But on connection it fails. No matter what server I put to DEF_SRV_ADDR and port to DEF_SRV_PORT. Here is log dropped to debug uart. (Btw, tried to get errno function and it returns 2 regardless I tried to connect existing or not existing server).

Any ideas ?

[2019-12-16_20:53:14:297] TCPClient Task Start…
[2019-12-16_20:53:25:456]Initializes the DSS netctrl library
[2019-12-16_20:53:25:472]DSS netctrl library has been initialized.
[2019-12-16_20:53:25:502]Registering Callback tcp_dss_handle
[2019-12-16_20:53:25:502]tcp_dss_handle -177785049, status 0
[2019-12-16_20:53:25:502]Registed tcp_dss_handler success
[2019-12-16_20:53:25:518]Setting tech to Automatic
[2019-12-16_20:53:25:518]Setting APN - CMNET
[2019-12-16_20:53:25:534]Setting family to IPv4
[2019-12-16_20:53:25:550]qapi_DSS_Start_Data_Call start!!!.
[2019-12-16_20:53:25:566]Start Data service success.
[2019-12-16_20:53:28:907]Data test event callback, event: 1
[2019-12-16_20:53:28:923]Data Call Connected.
[2019-12-16_20:53:28:951]<— static IP address information —>
[2019-12-16_20:53:28:951]static IP: 10.141.131.65
[2019-12-16_20:53:28:951]Gateway IP: 10.141.131.66
[2019-12-16_20:53:28:967]Primary DNS IP: 81.95.167.65
[2019-12-16_20:53:28:967]Second DNS IP: 81.95.167.66
[2019-12-16_20:53:28:983]<— End of system info —>
[2019-12-16_20:53:28:999]SIGNAL EVENT IS [4]
[2019-12-16_20:53:28:999]DSS_SIG_EVT_CONN_E Signal
[2019-12-16_20:53:29:015]<-- Create socket[16385] success -->
[2019-12-16_20:53:29:031]Connect to servert error

Connect to servert error??? result?

IP or host name?
and try google DNS 8.8.8.8 and 8.8.4.4

No specific error code.
/* Connect to TCP server */
if (-1 == qapi_connect(sock_fd, (struct sockaddr *)&client_addr, sizeof(client_addr)))
{
TCP_UART_DBG(“Connect to servert error\n”);
break;
}
Tried google and my terminal server (which is 100% accessible, rechecked from phone).

int res = qapi_connect( … )
TCP_UART_DBG("[ERR] %d", res)

ups - there is no error

Yea. -1 or all is fine :slight_smile:

int qapi_errno(int32_t handle);

Returns always 2, no matter what IP I use as server.
And I was unable to find corresponding error meaning :confused:

qapi_socket.h
#define ETIMEDOUT 2 /**< Operation timed out */

Oh, thanks! But gives no information…

I am not sure if that is some regional issue ?
Here is LTE, but not M1.

you have static LOCAL_IP … connection to provider is OK
check result from inet_addr() and _htons()

1 Like

and try HTTP demo if work … connection is ok

Http failed too
[2019-12-16_23:02:49:687] HTTP Task Start…
[2019-12-16_23:03:04:764]host:www.yaplakal.com,port:80,source:/forum3/topic1806272.html
[2019-12-16_23:03:04:812]Initializes the DSS netctrl library

[2019-12-16_23:03:04:876]DSS netctrl library has been initialized.

[2019-12-16_23:03:04:923]Registering Callback http_dss_handle

[2019-12-16_23:03:04:971]http_dss_handle 1879824597, status 0

[2019-12-16_23:03:05:019]Registed http_dss_handler success

[2019-12-16_23:03:05:067]Setting tech to Automatic

[2019-12-16_23:03:05:115]Setting APN - CMNET

[2019-12-16_23:03:05:163]Setting family to IPv4

[2019-12-16_23:03:05:227]qapi_DSS_Start_Data_Call start!!!.

[2019-12-16_23:03:05:291]Start Data service success.

[2019-12-16_23:03:07:721]Data test event callback, event: 1

[2019-12-16_23:03:07:769]Data Call Connected.

[2019-12-16_23:03:07:817]<— static IP address information —>

[2019-12-16_23:03:07:865]static IP: 10.109.60.244

[2019-12-16_23:03:07:929]Gateway IP: 10.109.60.245

[2019-12-16_23:03:07:977]Primary DNS IP: 81.95.167.65

[2019-12-16_23:03:08:025]Second DNS IP: 81.95.167.66

[2019-12-16_23:03:08:073]<— End of system info —>

[2019-12-16_23:03:08:121]dss_event:4
[2019-12-16_23:07:15:110]qapi_Net_HTTPc_Connect ERROR ret:-3, re-connect times:1

will try ftp now. In parallel asking coworker in US to check his side

Well, that becomes more interesting.
In FTP there is network check (which was not in other samples)

FTP_UART_DBG("FTP Task Start...\n");
qapi_Device_Info_Init();

do
{
	qapi_Timer_Sleep(200, QAPI_TIMER_UNIT_MSEC, true);
	memset(&info,  0x00, sizeof(qapi_Device_Info_t));
	qapi_Device_Info_Get(QAPI_DEVICE_INFO_SERVICE_STATE_E, &info);
	if(info.u.valueint == 0)
	{
		network_enabled = false;
			FTP_UART_DBG("False...\n");
	}
	else
	{
		network_enabled = true;
	}
}while(!network_enabled);

False message I added to see in log. So it never go out of this cycle. But from AT port I see there is network registration and so on…

[2019-12-16_23:17:18:000]AT+CREG?

[2019-12-16_23:17:18:000]+CREG: 2,1,“328”,“17CB”,3

[2019-12-16_23:17:18:000]OK
[2019-12-16_23:17:27:931]AT+COPS?

[2019-12-16_23:17:27:932]+COPS: 0,0,“MAGTI-GSM-GEO MAGTICOM1”,3

[2019-12-16_23:17:27:932]OK
[2019-12-16_23:17:36:143]AT+CSQ

[2019-12-16_23:17:36:143]+CSQ: 19,99

[2019-12-16_23:17:36:143]OK

Got lost a bit :confused:

Checked TCP_Client demo from US - works… What a sad I can’t test app right here…

Ok, looks solved, different network OP worked well

sure for SIM card and access to network
APN?

Yes, checked with another device and it was sending data.

Now facing different issue. Other sim send data over TCP, that’s fine. But I want to implement network check before initializing connect. But when I request device info with QAPI_DEVICE_INFO_SERVICE_STATE_E - I always get 0… And that not only here, in US same.