Skip to content

Commit b7a620a

Browse files
Merge branch 'main' into main
2 parents af03bb1 + a38606b commit b7a620a

File tree

16 files changed

+519
-86
lines changed

16 files changed

+519
-86
lines changed

Diff for: cores/arduino/analog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ void analogReadResolution(int bits) {
645645
default:
646646
_analogRequestedReadResolution = 12;
647647
adc.cfg.resolution = ADC_RESOLUTION_12_BIT;
648-
adc1.cfg.resolution = ADC_RESOLUTION_10_BIT;
648+
adc1.cfg.resolution = ADC_RESOLUTION_12_BIT;
649649
break;
650650
}
651651

Diff for: extras/net/lwipopts.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@
277277
* (requires the LWIP_RAW option)
278278
*/
279279
#ifndef MEMP_NUM_RAW_PCB
280-
#define MEMP_NUM_RAW_PCB 0
280+
#define MEMP_NUM_RAW_PCB 1
281281
#endif
282282

283283
/**
@@ -642,7 +642,7 @@
642642
* LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
643643
*/
644644
#ifndef LWIP_RAW
645-
#define LWIP_RAW 0
645+
#define LWIP_RAW 1
646646
#endif
647647

648648
/*
+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
Web ICMP Ping
3+
4+
This sketch pings a device based on the IP address or the hostname
5+
using the Ethernet module.
6+
7+
created 14 February 2024
8+
by paulvha
9+
10+
updated 27 February 2025
11+
by Fabik111
12+
13+
*/
14+
15+
#include "EthernetC33.h"
16+
17+
int status = WL_IDLE_STATUS;
18+
19+
// Set the static IP address to use if the DHCP fails to assign
20+
IPAddress ip(10, 130, 22, 84);
21+
22+
/* -------------------------------------------------------------------------- */
23+
void setup() {
24+
/* -------------------------------------------------------------------------- */
25+
//Initialize serial and wait for port to open:
26+
Serial.begin(115200);
27+
while (!Serial) {
28+
; // wait for serial port to connect. Needed for native USB port only
29+
}
30+
31+
// start the Ethernet connection:
32+
if (Ethernet.begin() == 0) {
33+
Serial.println("Failed to configure Ethernet using DHCP");
34+
// try to configure using IP address instead of DHCP:
35+
// IN THAT CASE YOU SHOULD CONFIGURE manually THE DNS or USE the IPAddress Server variable above
36+
// that is what is automatically done here...
37+
Ethernet.begin(ip);
38+
}
39+
// give the Ethernet shield a second to initialize:
40+
delay(2000);
41+
}
42+
43+
/* -------------------------------------------------------------------------- */
44+
void loop() {
45+
/* -------------------------------------------------------------------------- */
46+
47+
// Ping IP
48+
const IPAddress remote_ip(140,82,121,4);
49+
Serial.print("Trying to ping github.com on IP: ");
50+
Serial.println(remote_ip);
51+
52+
// using default ping count of 1
53+
int res = Ethernet.ping(remote_ip);
54+
55+
if (res > 0) {
56+
Serial.print("Ping response time: ");
57+
Serial.print(res);
58+
Serial.println(" ms");
59+
}
60+
else {
61+
Serial.println("Timeout on IP!");
62+
}
63+
64+
// Ping Host
65+
const char* remote_host = "www.google.com";
66+
Serial.print("Trying to ping host: ");
67+
Serial.println(remote_host);
68+
69+
// setting ttl to 128 and ping count to 10
70+
int res1 = Ethernet.ping(remote_host);
71+
72+
if (res1 > 0) {
73+
Serial.print("Ping average response time: ");
74+
Serial.print(res1);
75+
Serial.println(" ms");
76+
}
77+
else {
78+
Serial.println("Timeout on host!");
79+
}
80+
81+
Serial.println();
82+
delay(1000);
83+
}

Diff for: libraries/Ethernet/src/Ethernet.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,27 @@ IPAddress CEthernet::dnsServerIP() {
223223
return CLwipIf::getInstance().getDns();
224224
}
225225

