mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
Migrate from astyle to clang-format (#8464)
This commit is contained in:
committed by
Max Prokhorov
parent
46190b61f1
commit
19b7a29720
@ -23,12 +23,12 @@
|
||||
|
||||
#ifndef STASSID
|
||||
#define STASSID "your-ssid"
|
||||
#define STAPSK "your-password"
|
||||
#define STAPSK "your-password"
|
||||
#endif
|
||||
|
||||
#define FQDN F("www.google.com") // with both IPv4 & IPv6 addresses
|
||||
#define FQDN2 F("www.yahoo.com") // with both IPv4 & IPv6 addresses
|
||||
#define FQDN6 F("ipv6.google.com") // does not resolve in IPv4
|
||||
#define FQDN F("www.google.com") // with both IPv4 & IPv6 addresses
|
||||
#define FQDN2 F("www.yahoo.com") // with both IPv4 & IPv6 addresses
|
||||
#define FQDN6 F("ipv6.google.com") // does not resolve in IPv4
|
||||
#define STATUSDELAY_MS 10000
|
||||
#define TCP_PORT 23
|
||||
#define UDP_PORT 23
|
||||
@ -71,29 +71,17 @@ void status(Print& out) {
|
||||
|
||||
for (int i = 0; i < DNS_MAX_SERVERS; i++) {
|
||||
IPAddress dns = WiFi.dnsIP(i);
|
||||
if (dns.isSet()) {
|
||||
out.printf("dns%d: %s\n", i, dns.toString().c_str());
|
||||
}
|
||||
if (dns.isSet()) { out.printf("dns%d: %s\n", i, dns.toString().c_str()); }
|
||||
}
|
||||
|
||||
out.println(F("Try me at these addresses:"));
|
||||
out.println(F("(with 'telnet <addr> or 'nc -u <addr> 23')"));
|
||||
for (auto a : addrList) {
|
||||
out.printf("IF='%s' IPv6=%d local=%d hostname='%s' addr= %s",
|
||||
a.ifname().c_str(),
|
||||
a.isV6(),
|
||||
a.isLocal(),
|
||||
a.ifhostname(),
|
||||
a.toString().c_str());
|
||||
out.printf("IF='%s' IPv6=%d local=%d hostname='%s' addr= %s", a.ifname().c_str(), a.isV6(), a.isLocal(), a.ifhostname(), a.toString().c_str());
|
||||
|
||||
if (a.isLegacy()) {
|
||||
out.printf(" / mask:%s / gw:%s",
|
||||
a.netmask().toString().c_str(),
|
||||
a.gw().toString().c_str());
|
||||
}
|
||||
if (a.isLegacy()) { out.printf(" / mask:%s / gw:%s", a.netmask().toString().c_str(), a.gw().toString().c_str()); }
|
||||
|
||||
out.println();
|
||||
|
||||
}
|
||||
|
||||
// lwIP's dns client will ask for IPv4 first (by default)
|
||||
@ -101,8 +89,8 @@ void status(Print& out) {
|
||||
fqdn(out, FQDN);
|
||||
fqdn(out, FQDN6);
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
fqdn_rt(out, FQDN, DNSResolveType::DNS_AddrType_IPv4_IPv6); // IPv4 before IPv6
|
||||
fqdn_rt(out, FQDN2, DNSResolveType::DNS_AddrType_IPv6_IPv4); // IPv6 before IPv4
|
||||
fqdn_rt(out, FQDN, DNSResolveType::DNS_AddrType_IPv4_IPv6); // IPv4 before IPv6
|
||||
fqdn_rt(out, FQDN2, DNSResolveType::DNS_AddrType_IPv6_IPv4); // IPv6 before IPv4
|
||||
#endif
|
||||
out.println(F("------------------------------"));
|
||||
}
|
||||
@ -125,7 +113,7 @@ void setup() {
|
||||
|
||||
status(Serial);
|
||||
|
||||
#if 0 // 0: legacy connecting loop - 1: wait for IPv6
|
||||
#if 0 // 0: legacy connecting loop - 1: wait for IPv6
|
||||
|
||||
// legacy loop (still valid with IPv4 only)
|
||||
|
||||
@ -146,11 +134,9 @@ void setup() {
|
||||
for (bool configured = false; !configured;) {
|
||||
for (auto addr : addrList)
|
||||
if ((configured = !addr.isLocal()
|
||||
// && addr.isV6() // uncomment when IPv6 is mandatory
|
||||
// && addr.ifnumber() == STATION_IF
|
||||
)) {
|
||||
break;
|
||||
}
|
||||
// && addr.isV6() // uncomment when IPv6 is mandatory
|
||||
// && addr.ifnumber() == STATION_IF
|
||||
)) { break; }
|
||||
Serial.print('.');
|
||||
delay(500);
|
||||
}
|
||||
@ -188,10 +174,8 @@ void loop() {
|
||||
udp.remoteIP().printTo(Serial);
|
||||
Serial.print(F(" :"));
|
||||
Serial.println(udp.remotePort());
|
||||
int c;
|
||||
while ((c = udp.read()) >= 0) {
|
||||
Serial.write(c);
|
||||
}
|
||||
int c;
|
||||
while ((c = udp.read()) >= 0) { Serial.write(c); }
|
||||
|
||||
// send a reply, to the IP address and port that sent us the packet we received
|
||||
udp.beginPacket(udp.remoteIP(), udp.remotePort());
|
||||
@ -200,8 +184,5 @@ void loop() {
|
||||
}
|
||||
|
||||
|
||||
if (showStatusOnSerialNow) {
|
||||
status(Serial);
|
||||
}
|
||||
|
||||
if (showStatusOnSerialNow) { status(Serial); }
|
||||
}
|
||||
|
Reference in New Issue
Block a user