B4R Library ESP32 Ping

This is a B4R-ESP32 portation from https://github.com/marian-craciunescu/ESP32Ping
Rename to rar and use winrar for decompression because rar attachment are not allowed.

B4X:
Sub Process_Globals
    Public Serial1 As Serial
    Private ping As ESP32Ping
    Private wifi As ESP8266WiFi
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    If wifi.Connect2("SSID","pssst") Then
        Log("Connected to network")
    Else
        Log("Failed to connect to network")
        Return
    End If
    AddLooper("Looper1")
End Sub

Private Sub Looper1
    Log("google.com: ", ping.PingHost("google.com", 2),TAB,ping.AverageTime,TAB,StackBufferUsage,TAB,AvailableRAM)
    Log("google.de:  ", ping.PingHost("google.de", 2),TAB,ping.AverageTime,TAB,StackBufferUsage,TAB,AvailableRAM)
    Log("Google DNS: ", ping.PingIP(Array As Byte(8, 8, 8, 8),2),TAB,ping.AverageTime,TAB,StackBufferUsage,TAB,AvailableRAM)
    Log("Google DNS: ", ping.PingIP(Array As Byte(8, 8, 4, 4),2),TAB,ping.AverageTime,TAB,StackBufferUsage,TAB,AvailableRAM)
End Sub
 

Attachments

  • rESP32Ping.zip
    8 KB · Views: 171
Last edited:

viriato

Member
Licensed User
Longtime User
This is a B4R-ESP32 portation from https://github.com/marian-craciunescu/ESP32Ping

B4X:
Sub Process_Globals
    Public Serial1 As Serial
    Private ping As ESP32Ping
    Private wifi As ESP8266WiFi
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    If wifi.Connect2("SSID","pssst") Then
        Log("Connected to network")
    Else
        Log("Failed to connect to network")
        Return
    End If
    AddLooper("Looper1")
End Sub

Private Sub Looper1
    Log("google.com: ", ping.PingHost("google.com", 2),TAB,ping.AverageTime,TAB,StackBufferUsage,TAB,AvailableRAM)
    Log("google.de:  ", ping.PingHost("google.de", 2),TAB,ping.AverageTime,TAB,StackBufferUsage,TAB,AvailableRAM)
    Log("Google DNS: ", ping.PingIP(Array As Byte(8, 8, 8, 8),2),TAB,ping.AverageTime,TAB,StackBufferUsage,TAB,AvailableRAM)
    Log("Google DNS: ", ping.PingIP(Array As Byte(8, 8, 4, 4),2),TAB,ping.AverageTime,TAB,StackBufferUsage,TAB,AvailableRAM)
End Sub
Hi ,
Super Merci ,
Thanks a lot , but it looks like there is a problem with the ZIP file (seems corrupted)
 

Hypnos

Active Member
Licensed User
Longtime User
This is a B4R-ESP32 portation from https://github.com/marian-craciunescu/ESP32Ping
Rename to rar and use winrar for decompression because rar attachment are not allowed.

B4X:
Sub Process_Globals
    Public Serial1 As Serial
    Private ping As ESP32Ping
    Private wifi As ESP8266WiFi
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    If wifi.Connect2("SSID","pssst") Then
        Log("Connected to network")
    Else
        Log("Failed to connect to network")
        Return
    End If
    AddLooper("Looper1")
End Sub

Private Sub Looper1
    Log("google.com: ", ping.PingHost("google.com", 2),TAB,ping.AverageTime,TAB,StackBufferUsage,TAB,AvailableRAM)
    Log("google.de:  ", ping.PingHost("google.de", 2),TAB,ping.AverageTime,TAB,StackBufferUsage,TAB,AvailableRAM)
    Log("Google DNS: ", ping.PingIP(Array As Byte(8, 8, 8, 8),2),TAB,ping.AverageTime,TAB,StackBufferUsage,TAB,AvailableRAM)
    Log("Google DNS: ", ping.PingIP(Array As Byte(8, 8, 4, 4),2),TAB,ping.AverageTime,TAB,StackBufferUsage,TAB,AvailableRAM)
