ENTS-tock
Environmental NeTworked Sensor firmware on Tock OS
Loading...
Searching...
No Matches
Dirtviz Class Reference

Logic for interfacing with the Dirtviz API. More...

#include <dirtviz/include/dirtviz.hpp>

Public Member Functions

 Dirtviz (void)
 Construct a new Dirtviz object.
 
 Dirtviz (const char *url)
 Default constructor.
 
 ~Dirtviz ()
 Frees all memory.
 
void SetUrl (const char *url)
 Set new URL string.
 
unsigned int Check ()
 Health check for API endpoint.
 
unsigned int SendMeasurement (const uint8_t *meas, size_t meas_len)
 Send serialized measurement to the API.
 
HttpClient GetResponse ()
 Get the response from the server.
 

Detailed Description

Logic for interfacing with the Dirtviz API.

Assumes that WiFi interface is connected to the network. Uses http to read http requests. Requests are formatted ad-hoc.

Examples:

HTTP interface for Dirtviz API

Definition at line 43 of file dirtviz.hpp.

Constructor & Destructor Documentation

◆ Dirtviz() [1/2]

Dirtviz::Dirtviz ( void  )

Construct a new Dirtviz object.

Definition at line 27 of file dirtviz.cpp.

◆ Dirtviz() [2/2]

Dirtviz::Dirtviz ( const char *  url)
explicit

Default constructor.

Allows for setting of URL on initialization.

Parameters
urlAPI URL

Definition at line 29 of file dirtviz.cpp.

References SetUrl().

◆ ~Dirtviz()

Dirtviz::~Dirtviz ( )

Frees all memory.

Definition at line 31 of file dirtviz.cpp.

Member Function Documentation

◆ Check()

unsigned int Dirtviz::Check ( )

Health check for API endpoint.

Note
The path of the server health check is hardcoded to "/api/".
Returns
Number of bytes sent to the server

Definition at line 40 of file dirtviz.cpp.

References g_user_agent.

◆ GetResponse()

HttpClient Dirtviz::GetResponse ( )

Get the response from the server.

Returns
HTTP response

Definition at line 106 of file dirtviz.cpp.

References g_resp_timeout.

Referenced by loop().

◆ SendMeasurement()

unsigned int Dirtviz::SendMeasurement ( const uint8_t *  meas,
size_t  meas_len 
)

Send serialized measurement to the API.

Parameters
measPointer to serialized measurement data
meas_lenNumber of bytes in meas
Returns
Number of bytes sent to the server

Definition at line 64 of file dirtviz.cpp.

References buffer, and g_user_agent.

Referenced by loop().

◆ SetUrl()

void Dirtviz::SetUrl ( const char *  url)

Set new URL string.

Parameters
new_urlNew API URL

Definition at line 33 of file dirtviz.cpp.

Referenced by Dirtviz().


The documentation for this class was generated from the following files: