Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending UDP datagrams from Arduino with EtherCard library to concrete IP #431

Open
vbgrigorevuser opened this issue Apr 6, 2024 · 0 comments

Comments

@vbgrigorevuser
Copy link

I've checked that my arduino and shield worked, but my python server can't get arduino udp.

`#include <EtherCard.h>

static byte mymac[] = { 0x1A,0x2B,0x3C,0x4D,0x5E,0x6F };
byte Ethernet::buffer[700];
static uint32_t timer;

const int dstPort PROGMEM = 1234;

const int srcPort PROGMEM = 4321;

uint8_t ipDestinationAddress[IP_LEN];

void setup () {
Serial.begin(9600);

// Change 'SS' to your Slave Select pin, if you arn't using the default pin
if (ether.begin(sizeof Ethernet::buffer, mymac, SS) == 0)
Serial.println( "Failed to access Ethernet controller");
if (!ether.dhcpSetup())
Serial.println("DHCP failed");

ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);

// if (!ether.dnsLookup(website))
// Serial.println("DNS failed");

ether.parseIp(ipDestinationAddress, "<xx.xx.xx.xx>");

ether.printIp("SRV: ", ether.hisip);
}

char textToSend[] = "test 123";

void loop () {
if (millis() > timer) {
timer = millis() + 5000;
//static void sendUdp (char *data,uint8_t len,uint16_t sport, uint8_t *dip, uint16_t dport);
ether.sendUdp(textToSend, sizeof(textToSend), srcPort, ipDestinationAddress, dstPort );
}
}`

Instead of <xx.xx.xx.xx> I have white ip for my server, port-forwarding done, but I still can't get udps from arduino. I see udp in wireshark too.

I've tested, that through internet from remove vps I can reach my server (python server, client), but from arduino it still does not work. Help me please!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant