#include "erpc_core.h" #include "crc16.h" u32 erpc_report_node_self(node_cfg_t *node_cfg) { erpc_cmd_def_t cmd; cmd.src_id = node_cfg->local_id; cmd.dest_id = 0xFF; cmd.msg_len = 0; cmd.type = PACKAGE_TYPE_DEV_POWER_ON; cmd_cal_crc16(&cmd); return node_cfg->write((u8 *)&cmd, sizeof(erpc_cmd_def_t)); } u32 erpc_search_all_node(node_cfg_t *node_cfg) { erpc_cmd_def_t cmd; cmd.src_id = node_cfg->local_id; cmd.dest_id = 0xFF; cmd.msg_len = 0; cmd.type = PACKAGE_TYPE_CMD_SERCH_DEV_ONLINE; cmd_cal_crc16(&cmd); return node_cfg->write((u8 *)&cmd, sizeof(erpc_cmd_def_t)); } u32 erpc_send_cmd(node_cfg_t *node_cfg, u8 dest_id, u8 *data, u32 len) { erpc_cmd_def_t cmd; cmd.src_id = node_cfg->local_id; cmd.dest_id = dest_id; cmd.msg_len = len; cmd.type = PACKAGE_TYPE_CMD_REQ; cmd.data = data; cmd_cal_crc16(&cmd); return node_cfg->write((u8 *)&cmd, sizeof(erpc_cmd_def_t) + len); } u32 erpc_send_cmd_ack(node_cfg_t *node_cfg, erpc_cmd_def_t *cmd_rec, u8 is_ack) { erpc_cmd_def_t cmd_send; cmd_send.src_id = node_cfg->local_id; cmd_send.dest_id = cmd_rec->src_id; if (is_ack) cmd_send.type = PACKAGE_TYPE_CMD_REQ_ACK; else cmd_send.type = PACKAGE_TYPE_CMD_RESP_NACK; cmd_send.msg_len = 0; cmd_cal_crc16(&cmd_send); return node_cfg->write((u8 *)&cmd_send, sizeof(erpc_cmd_def_t)); } u32 erpc_send_repeat(node_cfg_t *node_cfg,u8 dest_id) { erpc_cmd_def_t cmd; cmd.src_id = node_cfg->local_id; cmd.dest_id = dest_id; cmd.type = PACKAGE_TYPE_CMD_REPEAT; cmd.msg_len = 0; cmd_cal_crc16(&cmd); return node_cfg->write((u8 *)&cmd, sizeof(erpc_cmd_def_t)); } u32 erpc_send_msg(node_cfg_t *node_cfg, u8 dest_id, u8 *data, u32 len) { int retry = CMD_MAX_RETRY; node_cfg->bus_lock(); u32 ret = 0; while (retry-- > 0) { u32 ret = erpc_send_cmd(node_cfg, dest_id, data, len); } return ret; } u32 erpc_rec_msg_core(node_cfg_t *node_cfg, u8 *data, u32 len) { }