Exemplo n.º 1
0
void http_server(void *pdata) {
	struct netconn *HTTPNetConn = NULL, *xHTTPNetConn;
	err_t rc1;
	if (xSemaphoreTake(xDhcpCmplSemaphore_2, portMAX_DELAY) == pdTRUE) {

		/* Create a new TCP connection handle */
		HTTPNetConn = netconn_new(NETCONN_TCP);
//		netconn_set_recvtimeout(HTTPNetConn, 100);
		if (HTTPNetConn == NULL) {
			/*No memory for new connection? */
			UART_PrintStr("No mem for new HTTP con\r\n");
		}
		/* Bind to port 80 (HTTP) with default IP address */
		netconn_bind(HTTPNetConn, NULL, 80);

		/* Put the connection into LISTEN state */
		netconn_listen(HTTPNetConn);

		while (1) {
			rc1 = netconn_accept(HTTPNetConn, &xHTTPNetConn);
			if(rc1 == ERR_OK){
//				http_server_serve(xHTTPNetConn);
				UART_PrintStr("netconn accept\r\n");
				netconn_close(xHTTPNetConn);
				netconn_delete(xHTTPNetConn);
			}else{
				PrintERR(rc1);
			}
		}
	}
	while (1)
		vTaskDelay(1000/portTICK_RATE_MS);
}
Exemplo n.º 2
0
/* Print data over UART */
void UART_PrintData(unsigned char *data, unsigned int n)
{
	char str[16];

	UART_PrintStr("[ ");
	while (n--) {
		sprintf(str, "%d ", *data++);
		UART_PrintStr(str);
	}
	UART_PrintStr("]\r\n");
}
Exemplo n.º 3
0
void  UART_Printf (uint8_t *format, ...)
{
    static char  buffer[40 + 1];
    va_list     vArgs;


    va_start(vArgs, format);
    vsprintf((char *)buffer, (const char *)format, vArgs);
    va_end(vArgs);
    UART_PrintStr((uint8_t*) buffer);
}
Exemplo n.º 4
0
/* Main routine */
int main(void)
{
	/* Hardware initialization */
	RCC_Configuration();
	GPIO_Configuration();
	#ifdef DEBUG
	USART_Configuration();
	#endif

	LED2_ON;

	UART_PrintStr("Hello!\r\n");

    while(1)
    {
    	LED1_ON;
    	delay(1000);
    	LED1_OFF;
    	delay(1000);
    }
}