Example #1
0
/**
* Internal utils
*/
static void connect()
{
	respHeader[0]='\0';
	respBody[0]='\0';

	socket = TCPClientOpen(EVRYTHNG_API_HOST, EVRYTHNG_API_PORT);	
	while(!TCPisConn(socket))
    {
		vTaskDelay(30);
		_dbgwrite(".");
    }
	_dbgwrite("\r\nTCP connection OK\r\n");
		
	TCPSSLStart(socket);
	char buff[100];
	sprintf(buff, "SSL stat: %d\r\n", TCPSSLStatus(socket));
	_dbgwrite(buff);
	while(TCPSSLStatus(socket) == 1);
	sprintf(buff, "SSL stat: %d\r\n", TCPSSLStatus(socket));		
	_dbgwrite(buff);
	
}
TCP_SOCKET XivelyConn(char* ServerName, char* ServerPort)
{
	int j;
	TCP_SOCKET   MySocket = INVALID_SOCKET;
	#if defined(STACK_USE_UART)
	UARTWrite(1,"Connecting to Xively...\r\n");
	#endif
	MySocket = TCPClientOpen(ServerName, ServerPort);
	
	#if defined(STACK_USE_UART)
	if(MySocket == INVALID_SOCKET) 
	{
		UARTWrite(1,"INVALID_SOCKET\r\n");
	}
	UARTWrite(1,"Checking connection.\r\n");
	#endif
	// Make sure it connects
	j = 10;
	while (j>0 && !TCPisConn(MySocket))
	{
		//vTaskDelay(xDelay(500));
		vTaskDelay(500);
		j--;
		//sprintf(j, "%d\r\n", j+1);
	}
	if(j==0) 
	{
		#if defined(STACK_USE_UART)
		UARTWrite(1,"Connection failed.\r\n");
		#endif
		// Close the socket so it can be used by other modules
		TCPClientClose(MySocket);
		MySocket = INVALID_SOCKET;
		// We are in an error condition, so light up the Flyport led
	}
	return MySocket;
}
Example #3
0
/**
 * Verifies the connection of a remote FTP device with the socket.
 * \param sockcon - The handle of the socket to control (the handle returned by the command FTPOpen).
 * \return TRUE - The remote connection is established.
 * \return FALSE - The remote connection is not established.
 */
BOOL FTPisConn(TCP_SOCKET sockcon)
{
	return TCPisConn(sockcon);
}