int WiFiEspUDP::beginPacket(IPAddress ip, uint16_t port) { char s[18]; sprintf(s, "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); return beginPacket(s, port); }
int WiFiUDP::beginPacket(const char *host, uint16_t port) { IPAddress remote_addr; if (WiFi.hostByName(host, remote_addr)) { return beginPacket(remote_addr, port); } return 0; }
int WiFiUDP::beginPacket(const char *host, uint16_t port) { // Look up the host first int ret = 0; IPAddress remote_addr; if (WiFi.hostByName(host, remote_addr)) { return beginPacket(remote_addr, port); } return ret; }
int LWiFiUDP::beginPacket(const char *host, uint16_t port) { // DNS loopup and bypass to IP version if (LWiFi.hostByName(host, m_sendToIP)) { return beginPacket(m_sendToIP, port); } else { return 0; } }
int EthernetUDP::beginPacket(const char *host, uint16_t port) { // Look up the host first int ret = 0; DNSClient dns; IPAddress remote_addr; dns.begin(Ethernet.dnsServerIP()); ret = dns.getHostByName(host, remote_addr); if (ret == 1) return beginPacket(remote_addr, port); else return ret; }
int EthernetUDP::beginPacket(const char *host, uint16_t port) { ip_addr_t ip; ip.addr = 0; dns_gethostbyname(host, &ip, do_dns, &ip); while(!ip.addr) { delay(10); } if(ip.addr == IPADDR_NONE) return false; return(beginPacket(IPAddress(ip.addr), port)); }
int BridgeUDP::beginPacket(IPAddress ip, uint16_t port) { if (!opened) return 0; String address; address.reserve(18); address += ip[0]; address += '.'; address += ip[1]; address += '.'; address += ip[2]; address += '.'; address += ip[3]; return beginPacket(address.c_str(), port); }
/* Add a byte to the currently assembled packet if there is space * if there isn't space, either truncate (ignore) or split the packet. */ void UdpBytewiseClass::write(uint8_t b) { if(_txIndex>= UDP_TX_PACKET_MAX_SIZE) { //buffer is full - we can either truncate the packet or split in two switch (_txOverflowStrategy) { case UDP_TX_OVERFLOW_SPLIT: endPacket(); beginPacket(_txIp,_txPort); //fall through to normal add of byte to buffer below break; case UDP_TX_OVERFLOW_TRUNCATE: default: //don't add - just ignore bytes past buffer size return; } } _txBuffer[_txIndex++] = b; }
//--tested, working--// int WiFiUDP::beginPacket(const char *host, uint16_t port) { // //look up host's IP address // IPAddress ip; int success = WiFi.hostByName((char*)host, ip); // //if host successfully resolved to IP, begin packet to that IP // if (success) { return beginPacket(ip, port); } else { return 0; } }
void SLIPEncodedSerial::encode(const uint8_t *buf, int size) { beginPacket(); while (size--) encode(*buf++); endPacket(); }