err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err)
{
// This function is called after TCP/IP connection establishment
tcp_recv(pcb, http_receive);
return ERR_OK;
}
err_t http_receive(void * arg, struct tcp_pcb * tpcb, struct pbuf * p, err_t err)
{
char *rq;
if (p != NULL)
{
rq = p->payload;
if (rq[0] == 'G' && rq[1] == 'E' && rq[2] == 'T' && rq[3] == ' ')
{
tcp_sent(tpcb, http_sent); // http_sent never gets called
tcp_write(tpcb, htmlText, sizeof(htmlText), 0);
}
tcp_recved(tpcb, p->len);
pbuf_free(p);
}
return ERR_OK;
}