Thanks to visit codestin.com
Credit goes to github.com

Skip to content

UDP not send packet #368

@Avenitos

Description

@Avenitos

Hello!

sendUdp() function not send broadcast packets :(
in Wireshark no packets.

UIP library worked correctly!

#include <EtherCard.h>

const byte myMac[] PROGMEM = { 0x70, 0x69, 0x69, 0x2D, 0x30, 0x31 };
byte Ethernet::buffer[350];                          // Buffer must be 350 for DHCP to work

void setup() {
  Serial.begin(57600);
  Serial.println(F("\n[EtherCard UDP send]"));

  if (ether.begin(sizeof Ethernet::buffer, myMac, SS) == 0)
    Serial.println(F("Failed to access Ethernet controller"));

  static byte myip[] = { 172,16,1,147 };
  static byte gwip[] = { 172,16,1,1 };
  static byte dnsip[] = { 8,8,8,8 };
  static byte mask[] = { 255,255,255,0 };

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

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

  char payload[] = "My UDP message";
  uint8_t nSourcePort = 6454;
  uint8_t nDestinationPort = 6454;
  uint8_t broadcast[4] = { 255,255,255,255};
  
//ether.client_arp_whohas_blocking(ipDestinationAddress);
//delay(10);
//ether.sendUdp_mac(payload, sizeof(payload), nSourcePort, ipDestinationAddress, ether.returned_mac, nDestinationPort);

  ether.sendUdp(payload, sizeof(payload), nSourcePort, broadcast, nDestinationPort);

  Serial.println("UDP sent.");  
}

void loop() {
  ether.packetLoop(ether.packetReceive());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions