TuyaOS
结构体 | 宏定义 | 类型定义 | 枚举 | 函数
svc_rpc.h 文件参考

rcp relate 更多...

#include <stdint.h>
#include "tuya_cloud_com_defs.h"
#include "tuya_slist.h"
#include "rpc_base.h"
#include "json_rpc.h"
#include "tal_thread.h"
svc_rpc.h 的引用(Include)关系图:
此图展示该文件直接或间接的被哪些文件引用了:

浏览源代码.

结构体

struct  tuya_rpc_t
 

宏定义

#define OPRT_RPC_CALL_ERROR   -11
 
#define OPRT_RPC_CALL_NOT_FOUND   -11
 
#define OPRT_RPC_CALL_TIMEOUT   -10
 
#define TUYA_RPC_DEFAULT_BUFSZ   256
 
#define TUYA_RPC_ID_LEN   (GW_ID_LEN)
 
#define TUYA_RPC_KEY_LEN   (LOCAL_KEY_LEN)
 

类型定义

typedef void(* rpc_async_cb) (jrpc_msg_t *result, void *arg)
 rpc async callback 更多...
 
typedef int(* rpc_crypt_cb) (uint8_t **data, uint32_t *len, uint8_t key[16], tuya_rpc_crypt_mode_t mode)
 
typedef void(* rpc_method_cb) (jrpc_msg_t *request, void *arg, jrpc_msg_t *reply)
 rpc method callback 更多...
 
typedef void(* rpc_subscribe_cb) (jrpc_msg_t *request, void *arg)
 rpc subscribe callback 更多...
 

枚举

enum  tuya_rpc_cmd_t { RPC_BUFSIZE_SET_CMD }
 
enum  tuya_rpc_crypt_mode_t { TUYA_RPC_ENCRYPT , TUYA_RPC_DECRYPT , TUYA_RPC_FREECRYPT }
 

函数

int tuya_rpc_call_async (tuya_rpc_t *rpc, char *id, jrpc_msg_t *requset, rpc_async_cb cb, void *arg, uint32_t sec)
 rpc asynchronous call 更多...
 
int tuya_rpc_call_notify (tuya_rpc_t *rpc, char *id, jrpc_msg_t *requset)
 rpc call notify 更多...
 
int tuya_rpc_call_sync (tuya_rpc_t *rpc, char *id, jrpc_msg_t *requset, jrpc_msg_t *reply, uint32_t sec)
 rpc synchronous call 更多...
 
int tuya_rpc_control (tuya_rpc_t *rpc, uint8_t cmd, void *arg)
 rpc control 更多...
 
int tuya_rpc_declare (tuya_rpc_t *rpc, char *name, rpc_method_cb cb, void *arg)
 declare one rpc according name 更多...
 
int tuya_rpc_init (tuya_rpc_t *rpc, char *id, char *addr)
 rpc function init 更多...
 
int tuya_rpc_publish (tuya_rpc_t *rpc, char *name, jrpc_msg_t *msg)
 publish one rpc 更多...
 
int tuya_rpc_run (tuya_rpc_t *rpc, uint32_t stack_size, uint32_t prio)
 create rpc task 更多...
 
int tuya_rpc_set_crypt (tuya_rpc_t *rpc, rpc_crypt_cb crypt_cb, uint8_t key[(LOCAL_KEY_LEN)])
 set encryption key and callback 更多...
 
int tuya_rpc_set_crypt_cb (tuya_rpc_t *rpc, rpc_crypt_cb crypt_cb)
 set encryption callback 更多...
 
int tuya_rpc_set_crypt_key (tuya_rpc_t *rpc, uint8_t key[(LOCAL_KEY_LEN)])
 set encryption key 更多...
 
int tuya_rpc_subscribe (tuya_rpc_t *rpc, char *id, char *name, rpc_subscribe_cb cb, void *arg)
 subscribe one rpc 更多...
 
int tuya_rpc_undeclare (tuya_rpc_t *rpc, char *name)
 undeclare one rpc according name 更多...
 
int tuya_rpc_unsubscribe (tuya_rpc_t *rpc, char *id, char *name)
 unsubscribe one rpc 更多...
 

详细描述

rcp relate

版本
0.1
日期
2015-05-27

类型定义说明

◆ rpc_async_cb

typedef void(* rpc_async_cb) (jrpc_msg_t *result, void *arg)

rpc async callback

参数
[in]resultmsg
[in]argrequest argument

◆ rpc_method_cb

typedef void(* rpc_method_cb) (jrpc_msg_t *request, void *arg, jrpc_msg_t *reply)

rpc method callback

参数
[in]requestmsg
[in]argrequest argument
[in]replyreply

◆ rpc_subscribe_cb

typedef void(* rpc_subscribe_cb) (jrpc_msg_t *request, void *arg)

rpc subscribe callback

参数
[in]requestmsg
[in]argrequest argument

函数说明

◆ tuya_rpc_call_async()

int tuya_rpc_call_async ( tuya_rpc_t rpc,
char *  id,
jrpc_msg_t requset,
rpc_async_cb  cb,
void *  arg,
uint32_t  sec 
)

rpc asynchronous call

参数
[in]rpcrpc handle
[in]idrpc id
[in]requsetrequest message
[in]cbasynchronous call back
[in]argcall parameter
[in]sectimeout seconds
注解
This API is used to rpc asynchronous call
返回
OPRT_OK when success. Others please refer to tuya_error_code.h

