File espos_sk_http.h¶
FileList > espos_sk > include > espos_sk_http.h
Go to the source code of this file
#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include "esp_err.h"
Classes¶
| Type | Name |
|---|---|
| struct | espos_sk_http_opts_t Zeroed (or NULL) = 6000 ms, 16 KiB, Bearer on, 401/403 reported, Accept: application/json. |
| struct | espos_sk_http_resp_t |
Public Functions¶
| Type | Name |
|---|---|
| esp_err_t | espos_sk_get_meta (const char * sk_path, char ** out_json) The path's meta object (GET .../meta) as JSON text (malloc'ed). |
| esp_err_t | espos_sk_get_value (const char * sk_path, char ** out_json) Current value of a vessels.self path ("navigation.speedOverGround" -> GET /signalk/v1/api/vessels/self/navigation/speedOverGround), handed back as the JSON text of the node's "value" member (malloc'ed; a number, string, object or "null" whatever the server holds). |
| esp_err_t | espos_sk_http_delete (const char * path, const espos_sk_http_opts_t * o, espos_sk_http_resp_t * r) |
| esp_err_t | espos_sk_http_get (const char * path, const espos_sk_http_opts_t * o, espos_sk_http_resp_t * r) One request to the selected server. |
| esp_err_t | espos_sk_http_post (const char * path, const char * json, const espos_sk_http_opts_t * o, espos_sk_http_resp_t * r) |
| esp_err_t | espos_sk_http_put (const char * path, const char * json, const espos_sk_http_opts_t * o, espos_sk_http_resp_t * r) |
| void | espos_sk_http_resp_free (espos_sk_http_resp_t * r) Frees the body and zeroes the struct; safe on a zeroed or failed reply. |
| esp_err_t | espos_sk_url (const char * path, char * out, size_t n) "http(s)://host:port/path" for the selected server (a missing leading slash is added; the path is otherwise used verbatim). |
| esp_err_t | espos_sk_ws_url (const char * path, char * out, size_t n) "ws(s)://host:port/path", same rules. |
Macros¶
| Type | Name |
|---|---|
| define | ESPOS_SK_URL_MAX 384Fits any "scheme://host:port/path" espos_sk_url() builds: path up to ~300. |
Public Functions Documentation¶
function espos_sk_get_meta¶
The path's meta object (GET .../meta) as JSON text (malloc'ed).
ESP_ERR_NOT_FOUND when the server has none: a 404, or a 200 whose body is not a JSON object (seen for paths a server exposes without meta). Other errors as espos_sk_get_value().
function espos_sk_get_value¶
Current value of a vessels.self path ("navigation.speedOverGround" -> GET /signalk/v1/api/vessels/self/navigation/speedOverGround), handed back as the JSON text of the node's "value" member (malloc'ed; a number, string, object or "null" whatever the server holds).
What a display needs for a path whose value rarely changes: the stream only carries changes, the REST node has the reading now.
ESP_ERR_NOT_FOUND: 404, or the node has no "value" member; ESP_ERR_NOT_ALLOWED: 401/403 (reported to the token machine); ESP_ERR_INVALID_RESPONSE: not JSON; ESP_ERR_INVALID_SIZE: over 16 KiB; ESP_FAIL: any other status; transport errors as above.
function espos_sk_http_delete¶
esp_err_t espos_sk_http_delete (
const char * path,
const espos_sk_http_opts_t * o,
espos_sk_http_resp_t * r
)
function espos_sk_http_get¶
One request to the selected server.
esp_err_t espos_sk_http_get (
const char * path,
const espos_sk_http_opts_t * o,
espos_sk_http_resp_t * r
)
path is absolute ("/signalk/v1/..."), json (PUT/POST) is sent as application/json, NULL = no body.
Returns ESP_OK whenever a reply arrived check r->status, a 404 or 500 is a successful call. Otherwise ESP_ERR_INVALID_STATE (no server), ESP_ERR_TIMEOUT (no slot within timeout_ms), ESP_ERR_NO_MEM, or the transport error esp_http_client reported (unreachable, TLS refused, timed out on the wire). Always espos_sk_http_resp_free(r) afterwards.
function espos_sk_http_post¶
esp_err_t espos_sk_http_post (
const char * path,
const char * json,
const espos_sk_http_opts_t * o,
espos_sk_http_resp_t * r
)
function espos_sk_http_put¶
esp_err_t espos_sk_http_put (
const char * path,
const char * json,
const espos_sk_http_opts_t * o,
espos_sk_http_resp_t * r
)
function espos_sk_http_resp_free¶
Frees the body and zeroes the struct; safe on a zeroed or failed reply.
function espos_sk_url¶
"http(s)://host:port/path" for the selected server (a missing leading slash is added; the path is otherwise used verbatim).
ESP_ERR_NOT_FOUND without a server, ESP_ERR_INVALID_SIZE when it does not fit in n.
function espos_sk_ws_url¶
"ws(s)://host:port/path", same rules.
Macro Definition Documentation¶
define ESPOS_SK_URL_MAX¶
Fits any "scheme://host:port/path" espos_sk_url() builds: path up to ~300.
The documentation for this class was generated from the following file espos_sk/include/espos_sk_http.h