I think I also found a bug in WiFI_RN171:
If the buffer is larger than baudrate then it sends in chunks, but …
/// <summary>
/// Send data to the currently connected client
///
/// </summary>
/// <param name="data">Data</param>
public void Send(byte[] data)
{
if (data.Length <= this._wifly.BaudRate)
{
this._wifly.Write(data, 0, data.Length);
}
else
{
int baudRate = this._wifly.BaudRate;
int num = data.Length / baudRate;
int count = data.Length % baudRate;
for (int index = 0; index < num; ++index)
{
int offset = index * baudRate;
this._wifly.Write(data, offset, baudRate);
if (index == num - 1 && count > 0)
this._wifly.Write(data, offset, count); // this line is wrong I think
// should be
//this._wifly.Write(data, offset + baudRate, count);
}
}
}
If the offset is not increased by baudRate to send the remaining data, the final chunk will be a partial repetition of the previous chunk.
anyway: checking if this is the last complete chunk inside the loop is quite ineffective.
Also recalculating the offset with a multiplication could be replaced by a more simple addition.
But to come back to the original problem.
The number of bytes sent should be right.
Only the last bit of the data is wrong if the buffer is larger than baud rate.