0

我有以下代码:

   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 上的网络服务器上的 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);
  }

我想将以下整数 a (将来也会添加其他变量)添加到 char 中,因此以下代码将发布包含在此页面 char 中的整数。我的 char 示例将非常有帮助。

谢谢你的帮助。

4

1 回答 1

0

由于 char page[] 创建了一个带有元素 +1 的固定字符(用于终止符),因此您无法轻松地向其中添加一些内容。您可以在 OPs HW(UNO 上的闪存 32k 字节(其中 .5k 用于引导加载程序)

    char page[320 + 100]

对于 ESP8266 /ESP32(闪存以 1MB 开始,通常为 4Mb,您可以使用

    char page[4048] 

然后对其进行操作。

于 2020-03-22T10:54:55.540 回答