#ifndef __RPC_API_H
#define __RPC_API_H
#include "yjq_ezsp.h"
#include <stdio.h>
#include <pthread.h>



#include "./jsonrpc/jsonrpc-c.h"
#include "./jsonrpc/rpccJSON.h"

#define MSG_PARSE_ERROR  "Parse error"
#define MSG_INVALID_REQUEST  "Invalid Request"
#define MSG_METHOD_NOT_FOUND  "Method not found"
#define MSG_INVALID_PARAMS  "Invalid params"
#define MSG_INTERNAL_ERROR  "Internal error"

extern pthread_mutex_t g_mutex_lock;

void zclBufferSetup(uint8_t frameType, uint16_t clusterId, uint8_t commandId);

#define zcl_clu_client_cmd_buffer_setup(clu, cmd)                                     \
	zclBufferSetup(ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_CLIENT_TO_SERVER, \
					(clu),                                                            \
					(cmd))

#define zcl_clu_server_cmd_buffer_setup(clu, cmd)                                     \
	zclBufferSetup(ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT, \
					(clu),                                                            \
					(cmd))

void rpcBufferPrint(void);
EmberStatus rpcSendCommand(uint16_t destination,uint8_t srcEndpoint,uint8_t dstEndpoint,bool multicast);

typedef struct{
	uint8_t *buffer;
	uint8_t *len;
	bool AStringType;
}rpc_read_attr_s;


char rpc_convert_char(char ch);
uint8_t rpc_get_u8(char *string);
uint16_t rpc_get_u16(char *string);

EmberAfStatus ReadAttr(uint16_t node,
								uint8_t endpoint,
								EmberAfClusterId cluster,
								EmberAfAttributeId attribute,
								bool serverAttribute,
								rpc_read_attr_s *dataBuff);

cJSON *rpc_ReadAttr(jrpc_context * ctx, cJSON * params, cJSON *id);


#define RPC_COMMON_FUNCTION_TABLE	\
	{rpc_ReadAttr,"ReadAttr"}\


extern uint8_t appZclBuffer[];
extern uint16_t appZclBufferLen;
extern uint16_t mfgSpecificId ;
extern uint8_t disableDefaultResponse ;

extern EmberApsFrame globalApsFrame;





















#endif

