コード例 #1
0
ファイル: tcp.c プロジェクト: GerarDZG/Embedded-Systems
uint8_t process_request(TCP_CONFIG *config)
{
	uint16_t bytes_to_send =0;
	uint8_t rets=0;

	if(bytesReceived>tcp_data_buffer_size)
		return 0; // Content overflow

	// Assuming GIT request, read and parse if you with to use urls for anything
	recv_data_processing(config->s, tcp_data_buffer, bytesReceived); // Data from the GIT request
	sprintf(website,"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n\
			<html>\n<head>\n<center><h1>%d</h1></center>\n<meta http-equiv=\"refresh\" content=\"1.5\" >",ADCRead(0));

	bytes_to_send = strlen((char *)website);
	rets = send(config->s, website,bytes_to_send , 0); // Send Response with html
	bytesReceived=0;

	IINCHIP_WRITE(Sn_CR(config->s), Sn_CR_DISCON); 	// Shut down connection
	while (IINCHIP_READ(Sn_CR(config->s)));			//
	IINCHIP_WRITE(Sn_CR(config->s), Sn_CR_CLOSE);	//
	while (IINCHIP_READ(Sn_CR(config->s)));			//
	IINCHIP_WRITE(Sn_IR(config->s), 0xFF);			//

	return 1;
}
コード例 #2
0
ファイル: socket.c プロジェクト: ATMEGA17/tinkerit
/**
@brief	This function is an application I/F function which is used to receive the data in TCP mode.
		It continues to wait for data as much as the application wants to receive.
		
@return	received data size for success else -1.
*/ 
uint16 recv(
	SOCKET s,	/**< socket index */
	uint8 * buf,	/**< a pointer to copy the data to be received */
	uint16 len	/**< the data size to be read */
	)
{
#ifdef __DEF_IINCHIP_DBG__
	printf("recv()\r\n");
#endif
	if ( len > 0 )
	{
		recv_data_processing(s, buf, len);
	}
	return len;
}