226+
/* -------------------------------------------------------------------------- */
227+
int CEthernet::ping(IPAddress ip, uint8_t ttl) {
228+
/* -------------------------------------------------------------------------- */
229+
return CLwipIf::getInstance().ping(ip, ttl);
230+
}
231+
232+
/* -------------------------------------------------------------------------- */
233+
int CEthernet::ping(const String &hostname, uint8_t ttl)
234+
/* -------------------------------------------------------------------------- */
235+
{
236+
return ping(hostname.c_str(), ttl);
237+
}
238+
239+
/* -------------------------------------------------------------------------- */
240+
int CEthernet::ping(const char* host, uint8_t ttl) {
241+
/* -------------------------------------------------------------------------- */
242+
IPAddress ip;
243+
if(CLwipIf::getInstance().getHostByName(host,ip)) {
244+
return CLwipIf::getInstance().ping(ip, ttl);
245+
}
246+
return -1;
247+
}
248+
226249
CEthernet Ethernet;

Diff for: libraries/Ethernet/src/EthernetC33.h

+6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ class CEthernet {
6969
IPAddress gatewayIP();
7070
IPAddress dnsServerIP();
7171

72+
/*
73+
* PING
74+
*/
75+
int ping(IPAddress ip, uint8_t ttl = 128);
76+
int ping(const String &hostname, uint8_t ttl = 128);
77+
int ping(const char* host, uint8_t ttl = 128);
7278

7379
friend class EthernetClient;
7480
friend class EthernetServer;

Diff for: libraries/RTC/examples/Test_RTC/Test_RTC.ino

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// Include the RTC library
1212
#include "RTC.h"
1313

14-
// Define the interrupt pin for LED control during interrupts
15-
const int LED_ON_INTERRUPT = 22;
14+
// Define the pin to toggle on interrupt
15+
const int PIN_ON_INTERRUPT = D7;
1616

1717
bool periodicFlag = false;
1818
bool alarmFlag = false;
@@ -37,7 +37,7 @@ void setup() {
3737

3838
// Set LED pins as outputs
3939
pinMode(LED_BUILTIN, OUTPUT);
40-
pinMode(LED_ON_INTERRUPT, OUTPUT);
40+
pinMode(PIN_ON_INTERRUPT, OUTPUT);
4141

4242
// Initialize the RTC
4343
RTC.begin();
@@ -83,10 +83,10 @@ void loop() {
8383

8484
// Toggle the LED based on callback state
8585
if (clb_st) {
86-
digitalWrite(LED_ON_INTERRUPT, HIGH);
86+
digitalWrite(PIN_ON_INTERRUPT, HIGH);
8787
}
8888
else {
89-
digitalWrite(LED_ON_INTERRUPT, LOW);
89+
digitalWrite(PIN_ON_INTERRUPT, LOW);
9090
}
9191

9292
clb_st = !clb_st; // Toggle callback state

Diff for: libraries/WiFi/examples/WiFiPing/WiFiPing.ino

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
Web ICMP Ping
3+
4+
This sketch pings a device based on the IP address or the hostname
5+
using the WiFi module. By default the attempt is performed 5 times, but can
6+
be changed to max. 255
7+
8+
It requires at least version 0.5.0 of USB Wifi bridge firmware and WiFiS3 library.
9+
10+
This example is written for a network using WPA encryption. For
11+
WEP or WPA, change the WiFi.begin() call accordingly.
12+
13+
created 14 February 2024
14+
by paulvha
15+
16+
updated 27 February 2025
17+
by Fabik111
18+
19+
*/
20+
21+
#include "WiFiC3.h"
22+
#include "arduino_secrets.h"
23+
24+
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
25+
char ssid[] = SECRET_SSID; // your network SSID (name)
26+
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
27+
int keyIndex = 0; // your network key index number (needed only for WEP)
28+
29+
int status = WL_IDLE_STATUS;
30+
31+
/* -------------------------------------------------------------------------- */
32+
void setup() {
33+
/* -------------------------------------------------------------------------- */
34+
//Initialize serial and wait for port to open:
35+
Serial.begin(115200);
36+
while (!Serial) {
37+
; // wait for serial port to connect. Needed for native USB port only
38+
}
39+
40+
// check for the WiFi module:
41+
if (WiFi.status() == WL_NO_MODULE) {
42+
Serial.println("Communication with WiFi module failed.");
43+
// don't continue
44+
while (true);
45+
}
46+
47+
// attempt to connect to WiFi network:
48+
while (status != WL_CONNECTED) {
49+
Serial.print("Attempting to connect to SSID: ");
50+
Serial.println(ssid);
51+
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
52+
status = WiFi.begin(ssid, pass);
53+
54+
// wait 10 seconds for connection:
55+
delay(10000);
56+
}
57+
58+
printWifiStatus();
59+
}
60+
61+
/* -------------------------------------------------------------------------- */
62+
void loop() {
63+
/* -------------------------------------------------------------------------- */
64+
65+
// Ping IP
66+
const IPAddress remote_ip(140,82,121,4);
67+
Serial.print("Trying to ping github.com on IP: ");
68+
Serial.println(remote_ip);
69+
70+
// using default ping count of 1
71+
int res = WiFi.ping(remote_ip);
72+
73+
if (res > 0) {
74+
Serial.print("Ping response time: ");
75+
Serial.print(res);
76+
Serial.println(" ms");
77+
}
78+
else {
79+
Serial.println("Timeout on IP!");
80+
}
81+
82+
// Ping Host
83+
const char* remote_host = "www.google.com";
84+
Serial.print("Trying to ping host: ");
85+
Serial.println(remote_host);
86+
87+
// setting ttl to 128 and ping count to 10
88+
int res1 = WiFi.ping(remote_host);
89+
90+
if (res1 > 0) {
91+
Serial.print("Ping average response time: ");
92+
Serial.print(res1);
93+
Serial.println(" ms");
94+
}
95+
else {
96+
Serial.println("Timeout on host!");
97+
}
98+
99+
Serial.println();
100+
delay(1000);
101+
}
102+
103+
/* -------------------------------------------------------------------------- */
104+
void printWifiStatus() {
105+
/* -------------------------------------------------------------------------- */
106+
// print the SSID of the network you're attached to:
107+
Serial.print("SSID: ");
108+
Serial.println(WiFi.SSID());
109+
110+
// print your board's IP address:
111+
IPAddress ip = WiFi.localIP();
112+
Serial.print("IP Address: ");
113+
Serial.println(ip);
114+
115+
// print the received signal strength:
116+
long rssi = WiFi.RSSI();
117+
Serial.print("signal strength (RSSI):");
118+
Serial.print(rssi);
119+
Serial.println(" dBm");
120+
}

Diff for: libraries/WiFi/examples/WiFiPing/arduino_secrets.h

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define SECRET_SSID ""
2+
#define SECRET_PASS ""

Diff for: libraries/WiFi/src/WiFi.cpp

+23-2
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,33 @@ unsigned long CWifi::getTime() {
321321
return 0;
322322
}
323323

324-
325-
326324
void CWifi::setTimeout(unsigned long timeout) {
327325
(void)(timeout);
328326
}
329327

328+
/* -------------------------------------------------------------------------- */
329+
int CWifi::ping(IPAddress ip, uint8_t ttl) {
330+
/* -------------------------------------------------------------------------- */
331+
return CLwipIf::getInstance().ping(ip, ttl);
332+
}
333+
334+
/* -------------------------------------------------------------------------- */
335+
int CWifi::ping(const String &hostname, uint8_t ttl)
336+
/* -------------------------------------------------------------------------- */
337+
{
338+
return ping(hostname.c_str(), ttl);
339+
}
340+
341+
/* -------------------------------------------------------------------------- */
342+
int CWifi::ping(const char* host, uint8_t ttl) {
343+
/* -------------------------------------------------------------------------- */
344+
IPAddress ip;
345+
if(hostByName(host,ip)) {
346+
return CLwipIf::getInstance().ping(ip, ttl);
347+
}
348+
return -1;
349+
}
350+
330351

331352
CWifi WiFi;
332353

Diff for: libraries/WiFi/src/WiFiC3.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,12 @@ class CWifi {
254254

255255

256256
void setTimeout(unsigned long timeout);
257-
257+
/*
258+
* PING
259+
*/
260+
int ping(IPAddress ip, uint8_t ttl = 128);
261+
int ping(const String &hostname, uint8_t ttl = 128);
262+
int ping(const char* host, uint8_t ttl = 128);
258263

259264
};
260265

0 commit comments

Comments
 (0)