向char Arduino添加新参数

问题描述 投票:0回答:1

我有以下代码:

   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上的Web服务器上的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的示例将非常有帮助。

感谢您的帮助。

c char int arduino lan
1个回答
0
投票

因为char page []创建了一个带有元素+1(对于终止符)的固定char,所以您不能轻松地添加一些内容。您可以在OPs HW(UNO 32k字节上的Flash存储器)上设计一个固定大小的数组,该数组足以接收其他数据并适合您的特定硬件(对于聪明的人,我数了他的示例文本,并添加了100,因为他想添加一些变量)。 .5k用于引导程序)

    char page[320 + 100]

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

    char page[4048] 

然后对其进行操作。

© www.soinside.com 2019 - 2024. All rights reserved.