cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F7 control by http page

Pilous Droip
Senior

Hi,

I would like to control my board with http page. I created test task:

void http_task(void *pvParameters) {
 
	struct netconn *client = NULL;
	struct netconn *nc = netconn_new(NETCONN_TCP);
 
	// check alloocation socket
	if (nc == NULL) {
		ErrPrint("Failed to allocate socket\n");
		vTaskDelete(NULL);
	}
 
	netconn_bind(nc, IP_ADDR_ANY, 80);
	netconn_listen(nc);
 
	char buf[512];
 
	while (1) {
		err_t err = netconn_accept(nc, &client);
		if (err == ERR_OK) {
			struct netbuf *nb;
			if ((err = netconn_recv(client, &nb)) == ERR_OK) {
				void *data;
				u16_t len;
				netbuf_data(nb, &data, &len);
				InfoPrint("Received data: %d - %s", len, (char*) data);
 
				snprintf(buf, sizeof(buf),
						"HTTP/1.1 200 OK\r\n"
						"Content-type: text/html\r\n\r\n"
						"Test");
				// odeslu page pryc
				netconn_write(client, buf, strlen(buf), NETCONN_COPY);
			}
			netbuf_delete(nb);
		}
 
		InfoPrint("Closing connection");
		netconn_close(client);
		netconn_delete(client);
 
		// necheme vsechen cas pro sebe
		vTaskDelay(1);
	}
}

And I call init here:

void Init_httpd(void) {
	xTaskCreate(http_task, "http_server", 1024, (void*) NULL, HTTPD_TASK_PRIORITY, NULL);
}

And I have a problem. When I try to connect board from web browser, I get this output from my console.

[28236][I][HTTPD--] Closing connection
[28238][D][ETHCORE] tcp_abandon: sending RST
[28238][D][ETHCORE] tcp_rst: seqno 6513 ackno 2629478690.
[28238][D][ETHCORE] tcp_listen_input: ACK in LISTEN, sending reset
[28238][D][ETHCORE] tcp_rst: seqno 6513 ackno 2629478690.
[28238][D][ETHCORE] tcp_listen_input: ACK in LISTEN, sending reset
[28238][D][ETHCORE] tcp_rst: seqno 6513 ackno 2629478691.
[28410][I][HTTPD--] Closing connection
[28412][D][ETHCORE] tcp_abandon: sending RST
[28412][D][ETHCORE] tcp_rst: seqno 6523 ackno 1470956517.
[28412][D][ETHCORE] tcp_listen_input: ACK in LISTEN, sending reset
[28412][D][ETHCORE] tcp_rst: seqno 6523 ackno 1470956517.
[28412][D][ETHCORE] tcp_listen_input: ACK in LISTEN, sending reset
[28413][D][ETHCORE] tcp_rst: seqno 6523 ackno 1470956518.
[30315][I][HTTPD--] Closing connection

Any idea, why is send RST?

I use: lwIP, FreeRTOS

And I have implement sntp client. And it works very well.

1 REPLY 1
O. Mz. - 7
Associate III

I use a different approach on the board STM32 NUCLEO F767ZI. It is described in these three videos: https://youtu.be/cYynDc82g4w