我有以下代码:
char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
"<head><title>"
"DeckTone Server"
"</title></head>"
"<body>"
"<h3>Start page</h3>"
"<p>"
"Arduino UNO .<br />"
"Autor: DeckTone."
"</p>"
"</body>"
"</html>"
;
我有以下整数:
int a=2;
我在arduino上的webserver上的char正在提供以下代码:
if (ether.packetLoop(ether.packetReceive())) {
memcpy_P(ether.tcpOffset(), page, sizeof page);
ether.httpServerReply(sizeof page - 1);
memcpy_P(ether.tcpOffset(), page2, sizeof page2);
ether.httpServerReply(sizeof page2 - 1);
}
我想在char中添加以下整数a(以后的其他变量),以便下面的代码将发布此页面中包含的整数char。我的char示例将非常有用。
感谢您的帮助。
答案 0 :(得分:0)
由于char page []使用元素+1(对于终止符)创建了一个固定char,因此您不能轻松地添加一些内容。您可以在OPs HW(UNO 32k字节上的Flash存储器)上设计一个固定大小的数组,该数组足以接收其他数据并适合您的特定硬件(对于聪明的人,我数了他的示例文本,并添加了100,因为他想添加一些变量)。 .5k用于引导加载程序)
char page[320 + 100]
对于ESP8266 / ESP32(从1MB开始的闪存(通常为4Mb),您可以
char page[4048]
然后对其进行操作。