Golioth Firmware SDK
golioth_rpc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 Golioth, Inc.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #pragma once
7 
8 #include <cJSON.h>
9 #include "golioth_status.h"
10 #include "golioth_client.h"
11 #include "golioth_config.h"
12 
16 
18 typedef enum {
19  RPC_OK = 0,
37 
73  const char* method,
74  const cJSON* params,
75  uint8_t* detail,
76  size_t detail_size,
77  void* callback_arg);
78 
90  golioth_client_t client,
91  const char* method,
92  golioth_rpc_cb_fn callback,
93  void* callback_arg);
94 
96 typedef struct {
97  const char* method;
99  void* callback_arg;
101 
104 typedef struct {
106  int num_rpcs;
107 } golioth_rpc_t;
108 
#define CONFIG_GOLIOTH_RPC_MAX_NUM_METHODS
golioth_status_t
void * golioth_client_t
Opaque handle to the Golioth client.
golioth_rpc_status_t
Enumeration of RPC status codes, sent in the RPC response.
Definition: golioth_rpc.h:18
golioth_rpc_status_t(* golioth_rpc_cb_fn)(const char *method, const cJSON *params, uint8_t *detail, size_t detail_size, void *callback_arg)
Definition: golioth_rpc.h:72
golioth_status_t golioth_rpc_register(golioth_client_t client, const char *method, golioth_rpc_cb_fn callback, void *callback_arg)
@ RPC_UNAUTHENTICATED
Definition: golioth_rpc.h:35
@ RPC_RESOURCE_EXHAUSTED
Definition: golioth_rpc.h:27
@ RPC_NOT_FOUND
Definition: golioth_rpc.h:24
@ RPC_FAILED_PRECONDITION
Definition: golioth_rpc.h:28
@ RPC_UNKNOWN
Definition: golioth_rpc.h:21
@ RPC_UNAVAILABLE
Definition: golioth_rpc.h:33
@ RPC_DATA_LOSS
Definition: golioth_rpc.h:34
@ RPC_OUT_OF_RANGE
Definition: golioth_rpc.h:30
@ RPC_DEADLINE_EXCEEDED
Definition: golioth_rpc.h:23
@ RPC_PERMISSION_DENIED
Definition: golioth_rpc.h:26
@ RPC_INVALID_ARGUMENT
Definition: golioth_rpc.h:22
@ RPC_INTERNAL
Definition: golioth_rpc.h:32
@ RPC_ALREADYEXISTS
Definition: golioth_rpc.h:25
@ RPC_OK
Definition: golioth_rpc.h:19
@ RPC_UNIMPLEMENTED
Definition: golioth_rpc.h:31
@ RPC_ABORTED
Definition: golioth_rpc.h:29
@ RPC_CANCELED
Definition: golioth_rpc.h:20
Private struct to contain data about a single registered method.
Definition: golioth_rpc.h:96
const char * method
Definition: golioth_rpc.h:97
golioth_rpc_cb_fn callback
Definition: golioth_rpc.h:98