◆ tuya_rpc_call_notify()

int tuya_rpc_call_notify ( tuya_rpc_t rpc,
char *  id,
jrpc_msg_t requset 
)

rpc call notify

参数
[in]rpcrpc handle
[in]idrpc id
[in]requsetrequest message
注解
This API is used to rpc call notify
返回
OPRT_OK when success. Others please refer to tuya_error_code.h

◆ tuya_rpc_call_sync()

int tuya_rpc_call_sync ( tuya_rpc_t rpc,
char *  id,
jrpc_msg_t requset,
jrpc_msg_t reply,
uint32_t  sec 
)

rpc synchronous call

参数
[in]rpcrpc handle
[in]idrpc id
[in]requsetrequest message
[in]replyasynchronous reply message
[in]sectimeout seconds
注解
This API is used to rpc synchronous call
返回
OPRT_OK when success. Others please refer to tuya_error_code.h

◆ tuya_rpc_control()

int tuya_rpc_control ( tuya_rpc_t rpc,
uint8_t  cmd,
void *  arg 
)

rpc control

参数
[in]rpcrpc handle
[in]cmdcontrol command
[in]argcontrol parameter
注解
This API is used to control rpc function
返回
OPRT_OK when success. Others please refer to tuya_error_code.h

◆ tuya_rpc_declare()

int tuya_rpc_declare ( tuya_rpc_t rpc,
char *  name,
rpc_method_cb  cb,
void *  arg 
)

declare one rpc according name

参数
[in]rpcrpc handle
[in]namedeclare name
[in]cbcall back
[in]argcall back parameter
注解
This API is used to declare one rpc
返回
OPRT_OK when success. Others please refer to tuya_error_code.h

◆ tuya_rpc_init()

int tuya_rpc_init ( tuya_rpc_t rpc,
char *  id,
char *  addr 
)

rpc function init

参数
[in]rpcrpc handle
[in]idrpc id
[in]addrremote ip address
注解
This API is used to init rpc function
返回
OPRT_OK when success. Others please refer to tuya_error_code.h

◆ tuya_rpc_publish()

int tuya_rpc_publish ( tuya_rpc_t rpc,
char *  name,
jrpc_msg_t msg 
)

publish one rpc

参数
[in]rpcrpc handle
[in]namethe key name want to publish
[in]msgmsg
注解
This API is used to publish one rpc
返回
OPRT_OK when success. Others please refer to tuya_error_code.h

◆ tuya_rpc_run()

int tuya_rpc_run ( tuya_rpc_t rpc,
uint32_t  stack_size,
uint32_t  prio 
)

create rpc task

参数
[in]rpcrpc handle
[in]stack_sizetask stack size
[in]priotask prio
注解
This API is used to create rpc task
返回
OPRT_OK when success. Others please refer to tuya_error_code.h

◆ tuya_rpc_set_crypt()

int tuya_rpc_set_crypt ( tuya_rpc_t rpc,
rpc_crypt_cb  crypt_cb,
uint8_t  key[(LOCAL_KEY_LEN)] 
)

set encryption key and callback

参数
[in]rpcrpc handle
[in]crypt_cbencryption callback function
[in]keyencryption key
注解
This API is used to set encryption key and callback
返回
OPRT_OK when success. Others please refer to tuya_error_code.h

◆ tuya_rpc_set_crypt_cb()

int tuya_rpc_set_crypt_cb ( tuya_rpc_t rpc,
rpc_crypt_cb  crypt_cb 
)

set encryption callback

参数
[in]rpcrpc handle
[in]crypt_cbcallback
注解
This API is used to set encryption callback
返回
OPRT_OK when success. Others please refer to tuya_error_code.h

◆ tuya_rpc_set_crypt_key()

int tuya_rpc_set_crypt_key ( tuya_rpc_t rpc,
uint8_t  key[(LOCAL_KEY_LEN)] 
)

set encryption key

参数
[in]rpcrpc handle
[in]keyencryption key
注解
This API is used to set encryption key
返回
OPRT_OK when success. Others please refer to tuya_error_code.h

◆ tuya_rpc_subscribe()

int tuya_rpc_subscribe ( tuya_rpc_t rpc,
char *  id,
char *  name,
rpc_subscribe_cb  cb,
void *  arg 
)

subscribe one rpc

参数
[in]rpcrpc handle
[in]idrpc id
[in]namethe key name want to subscribe
[in]cbcallback
[in]argcallback paremater
注解
This API is used to subscribe one rpc
返回
OPRT_OK when success. Others please refer to tuya_error_code.h

◆ tuya_rpc_undeclare()

int tuya_rpc_undeclare ( tuya_rpc_t rpc,
char *  name 
)

undeclare one rpc according name

参数
[in]rpcrpc handle
[in]nameundeclare name
注解
This API is used to undeclare one rpc
返回
OPRT_OK when success. Others please refer to tuya_error_code.h

◆ tuya_rpc_unsubscribe()

int tuya_rpc_unsubscribe ( tuya_rpc_t rpc,
char *  id,
char *  name 
)

unsubscribe one rpc

参数
[in]rpcrpc handle
[in]idrpc id
[in]namethe key name want to subscribe
注解
This API is used to unsubscribe one rpc
返回
OPRT_OK when success. Others please refer to tuya_error_code.h