WiFiLink UDP problem on Arduino UNO+WiFi

Hi Folks,

I have a strange behaviour on using WiFiUDP with WiFiLink Firmware.

First, WiFiLink UDP-Lib V1.0.1 has a major bug in WiFiUDP.cpp. "availUdpData" has to be decreased in function "read(xxx)" by the actual read bytes. Scanning this class I think there are some other bugs but they dont affect my program.

My problem starts answering a status request UDP-package. I reserved an array of 48 bytes for building the UDP-packet. As long as I only use local variables, everything is fine.
But I have a global configuration class instance. If I try to add some values of the configuration into he packet, all values become zero. I have no clue why.

Here is the code snippet:

// Sendet das vollständige Statuspaket
void UdpService::SendStatusUdpPackage(IPAddress& addr, uint16_t port, Konfiguration* cfg)
{
// Temperatur und Feuchtigkeit
uint16_t temperatur = 0;
uint16_t hum = 0;

// alle Bytes im Puffer auf NULL
memset(_packetBuffer, 0, CPE_SW_PACKET_SIZE);

// Paket-Daten setzen für Funktion "CPE-SW#2017"
sprintf((char *)_packetBuffer, "CPE-SW#2017");

// Funktion = Status
_packetBuffer[12] = UdpFunctionCode::Status;

// Daten holen
temperatur = temp.GetValues(&hum);

// Feuchtigkeit
WriteUint16_t(_packetBuffer, 21, hum);

// Temperatur
WriteUint16_t(_packetBuffer, 23, temperatur);

// Lichtsensor
WriteUint16_t(_packetBuffer, 25, LastAnalogInputA0);

// und das Flag
_packetBuffer[27] = firmware.GetStatus();

// die anderen Werte
for (int i = 0; i < sizeof(Konfiguration); ++i)
_packetBuffer[13 + i] = ((byte )cfg);*
#ifdef USE_DEBUG

  • Serial.print("Bytes=");*
  • for (uint8_t i = 0; i < offset; ++i)*
  • {*
    _ Serial.print(buffer*);_
    _
    Serial.print(",");_
    _
    }_
    _
    Serial.println(".");_
    _
    #endif*_
    * // Zielport: der lokale Port*
    * if (Udp.beginPacket(addr, port) == 1)
    _
    {*

    * // Paket schreiben ...*
    * Udp.write(packetBuffer, CPE_SW_PACKET_SIZE);
    _
    // ... und senden*

    * Udp.endPacket();
    _
    }*

    #ifdef USE_DEBUG
    * Serial.print("After send=");*
    * for (uint8_t i = 0; i < offset; ++i)
    _
    {*

    _ Serial.print(buffer*);
    Serial.print(",");
    }
    Serial.println(".");
    #endif*
    }
    Any suggestions?
    Greetings
    Chris_

from where you did get that library?
please use code tags

I downloaded it from wifilink github.

this one?
source code 1.0.1 or binary version 1.0.0?

I wrote the binary version for WiFi Dev Ed 1.0.0 on ESP. Maybe I misunderstood something, but I thought 1.0.1 is just a newer release only for the library part.

cpehonk:
I wrote the binary version for WiFi Dev Ed 1.0.0 on ESP. Maybe I misunderstood something, but I thought 1.0.1 is just a newer release only for the library part.

there were changes on the firmware side but not udp related.

WiFi Link is new, there are bugs. I make a heavy use of TCP (modbus client, rest server, telnet server) in all day run, but I didn't need UDP.