PicoScenes API Docs
 
Loading...
Searching...
No Matches
SystemTools::Net Namespace Reference

Functions

bool hasInternetConnection ()
 Checks if there is an internet connection.
 
std::tuple< bool, std::string, std::optional< TimePoint_System_Millisecond > > checkInternetConnectionAndGetGMTTime (bool forceRefresh=false)
 Checks internet connection and gets GMT time.
 
std::vector< uint8_t > curlDownloadNoBody (const std::string &url, uint32_t timeout_ms=0, long *httpResponseCode=nullptr)
 Downloads data from a URL without the body.
 
std::vector< uint8_t > curlDownload (const std::string &url, uint32_t timeout_ms=0, long *httpResponseCode=nullptr)
 Downloads data from a URL.
 
std::string curlDownloadContentAsString (const std::string &url, uint32_t timeout_ms=0, long *httpResponseCode=nullptr)
 Downloads content from a URL as a string.
 
int udpSendData (const std::string &sessionName, const uint8_t *data, uint32_t bufferLength, const std::string &targetIP, uint16_t targetPoint, std::optional< uint16_t > sourcePort=std::nullopt)
 Sends data over UDP.
 

Function Documentation

◆ checkInternetConnectionAndGetGMTTime()

std::tuple< bool, std::string, std::optional< TimePoint_System_Millisecond > > SystemTools::Net::checkInternetConnectionAndGetGMTTime ( bool  forceRefresh = false)

Checks internet connection and gets GMT time.

Parameters
forceRefreshWhether to force refresh the connection check.
Returns
A tuple containing the connection status, GMT time as a string, and a time point.

◆ curlDownload()

std::vector< uint8_t > SystemTools::Net::curlDownload ( const std::string &  url,
uint32_t  timeout_ms = 0,
long *  httpResponseCode = nullptr 
)

Downloads data from a URL.

Parameters
urlThe URL to download from.
timeout_msThe timeout in milliseconds.
httpResponseCodeOptional pointer to store the HTTP response code.
Returns
A vector of bytes containing the downloaded data.

◆ curlDownloadContentAsString()

std::string SystemTools::Net::curlDownloadContentAsString ( const std::string &  url,
uint32_t  timeout_ms = 0,
long *  httpResponseCode = nullptr 
)

Downloads content from a URL as a string.

Parameters
urlThe URL to download from.
timeout_msThe timeout in milliseconds.
httpResponseCodeOptional pointer to store the HTTP response code.
Returns
A string containing the downloaded content.

◆ curlDownloadNoBody()

std::vector< uint8_t > SystemTools::Net::curlDownloadNoBody ( const std::string &  url,
uint32_t  timeout_ms = 0,
long *  httpResponseCode = nullptr 
)

Downloads data from a URL without the body.

Parameters
urlThe URL to download from.
timeout_msThe timeout in milliseconds.
httpResponseCodeOptional pointer to store the HTTP response code.
Returns
A vector of bytes containing the downloaded data.

◆ hasInternetConnection()

bool SystemTools::Net::hasInternetConnection ( )

Checks if there is an internet connection.

Returns
True if there is an internet connection, false otherwise.

◆ udpSendData()

int SystemTools::Net::udpSendData ( const std::string &  sessionName,
const uint8_t *  data,
uint32_t  bufferLength,
const std::string &  targetIP,
uint16_t  targetPoint,
std::optional< uint16_t >  sourcePort = std::nullopt 
)

Sends data over UDP.

Parameters
sessionNameThe session name.
dataThe data to send.
bufferLengthThe length of the data buffer.
targetIPThe target IP address.
targetPointThe target port number.
sourcePortOptional source port number.
Returns
The number of bytes sent.