Forum: Gesperrte Threads Webserver soll String senden


von Mary A. (logomaus)


Lesenswert?

Hallo zusammen!

Mein Ethernetshield arbeitet ja als Webserver. Nun möchte ich eine URL 
als Stringbefehl
versenden, damit beim empfangenden PC eine Webseite aufgeht.
Jetzt habe ich dafür die Udp-Library eingebunden und bekomme aber 
laufend
Fehlermeldungen wie z.B.:
no matching function for call to 'UdpClass::sendPacket(char[13], 
String&, int&)'
Was ist an dem Programm faul, bzw. wie kann ich das Senden realisieren?
Mein Programm sieht folgendermaßen aus, wobei ich das HTML-Zeug weg-
gelassen habe:



#include <SPI.h>
#include <Ethernet.h>
#include <Flash.h>
#include "UdpString.h"
#include <Udp.h>


byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x40, 0xF2 };    // MAC-Adresse
byte ip[]  = { 192, 168, 178, 22 };                     // IP-Adresse
byte gateway[] = { 192, 168, 178, 1 };                  // Gateway
byte subnet[]  = { 255, 255, 255, 0 };                  // Subnetz


Server server(80);
char  ReplyBuffer[] = "acknowledged";       // a string to send back
String remoteIp = "192.168.178.44";               // the remote IP 
address
int remotePort = 80;                              // the destination 
port
unsigned int localPort = 8888;      // local port to listen on

int Pin8 = 8;  // Digital Input
int Pin3 = 3;  // Digital Output
int Pin5 = 5;  // Analog Output
int Pin6 = 6;  // Analog Output

int state;
int helligkeit = 0;

String readString = String(100);      // String for data from address
boolean Pin8ON = false;               // Status flag
boolean Pin3ON = false;               // Status flag
boolean Pin5ON = false;               // Status flag
boolean Pin6ON = false;               // Status flag

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming 
packet,



void setup() {

Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
Udp.begin(localPort);


pinMode(Pin8, INPUT);
pinMode(Pin3, OUTPUT);
pinMode(Pin5, OUTPUT);
pinMode(Pin6, OUTPUT);
digitalWrite(Pin3, state);
analogWrite(Pin5, helligkeit);
analogWrite(Pin6, helligkeit);

Serial.begin(9600);
}

void loop()
{
// Create a client connection
Client client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();


//read char by char HTTP request
if (readString.length() < 100) {

//store characters to String
readString = readString + c;
}

//output chars to serial port
Serial.print(c);

  // if there's data available, read a packet
  int packetSize = Udp.available(); // note that this includes the UDP 
header
  if(packetSize)
  {
    packetSize = packetSize - 8;      // subtract the 8 byte header
    Serial.print("Received packet of size ");
    Serial.println(packetSize);

    // read the packet into packetBufffer and get the senders IP addr 
and port number
  //  Udp.readPacket(packetBuffer,UDP_TX_PACKET_MAX_SIZE, remoteIp, 
remotePort);
    Serial.println("Contents:");
    Serial.println(packetBuffer);

    Udp.sendPacket( ReplyBuffer, remoteIp, remotePort);
  }

//clearing string for next read
readString="";

//stopping client
client.stop();
}}}}}

Wäre die PString-Library die richtige?

LG

: Verschoben durch Admin
von Tim (Gast)


Lesenswert?

Keine Ahnung, aber Du solltest dazu schreiben das es sich um Arduino 
handelt.

von Läubi .. (laeubi) Benutzerseite


Lesenswert?


Dieser Beitrag ist gesperrt und kann nicht beantwortet werden.