Skip to content

File espos_sk_parse.h

FileList > espos_sk > include > espos_sk_parse.h

Go to the source code of this file

  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct espos_sk_frame_t
struct espos_sk_update_t
One value or meta item taken out of a delta message.

Public Types

Type Name
enum espos_sk_frame_kind_t
typedef bool(* espos_sk_update_cb_t
Return false to stop iterating.

Public Functions

Type Name
void espos_sk_frame_free (espos_sk_frame_t * info)
size_t espos_sk_frame_parse (const char * json, size_t len, espos_sk_frame_t * info, espos_sk_update_cb_t cb, void * arg)
Parse one text frame.
bool espos_sk_path_matches (const char * pattern, const char * path)
Path pattern match: exact, or "prefix.*" / "prefix*" / "*".
char * espos_sk_put_response_frame (const char * request_id, const char * state, int status_code, const char * message)
Build the response frame for an inbound PUT: the JSON a device sends back so signalk-server can resolve the request.

Public Types Documentation

enum espos_sk_frame_kind_t

enum espos_sk_frame_kind_t {
    ESPOS_SK_FRAME_UNKNOWN = 0,
    ESPOS_SK_FRAME_HELLO,
    ESPOS_SK_FRAME_DELTA,
    ESPOS_SK_FRAME_RESPONSE,
    ESPOS_SK_FRAME_ERROR,
    ESPOS_SK_FRAME_PUT
};

typedef espos_sk_update_cb_t

Return false to stop iterating.

typedef bool(* espos_sk_update_cb_t) (const espos_sk_update_t *u, void *arg);


Public Functions Documentation

function espos_sk_frame_free

void espos_sk_frame_free (
    espos_sk_frame_t * info
) 

function espos_sk_frame_parse

Parse one text frame.

size_t espos_sk_frame_parse (
    const char * json,
    size_t len,
    espos_sk_frame_t * info,
    espos_sk_update_cb_t cb,
    void * arg
) 

Fills *info (kind + fields, valid until espos_sk_frame_free) and calls cb for every item it carries:

DELTA โ€” every value and every meta item, in order, request_id NULL. PUT โ€” every {"path","value"} of the request, each with request_id set to the frame's requestId, so a handler knows what to answer. value_json is the JSON text of the new value.

Returns the number of items delivered (0 for other frames or malformed input; kind says which).


function espos_sk_path_matches

Path pattern match: exact, or "prefix.*" / "prefix*" / "*".

bool espos_sk_path_matches (
    const char * pattern,
    const char * path
) 


function espos_sk_put_response_frame

Build the response frame for an inbound PUT: the JSON a device sends back so signalk-server can resolve the request.

char * espos_sk_put_response_frame (
    const char * request_id,
    const char * state,
    int status_code,
    const char * message
) 

state must be "COMPLETED" or "PENDING". signalk-server accepts nothing else on this path its isWsRequestReply() (src/interfaces/ws.ts) tests for exactly those two (or null) and silently ignores any other reply, which reads to the client as a request that timed out 60 s later. A failure is COMPLETED with a 4xx/5xx statusCode, NOT a "FAILED" state.

Returns a malloc'ed string the caller frees, or NULL.



The documentation for this class was generated from the following file espos_sk/include/espos_sk_parse.h