End Sub

Hi All,

I got some error when running this example, anyone know what is wrong ? Thanks!

B4X:
Verifying...
2022-02-04T13:52:07.406Z INFO c.a.u.n.HttpConnectionManager:157 [cc.arduino.packages.discoverers.serial.SerialDiscovery] Request complete URL="https://builder.arduino.cc/builder/v1/boards/0x10C4/0xEA60", method=GET, response code=404, request id=24C7D4EBABE74018, headers={null=[HTTP/1.1 404 Not Found], Cache-Control=[no-cache, no-store, must-revalidate], Server=[nginx], Connection=[keep-alive], Vary=[Origin], Pragma=[no-cache], Expires=[0], Content-Length=[0], Date=[Fri, 04 Feb 2022 13:52:07 GMT]}
2022-02-04T13:52:07.407Z WARN p.a.h.BoardCloudResolver:64 [cc.arduino.packages.discoverers.serial.SerialDiscovery] Fail to get the Vid Pid information from the builder response code=404
c:/users/hypno/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\hypno\OneDrive\Desktop\ANDROI~1\B4R\ESP32P~1\Objects\bin\sketch\b4r_main.cpp.o:(.literal._ZN8b4r_main8_looper1Ev+0x1c): undefined reference to `B4R::rESP32Ping::PingHost(B4R::B4RString*, unsigned char)'
c:/users/hypno/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\hypno\OneDrive\Desktop\ANDROI~1\B4R\ESP32P~1\Objects\bin\sketch\b4r_main.cpp.o:(.literal._ZN8b4r_main8_looper1Ev+0x20): undefined reference to `B4R::rESP32Ping::AverageTime()'
c:/users/hypno/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\hypno\OneDrive\Desktop\ANDROI~1\B4R\ESP32P~1\Objects\bin\sketch\b4r_main.cpp.o:(.literal._ZN8b4r_main8_looper1Ev+0x24): undefined reference to `B4R::rESP32Ping::PingIP(B4R::Array*, unsigned char)'
Multiple libraries were found for "WiFi.h"
 Used: C:\Users\hypno\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\WiFi
 Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
c:/users/hypno/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\hypno\OneDrive\Desktop\ANDROI~1\B4R\ESP32P~1\Objects\bin\sketch\b4r_main.cpp.o: in function `b4r_main::_looper1()':
C:\Users\hypno\OneDrive\Desktop\ANDROI~1\B4R\ESP32P~1\Objects\bin\sketch/b4r_main.cpp:46: undefined reference to `B4R::rESP32Ping::PingHost(B4R::B4RString*, unsigned char)'
c:/users/hypno/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\hypno\OneDrive\Desktop\ANDROI~1\B4R\ESP32P~1\Objects\bin\sketch/b4r_main.cpp:46: undefined reference to `B4R::rESP32Ping::AverageTime()'
c:/users/hypno/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\hypno\OneDrive\Desktop\ANDROI~1\B4R\ESP32P~1\Objects\bin\sketch/b4r_main.cpp:46: undefined reference to `B4R::rESP32Ping::PingHost(B4R::B4RString*, unsigned char)'
c:/users/hypno/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\hypno\OneDrive\Desktop\ANDROI~1\B4R\ESP32P~1\Objects\bin\sketch/b4r_main.cpp:48: undefined reference to `B4R::rESP32Ping::AverageTime()'
c:/users/hypno/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\hypno\OneDrive\Desktop\ANDROI~1\B4R\ESP32P~1\Objects\bin\sketch/b4r_main.cpp:48: undefined reference to `B4R::rESP32Ping::PingIP(B4R::Array*, unsigned char)'
c:/users/hypno/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\hypno\OneDrive\Desktop\ANDROI~1\B4R\ESP32P~1\Objects\bin\sketch/b4r_main.cpp:50: undefined reference to `B4R::rESP32Ping::AverageTime()'
c:/users/hypno/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\hypno\OneDrive\Desktop\ANDROI~1\B4R\ESP32P~1\Objects\bin\sketch/b4r_main.cpp:50: undefined reference to `B4R::rESP32Ping::PingIP(B4R::Array*, unsigned char)'
c:/users/hypno/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\hypno\OneDrive\Desktop\ANDROI~1\B4R\ESP32P~1\Objects\bin\sketch/b4r_main.cpp:50: undefined reference to `B4R::rESP32Ping::AverageTime()'
collect2.exe: error: ld returned 1 exit status
exit status 1
DEBUG StatusLogger Stopping LoggerContext[name=1e6f5c3, org.apache.logging.log4j.core.LoggerContext@287ea3]
DEBUG StatusLogger Stopping LoggerContext[name=1e6f5c3, org.apache.logging.log4j.core.LoggerContext@287ea3]...
TRACE StatusLogger Unregistering 1 MBeans: [org.apache.logging.log4j2:type=1e6f5c3]
TRACE StatusLogger Unregistering 1 MBeans: [org.apache.logging.log4j2:type=1e6f5c3,component=StatusLogger]
TRACE StatusLogger Unregistering 1 MBeans: [org.apache.logging.log4j2:type=1e6f5c3,component=ContextSelector]
TRACE StatusLogger Unregistering 1 MBeans: [org.apache.logging.log4j2:type=1e6f5c3,component=Loggers,name=]
TRACE StatusLogger Unregistering 2 MBeans: [org.apache.logging.log4j2:type=1e6f5c3,component=Appenders,name=RollingFile, org.apache.logging.log4j2:type=1e6f5c3,component=Appenders,name=Console]
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=1e6f5c3,component=AsyncAppenders,name=*'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=1e6f5c3,component=AsyncLoggerRingBuffer'
TRACE StatusLogger Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=1e6f5c3,component=Loggers,name=*,subtype=RingBuffer'
TRACE StatusLogger Stopping XmlConfiguration[location=jar:file:/C:/Program%20Files%20(x86)/Arduino/lib/pde.jar!/log4j2.xml]...
TRACE StatusLogger XmlConfiguration notified 2 ReliabilityStrategies that config will be stopped.
TRACE StatusLogger XmlConfiguration stopping 1 LoggerConfigs.
TRACE StatusLogger XmlConfiguration stopping root LoggerConfig.
TRACE StatusLogger XmlConfiguration notifying ReliabilityStrategies that appenders will be stopped.
TRACE StatusLogger XmlConfiguration stopping remaining Appenders.
DEBUG StatusLogger Shutting down RollingFileManager C:\Users\hypno\AppData\Local\Arduino15/logs/application.log
DEBUG StatusLogger Shutting down RollingFileManager C:\Users\hypno\AppData\Local\Arduino15/logs/application.log
DEBUG StatusLogger All asynchronous threads have terminated
DEBUG StatusLogger RollingFileManager shutdown completed with status true
DEBUG StatusLogger Shut down RollingFileManager C:\Users\hypno\AppData\Local\Arduino15/logs/application.log, all resources released: true
DEBUG StatusLogger Appender RollingFile stopped with status true
DEBUG StatusLogger Shutting down OutputStreamManager SYSTEM_ERR.false.false
DEBUG StatusLogger Shut down OutputStreamManager SYSTEM_ERR.false.false, all resources released: true
DEBUG StatusLogger Appender Console stopped with status true
TRACE StatusLogger XmlConfiguration stopped 2 remaining Appenders.
TRACE StatusLogger XmlConfiguration cleaning Appenders from 2 LoggerConfigs.
DEBUG StatusLogger Stopped XmlConfiguration[location=jar:file:/C:/Program%20Files%20(x86)/Arduino/lib/pde.jar!/log4j2.xml] OK
DEBUG StatusLogger Stopped LoggerContext[name=1e6f5c3, org.apache.logging.log4j.core.LoggerContext@287ea3] with status true
 
Top