MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / http_recv

Function http_recv

bsp/efm32/httpd.c:119–200  ·  view source on GitHub ↗

Private function prototypes -----------------------------------------------*/ Private functions ---------------------------------------------------------*/ This is the callback function that is called * when a TCP segment has arrived in the connection. */

Source from the content-addressed store, hash-verified

117/* This is the callback function that is called
118 * when a TCP segment has arrived in the connection. */
119static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
120{
121 static unsigned char temp_var = 0;
122 unsigned short counter, i;
123 char *rq;
124 /* If we got a NULL pbuf in p, the remote end has closed
125 * the connection. */
126 if (p != NULL)
127 {
128 /* The payload pointer in the pbuf contains the data
129 * in the TCP segment. */
130 rq = p->payload;
131 /* Check if the request was an HTTP "GET / HTTP/1.1". */
132 if (rq[0] == 'G' && rq[1] == 'E' && rq[2] == 'T')
133 {
134 /* Send the web page to the remote host. A zero
135 * in the last argument means that the data should
136 * not be copied into internal buffers. */
137
138 counter = 0;
139
140 for (i = 0; i < sizeof(indexdata1) - 1; i++)
141 {
142 indexdata[counter] = indexdata1[i];
143 counter++;
144 }
145
146 indexdata[counter] = ' ';
147 counter++;
148
149 /*Copy page counter MSB*/
150 indexdata[counter] = temp_var / 10 + 0x30;
151 counter++;
152
153 /*Copy page counter LSB*/
154 indexdata[counter] = temp_var % 10 + 0x30;
155 counter++;
156
157 temp_var++;
158 if (temp_var > 100) temp_var = 1;
159
160 for (i = 0; i < sizeof(indexdata2) - 1; i++)
161 {
162 indexdata[counter] = indexdata2[i];
163 counter++;
164 }
165
166 vdd = rt_hw_get_vdd();
167 rt_sprintf(&indexdata[counter], "%1d.%02d", vdd / 100, vdd % 100);
168 counter += 4;
169
170 for (i = 0; i < sizeof(indexdata3) - 1; i++)
171 {
172 indexdata[counter] = indexdata3[i];
173 counter++;
174 }
175
176 temp = rt_hw_get_temp();

Callers

nothing calls this directly

Calls 6

rt_hw_get_vddFunction · 0.85
rt_sprintfFunction · 0.85
rt_hw_get_tempFunction · 0.85
tcp_writeFunction · 0.50
pbuf_freeFunction · 0.50
tcp_closeFunction · 0.50

Tested by

no test coverage detected