0

How do i build a suitable string from an array of data values, that the ethercard library will accept to serve as a webpage? From the examples i have the below thus far, but i want to use an variable number of array elements (up to the limit of the packet buffer size).

static word homePage() {
  bfill= ether.tcpOffset();
  bfill.emit_p(PSTR(
    "HTTP/1.0 200 OK\r\n"
    "Content-Type: text/plain\r\n"
    "Pragma: no-cache\r\n"
    "\r\n"
    "$D\n"
    "$D\n"
    "$D\n"
    "$D\n"
    ), 
    data[0],data[1],data[2],data[3]
  );
  return bfill.position();
}

void loop() {
  if (ether.packetLoop(ether.packetReceive())) {
    ether.httpServerReply(homePage());
  }
}

I guess a side question is where do i learn about c strings, duh. (php guy).

1 Answer 1

0

static char strbuf[STR_BUFFER_SIZE+1];

bfill.emit_raw(strbuf, strlen(strbuf));

Sign up to request clarification or add additional context in comments.

1 Comment

I think more context is needed. Try explaining your answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.