Documentation

Documentation

Includes

rpc_udp.h

#include "rpc_udp.h"
#include "rpc_udp.h"

tuya_cloud_com_defs.h

#include "tuya_cloud_com_defs.h"
#include "tuya_cloud_com_defs.h"

tuya_cloud_types.h

#include "tuya_cloud_types.h"
#include "tuya_cloud_types.h"

Macros

Marco __LAN_RPC_H__

#define __LAN_RPC_H__


      

Marco LAN_RPC_ID_LEN

#define LAN_RPC_ID_LEN                 (GW_ID_LEN)


      

Marco LAN_RPC_KEY_LEN

#define LAN_RPC_KEY_LEN                (LOCAL_KEY_LEN)


      

Marco LAN_RPC_NODE_TIMEOUT

#define LAN_RPC_NODE_TIMEOUT            20


      

Marco LAN_RPC_NODE_ADD

#define LAN_RPC_NODE_ADD                0  


      

Marco LAN_RPC_NODE_DEL

#define LAN_RPC_NODE_DEL                1 


      

Marco LAN_RPC_NODE_REJOIN

#define LAN_RPC_NODE_REJOIN             2

      

Functions

Func lan_rpc_fd_get

INT_T lan_rpc_fd_get(VOID);
/**
 * @brief get fd
 *
 * @return fd value
 */

Func lan_rpc_node_timeout_check

VOID lan_rpc_node_timeout_check(VOID);
/**
 * @brief check timeout
 * 
 */

Func lan_rpc_node_add

OPERATE_RET lan_rpc_node_add(LAN_RPC_NODE_S *node);
/**
 * @brief node add
 * 
 * @param[in] node node value
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func lan_rpc_node_find_by_ip

BOOL_T lan_rpc_node_find_by_ip(UINT_T ip, LAN_RPC_NODE_S *node);
/**
 * @brief found node by ip
 * 
 * @param[in] ip key ip
 * @param[out] node result node
 *
 * @return found TRUE,else false
 */

Func lan_rpc_node_find_ip_by_id

BOOL_T lan_rpc_node_find_ip_by_id(UINT8_T *id, UINT_T *ip);
/**
 * @brief found ip by id
 * 
 * @param[in] id node id
 * @param[out] ip result ip
 *
 * @return found TRUE,else false
 */

Func lan_rpc_node_key_set

OPERATE_RET lan_rpc_node_key_set(UINT8_T *id, UINT8_T *key);
/**
 * @brief node key set
 * 
 * @param[in] id node id
 * @param[in] key key value
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func lan_rpc_node_output

OPERATE_RET lan_rpc_node_output(LAN_RPC_NODE_OUTPUT_CB node_output_cb, VOID *arg);
/**
 * @brief node output
 * 
 * @param[in] node_output_cb refer to LAN_RPC_NODE_OUTPUT_CB
 * @param[in] arg argument
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func lan_rpc_session_key_set

OPERATE_RET lan_rpc_session_key_set(UINT8_T *session_key);
/**
 * @brief set session key
 * 
 * @param[in] session_key key value
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func lan_rpc_init

OPERATE_RET lan_rpc_init(LAN_RPC_CFG_S *cfg);
/**
 * @brief rpc init
 * 
 * @param[in] cfg refer to LAN_RPC_CFG_S
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func lan_rpc_slave_call_sync

OPERATE_RET lan_rpc_slave_call_sync(JRPC_MSG_S *requset, JRPC_MSG_S *result, UINT_T timeout);
/**
 * @brief slave rpc sync
 * 
 * @param[in] requset refer to JRPC_MSG_S
 * @param[in] result refer to JRPC_MSG_S
 * @param[in] timeout timeout
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func lan_rpc_master_call_sync

OPERATE_RET lan_rpc_master_call_sync(UINT8_T *id, JRPC_MSG_S *requset, JRPC_MSG_S *result, UINT_T timeout);
/**
 * @brief master rpc sync
 * 
 * @param[in] id node id
 * @param[in] requset refer to JRPC_MSG_S
 * @param[in] result refer to JRPC_MSG_S
 * @param[in] timeout timeout
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func lan_rpc_call_async

OPERATE_RET lan_rpc_call_async(UINT8_T *id, JRPC_MSG_S *requset, RPC_RET_CB cb, VOID *cb_param, UINT_T timeout);
/**
 * @brief rpc sync
 * 
 * @param[in] id node id
 * @param[in] requset refer to JRPC_MSG_S
 * @param[in] cb callback function
 * @param[in] cb_param callback argument
 * @param[in] timeout timeout
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func lan_rpc_recv

OPERATE_RET lan_rpc_recv(VOID);
/**
 * @brief rpc receive
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Func lan_rpc_method_register

OPERATE_RET lan_rpc_method_register(CHAR_T *name, RPC_METHOD_CB cb, VOID *arg);
/**
 * @brief lan rpc method register
 * 
 * @param[in] name key name
 * @param[in] cb callback function
 * @param[in] arg callback argument
 *
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */

Vars

Consts

Types

Typedefs

Typedef LAN_RPC_TYPE;

typedef enum {
   LAN_RPC_SLAVER,
   LAN_RPC_MASTER,
} LAN_RPC_TYPE;


      

Typedef LAN_RPC_NODE_S;

typedef struct {
   UINT_T             ip;
   INT_T              seqno;
   USHORT_T           cap;
   UINT8_T            id[LAN_RPC_ID_LEN + 1];
   UINT8_T            key[LAN_RPC_KEY_LEN + 1]; //key是非字符串的
} LAN_RPC_NODE_S;


      

Typedef LAN_RPC_MASTER_S;

typedef struct {
   UINT8_T            owner;
   UINT8_T            stat;
   LAN_RPC_NODE_S     node;
} LAN_RPC_MASTER_S;


      

Typedef LAN_RPC_MASTER_GET_CB

typedef OPERATE_RET (*LAN_RPC_MASTER_GET_CB)(LAN_RPC_MASTER_S *master);


      

Typedef LAN_RPC_NODE_STAT_CB

typedef OPERATE_RET (*LAN_RPC_NODE_STAT_CB)(UINT8_T stat, LAN_RPC_NODE_S *node);


      

Typedef LAN_RPC_NODE_OUTPUT_CB

typedef VOID (*LAN_RPC_NODE_OUTPUT_CB)(LAN_RPC_NODE_S *node, UINT16_T num, VOID *arg);


      

Typedef LAN_RPC_CFG_S;

typedef struct {
   UINT8_T                type;
   LAN_RPC_NODE_STAT_CB   node_stat_cb;
   LAN_RPC_MASTER_GET_CB  master_get_cb;
} LAN_RPC_CFG_S;