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