56 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			56 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| 
								 | 
							
								/****************************************************************************
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
							 | 
						||
| 
								 | 
							
								be copied by any method or incorporated into another program without
							 | 
						||
| 
								 | 
							
								the express written consent of Aerospace C.Power. This Information or any portion
							 | 
						||
| 
								 | 
							
								thereof remains the property of Aerospace C.Power. The Information contained herein
							 | 
						||
| 
								 | 
							
								is believed to be accurate and Aerospace C.Power assumes no responsibility or
							 | 
						||
| 
								 | 
							
								liability for its use in any way and conveys no license or title under
							 | 
						||
| 
								 | 
							
								any patent or copyright and makes no representation or warranty that this
							 | 
						||
| 
								 | 
							
								Information is free from patent or copyright infringement.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								****************************************************************************/
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "iot_io_api.h"
							 | 
						||
| 
								 | 
							
								#include "iot_errno_api.h"
							 | 
						||
| 
								 | 
							
								#include "iot_cli.h"
							 | 
						||
| 
								 | 
							
								#include "iot_cli_plc_tx_rx.h"
							 | 
						||
| 
								 | 
							
								#include "iot_cli_host_interface.h"
							 | 
						||
| 
								 | 
							
								#include "iot_cli_sg.h"
							 | 
						||
| 
								 | 
							
								#include "iot_cli_sg_api.h"
							 | 
						||
| 
								 | 
							
								#include "iot_cli_sg_ctrl_api.h"
							 | 
						||
| 
								 | 
							
								#include "iot_cli_ckq.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#if (IOT_CLI_SG_INTERFACE_ENABLE == 1)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								void cli_sg_ctrl_data_dl(uint8_t *buffer, uint32_t bufferlen,
							 | 
						||
| 
								 | 
							
								    uint8_t *src_mac)
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    iot_cli_sg_ctrl_data_dl_t *dl_data = (iot_cli_sg_ctrl_data_dl_t *)buffer;
							 | 
						||
| 
								 | 
							
								    iot_cli_sg_ctrl_data_dl_ack_t rsp;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    if ((!dl_data) || (bufferlen < sizeof(*dl_data))) {
							 | 
						||
| 
								 | 
							
								        return;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    if (bufferlen < (sizeof(*dl_data) + dl_data->data_len)) {
							 | 
						||
| 
								 | 
							
								        rsp.result = ERR_FAIL;
							 | 
						||
| 
								 | 
							
								    } else if ((dl_data->proto != IOT_CTRL_PROTO_SPG) &&
							 | 
						||
| 
								 | 
							
								        (dl_data->proto != IOT_CTRL_PROTO_3762)) {
							 | 
						||
| 
								 | 
							
								        /* invalid proto */
							 | 
						||
| 
								 | 
							
								        iot_printf("ctrl msg not support proto: %d \n", dl_data->proto);
							 | 
						||
| 
								 | 
							
								        rsp.result = ERR_FAIL;
							 | 
						||
| 
								 | 
							
								    } else {
							 | 
						||
| 
								 | 
							
								        rsp.app_sn = dl_data->app_sn;
							 | 
						||
| 
								 | 
							
								        rsp.result = ERR_OK;
							 | 
						||
| 
								 | 
							
								        iot_sg_cli_send_cmd(0, IOT_CLI_SG_CTRL_MSG_REQ_DATA_DL, buffer,
							 | 
						||
| 
								 | 
							
								            bufferlen);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								    iot_cli_send_to_host(CLI_MSGID_CTRL_DATA_DL_ACK, (uint8_t *)&rsp,
							 | 
						||
| 
								 | 
							
								        sizeof(rsp), src_mac);
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif /* (IOT_CLI_SG_INTERFACE_ENABLE == 1) */
							 |