I’ve got the following code to send buffered data to a server with the W5500. It uses the standard ioLibrary
socket functions.
// runs every 1 second
send_data(void) {
// data payload
uint8_t payload[32];
sprintf(payload, "%.2f,%.2f,%.2f,%u", env_t, env_p, env_h, env_l);
// open socket number 1
socket(1, Sn_MR_TCP, NULL, NULL);
// connect to the server
connect(1, dest_ip, dest_port);
// send payload
send(1, payload, strlen(payload));
}
Variables env_t
, env_h
, etc. are sensor values measured elsewhere in the code. The dest_ip
and dest_port
variables are the destination server details.
As it is shown above, the program works. However, if I increase the payload
buffer size higher (e.g. to 64) in order to make the payload larger, the program no longer works (no serial output, no network activity). I know that ioLibrary
checks the size of the provided buffer against its TX buffer size, but that is set to 2048 bytes, so it shouldn’t be a problem.
In my initialisation code I set the TX buffer size to 2kB:
uint8_t wiznet_buf_size[] = {2, 2, 2, 2, 2, 2, 2, 2};
wizchip_init(wiznet_buf_size, wiznet_buf_size);
Have I done something silly here?