FabGL
ESP32 Display Controller and Graphics Library
ICMP.h
Go to the documentation of this file.
1 /*
2  Created by Fabrizio Di Vittorio (fdivitto2013@gmail.com) - <http://www.fabgl.com>
3  Copyright (c) 2019-2021 Fabrizio Di Vittorio.
4  All rights reserved.
5 
6 
7 * Please contact fdivitto2013@gmail.com if you need a commercial license.
8 
9 
10 * This library and related software is available under GPL v3.
11 
12  FabGL is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  FabGL is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with FabGL. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 
27 #pragma once
28 
29 
37 #ifdef ARDUINO
38 
39 
40 #include "Client.h"
41 
42 #include "freertos/FreeRTOS.h"
43 
44 #include "lwip/netdb.h"
45 #include "lwip/raw.h"
46 #include "lwip/icmp.h"
47 #include "lwip/inet_chksum.h"
48 
49 
50 #include "fabglconf.h"
51 #include "fabutils.h"
52 
53 
54 
55 namespace fabgl {
56 
57 
58 
87  class ICMP {
88 
89 public:
90 
91  ICMP();
92  ~ICMP();
93 
94  // send Echo Request and wait for Echo Reply
95  // returns "measured" echo time in microseconds. ret -1 on timeout or error
96  int ping(IPAddress const &dest);
97  int ping(char const * host); // host can be IP or host name
98 
99  int receivedBytes() { return m_receivedBytes; }
100 
101  int receivedTTL() { return m_receivedTTL; }
102 
103  int receivedSeq() { return m_waitingSeq; }
104 
105  IPAddress const& hostIP() { return m_destIP; }
106 
107 private:
108 
109  static uint8_t raw_recv_fn(void * arg, raw_pcb * pcb, pbuf * p, const ip_addr_t * addr);
110 
111  IPAddress m_destIP;
112  QueueHandle_t m_queue;
113  int m_waitingID;
114  int m_waitingSeq;
115  int m_receivedBytes;
116  int m_receivedTTL;
117 };
118 
119 
120 
121 
122 }
123 
124 
125 #endif // #ifdef ARDUINO
ICMP Implementation.
Definition: ICMP.h:87
This file contains some utility classes and functions.
Definition: canvas.cpp:36
This file contains FabGL library configuration settings, like number of supported colors...