Hello
I have an Arduino DUE+ IoShield A (W5500 from Wiznet). IDE 1.6. Wiznet Ethernet library
I want the Arduino to behave as a TCP Server. This server waits for a client, and sends the client an info packet.
The code is divided in two files, one the server code, and other a .h with the struct of the packet
Server.
#include "packet.h"
#include <Ethernet.h>
// the media access control (ethernet hardware) address for the shield:
byte mac[] = { 0x00, 0x08, 0xDC, 0x4D, 0xD1, 0x55 };
//the IP address for the shield:
byte ip[] = { 10, 1, 1, 3 };
// the router's gateway address:
byte gateway[] = { 10, 1, 1, 1 };//? Esto no esun gateway, es un nodo.
// the subnet:
byte subnet[] = { 255, 255, 255, 0 };
int Port= 5000;
EthernetServer server = EthernetServer(Port);
void setup()
{
// initialize the ethernet device
Ethernet.begin(mac, ip, gateway, subnet);
// start listening for clients
server.begin();
Info.PacketID= 0x0E;
Info.ID_track=1;
Info.Direction=0x00;
Info.num=10;
Info.stateA[0]=0x00;
Info.stateA[1]=0x00;
Info.stateA[2]=0x00;
Info.stateA[3]=0x00;
void loop()
{
// if an incoming client connects, there will be bytes available to read:
EthernetClient client = server.available();
if (client) {
server.write(Info,sizeof(Info));
}
}
packet.h
struct Packet{
byte PacketID;
byte ID_track;
byte Direction;
byte num;
byte stateA[4];
};
struct Packet Info;
It gives error in server.write() , no matching function for call… I think that it is beacuse Info is not only an array of bytes but a struct… but I’m not sure
Any help about the server and how to send a data packet structure is welcome.
Thanks