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

UDP packet is not sent - NOT STATIC IP #422

Open
DexasElectronics opened this issue Oct 5, 2021 · 1 comment
Open

UDP packet is not sent - NOT STATIC IP #422

DexasElectronics opened this issue Oct 5, 2021 · 1 comment

Comments

@DexasElectronics
Copy link

Hello. Im trying to send some test strings using example sketch provided in the description of the library. I have checked all the mentioned issues, but they all seem to share same thing - static ip. I told that also, while using static ip i cannot neither send single packet to specific adress, neither broadcast. When using DHCP, i can broadcast, but cannot send packet to single adress (packet never arrives).

Tried using code provided in Add ARP cache #351, but that gives error about "no member named 'clientResolveIp'", from what i see those functions are deleted from the latest version, not sure why.

Snippets from code i am using:

static byte myip[] = { 192,168,1,200 };
static byte gwip[] = { 192,168,1,254 };
static byte dnsip[] = { 8,8,8,8 };
static byte mask[] = { 255,255,255,0 };
static byte mymac[] = { 0x70,0x69,0x69,0x2D,0x30,0x31 };

ether.staticSetup(myip, gwip, 0, mask);

char payload[] = "My UDP message";
uint8_t nSourcePort = 11;
uint8_t nDestinationPort = 11;
uint8_t ipDestinationAddress[IP_LEN];
ether.parseIp(ipDestinationAddress, "192.168.1.103");
ether.sendUdp(payload, sizeof(payload), nSourcePort, ipDestinationAddress, nDestinationPort);

void loop() // run over and over
{
ether.packetLoop(ether.packetReceive());
}

Tried changing ports, etc, both static and dynamic ip, no luck in any case.

@daonguyen207
Copy link

The library was not able to get the destination MAC address correctly, so the computer ignored the UDP packet.
Open the file tcpip.cpp and locate the function void EtherCard::udpPrepare (uint16_t sport, const uint8_t *dip, uint16_t dport) on line 376
Please replace destmacaddr with gwmacaddr

if(is_lan(myip, dip)) {
//setMACandIPs(destmacaddr, dip);
setMACandIPs(gwmacaddr, dip);
}

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

2 participants