| | |
| | | #include "AES128.h" |
| | | #include "system_general_para.h" |
| | | #include "linked_list.h" |
| | | #include "uart.h" |
| | | #include "sizhu_event_record.h" |
| | | #include "sizhu_history_record.h" |
| | | #include "bootloader_iap.h" |
| | | |
| | | static SIZHU_V4_PROTOCOL_HEAD_T protocol_head_up_g ={.frame_start_code = SIZHU_FRAME_HEAD,.data_start_code = SIZHU_DATA_HEAD}; |
| | | static SIZHU_V4_PROTOCOL_NORMAL_DATA_HEAD_T up_data_head_g; |
| | | static SIZHU_V4_PROTOCOL_TAIL_T proto_tail_up_g = {.frame_end_code = SIZHU_FRAME_TAIL}; |
| | | static SIZHU_V4_REPORT_CTRL_PARA_T report_ctrl_para_g; |
| | | static SIZHU_V4_REPORT_CTRL_PARA_T __attribute__ ((aligned (4))) report_ctrl_para_g; |
| | | ErrorStatus wrc_sizhuV4_result_flag = FAIL; //×îÖÕµÄͨѶ½á¹ûÅжϣ¬³õʼÖÃFAIL£¬×îÖÕ¸ù¾ÝÐÒéÈ·Èϱ¾´ÎͨѶÊÇ·ñ³É¹¦£¬±ÈÈç˼ÖþµÄÐÒéͨ¹ý½áÊøÖ¡ÅжÏÊÇ·ñ×îÖճɹ¦ |
| | | ErrorStatus report_sizhuV4_result_flag = FAIL; //Éϱ¨ÊÇ·ñ³É¹¦±êÖ¾£¬ÓÃÓÚÒ»ÌìÖ®ÄÚÓÐûÓÐÉÏ´«³É¹¦¹ý£¬¸úwrc_sizhuV4_result_flagͨѶÊÇ·ñ³É¹¦²»Ò»Ñù£¬¿íËÉÒ»µã£¬Ö»ÒªÊý¾ÝÉϱ¨ÏìÓ¦³É¹¦¼´´ú±íÉϱ¨³É¹¦£¬ÊÕµ½½áÊøÖ¡Ò²´ú±í³É¹¦ |
| | | |
| | | //static uint16_t current_report_data_num = 0; |
| | | |
| | |
| | | uint32_t read_start_addr ; |
| | | //?»ñÈ¡ÆðʼµØÖ·£¬Ã»Ð´Íê |
| | | read_start_addr = current_save_addr; |
| | | if(data_num == 0) |
| | | return read_start_addr; |
| | | |
| | | while(data_num--){ |
| | | if(read_start_addr <= HISTORY_INTERVAL_START_ADDR){ |
| | | read_start_addr = HISTORY_INTERVAL_END_ADDR; |
| | | }else{ |
| | | read_start_addr -= HISTORY_INTERVAL_LENGTH; |
| | | } |
| | | } |
| | | return read_start_addr; |
| | | } |
| | | |
| | | |
| | | //´Ó´æ´¢ÀïÃæ¶ÁÈ¡Êý¾Ý£¬Í¬Ê±µØÖ·Ö¸ÏòºóÒ»ÌõÊý¾Ý |
| | | void ReadDataFromRecord(uint32_t * read_addr ,uint8_t *buf) |
| | | { |
| | | SIZHU_HISTORY_INTERVAL_T history_interval_l; |
| | | SIZHU_V4_PROTOCOL_NORMAL_DATA_PACK_T up_data_pack_l; |
| | | //?´Ó´æ´¢ÀïÃæ¶ÁÈ¡Êý¾Ýµ½buf,Èç¹ûÅжϴ洢¶ÁÈ¡µÄÊý¾ÝÒì³££¬ÔòÌî³ä0»òÕßÈÝÒ×ʶ±ðµÄÊý¾Ý |
| | | //read_addr++ |
| | | if(FlashMultipleReadAndCrcCheck((uint8_t *)&history_interval_l,*read_addr,HISTORY_INTERVAL_LENGTH)== PASS){ |
| | | arrayA_2_arrayB((uint8_t *)&history_interval_l.record_time_BCD, (uint8_t *)&up_data_pack_l.sample_time, sizeof(up_data_pack_l.sample_time), LITTLE_ENDIAN); |
| | | up_data_pack_l.sc_cumulate = history_interval_l.forward_cumulate_sc * 10000; |
| | | up_data_pack_l.wc_cumulate = history_interval_l.forward_cumulate_wc * 10000; |
| | | up_data_pack_l.sc_instant = history_interval_l.instant_sc * 10000; |
| | | up_data_pack_l.wc_instant = history_interval_l.instant_wc * 10000; |
| | | up_data_pack_l.pressure = history_interval_l.pressure; |
| | | up_data_pack_l.temperature = history_interval_l.temperature; |
| | | up_data_pack_l.balance = history_interval_l.residual_amount * 1000; |
| | | up_data_pack_l.uint_price = history_interval_l.current_price; |
| | | up_data_pack_l.lith_vcc = history_interval_l.lith_bat_v; |
| | | up_data_pack_l.lith_vcc_per = history_interval_l.lith_bat_per; |
| | | up_data_pack_l.alka_vcc = history_interval_l.alka_bat_v; |
| | | up_data_pack_l.alka_vcc_per = history_interval_l.alka_bat_per; |
| | | arrayA_2_arrayB((uint8_t *)&history_interval_l.status_word, (uint8_t *)&up_data_pack_l.status, 12, LITTLE_ENDIAN); |
| | | |
| | | arrayA_2_arrayB((uint8_t *)&up_data_pack_l, buf, DATA_PACKET_LENGTH, LITTLE_ENDIAN); |
| | | }else{ |
| | | memset(buf,0,DATA_PACKET_LENGTH); |
| | | } |
| | | |
| | | if(*read_addr >= HISTORY_INTERVAL_END_ADDR){ |
| | | *read_addr = HISTORY_INTERVAL_START_ADDR; |
| | | }else{ |
| | | *read_addr += HISTORY_INTERVAL_LENGTH; |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | /*ͨѶÏà¹Ø*/ |
| | | wrc_ctrl_para_g.time_out_time_sec = wrc_para_sizhu_g.comm_timeout_time; //³¬Ê±Ê±¼ä |
| | | wrc_sizhuV4_result_flag = FAIL; |
| | | wrc_ctrl_para_g.wrc_restart_time_sec_cnt = wrc_para_sizhu_g.retransmission_interval ; //ÖÃÖØ±¨¼ä¸ôʱ¼ä |
| | | wrc_ctrl_para_g.wrc_restart_time_sec_cnt = wrc_para_sizhu_g.retransmission_interval * 60 ; //ÖÃÖØ±¨¼ä¸ôʱ¼ä |
| | | |
| | | /*ÐÒéÏà¹Ø*/ |
| | | protocol_head_up_g.frame_start_code = SIZHU_FRAME_HEAD; |
| | |
| | | #else |
| | | report_ctrl_para_g.current_report_data_num = wrc_data_num_ctrl_para_sizhu_g.report_data_save_num + wrc_data_num_ctrl_para_sizhu_g.report_data_left_num ; |
| | | report_ctrl_para_g.current_report_data_num = (report_ctrl_para_g.current_report_data_num > ONCE_REPORT_MAX_NUM)? ONCE_REPORT_MAX_NUM:report_ctrl_para_g.current_report_data_num; //ÏÞÖÆÉϱ¨ÌõÊý |
| | | //? report_ctrl_para_g.report_data_read_addr = (current_save_addr,report_ctrl_para_g.current_report_data_num); |
| | | report_ctrl_para_g.report_data_read_addr = DataReadAddrInit(log_sizhu_history_ctrl_g.per_interval_log.log_addr_save,report_ctrl_para_g.current_report_data_num); |
| | | wrc_data_num_ctrl_para_sizhu_g.report_data_save_num =0 ; |
| | | wrc_data_num_ctrl_para_sizhu_g.report_data_left_num = report_ctrl_para_g.current_report_data_num; |
| | | //?wrc_data_num_ctrl_para_sizhu_g´æ´¢ |
| | |
| | | { |
| | | uint8_t yushu; |
| | | uint8_t fill_num; |
| | | uint16_t Encrypt_Bytes= 0; |
| | | |
| | | if((KeyVer&0x7f) > 8) |
| | | return; |
| | | |
| | | // *length = ((*length % 16 )!=0) ? ((*length >>4) + 1)*16 : *length; |
| | | /*²»ÊÇ16ÕûÊý±¶£¬ÔòÌî³äÖÁ16µÄÕûÊý±¶£¬È±N¸öÌî³äN¸öN*/ |
| | | yushu = (*length) & 0x0f; |
| | | Encrypt_Bytes = *length; |
| | | yushu = Encrypt_Bytes & 0x0f; |
| | | if(yushu != 0){ |
| | | fill_num = 16 - yushu; |
| | | for(uint8_t count_i=0;count_i < fill_num ;count_i ++){ |
| | | *(buf_in + *length + count_i) = fill_num; |
| | | *(buf_in + Encrypt_Bytes + count_i) = fill_num; |
| | | } |
| | | *length = ((*length >>4) + 1) <<4; |
| | | *length = ((Encrypt_Bytes >>4) + 1) <<4; |
| | | } |
| | | |
| | | //°´16¸öΪһ×é½øÐмÓÃÜ |
| | |
| | | uint16_t SizhuV4SendNormalData2buf(uint8_t * send_buf) |
| | | { |
| | | // uint8_t send_buf[1024] = {0}; |
| | | uint16_t data_length =0; |
| | | uint16_t crc_addr; |
| | | uint8_t current_frame_data_num; |
| | | SIZHU_V4_PROTOCOL_NORMAL_DATA_PACK_T one_pack_data; |
| | | |
| | | arrayA_2_arrayB((uint8_t*)&sys_clockBCD_g, (uint8_t*)&protocol_head_up_g.device_time, 8, LITTLE_ENDIAN); |
| | | arrayA_2_arrayB((uint8_t*)&sys_clockBCD_g, (uint8_t*)&protocol_head_up_g.device_time, sizeof(sys_clockBCD_g), LITTLE_ENDIAN); |
| | | // arrayA_2_arrayB((uint8_t*)system_alarm_word_g.alarm_word_union, (uint8_t*)&up_data_head_g.alarm_word, 14, LITTLE_ENDIAN); //ʱ¼äºÍ±¨¾¯×Ö»áËæÊ±¸üУ¬ËùÒÔ·ÅÔÚÉϱ¨Ç°¸³Öµ |
| | | //ÔÚËùÓб¨¾¯×Ö¶¼ÊǽöÕ¼1¸öBitµÄÇé¿öÏ£¬¿ÉÒÔÓûò|À´µþ¼Ó±¨¾¯£¬ÕâÑù¿ÉÒÔ½«ÉÏ´ÎδÉϱ¨³É¹¦±¨¾¯×Öµþ¼Óеı¨¾¯×Ö¼ÌÐøÉϱ¨ |
| | | for(uint8_t count_i =0;count_i < 7;count_i ++){ |
| | |
| | | one_pack_data.temperature = flow_meter_data_g.temperature; |
| | | one_pack_data.balance = save_realtime_data_g.realtime_billing_data_s.balance_now * 1000 ; |
| | | one_pack_data.uint_price = save_realtime_data_g.realtime_billing_data_s.price_now; |
| | | one_pack_data.lith_vcc = pwr_vol_g.lith_vcc; |
| | | one_pack_data.lith_vcc = pwr_vol_g.lith_vcc * 10; |
| | | one_pack_data.lith_vcc_per = pwr_vol_g.lith_synthesize_per; |
| | | one_pack_data.alka_vcc = pwr_vol_g.alka_vcc; |
| | | one_pack_data.alka_vcc = pwr_vol_g.alka_vcc * 10; |
| | | one_pack_data.alka_vcc_per = pwr_vol_g.alka_vcc_per; |
| | | arrayA_2_arrayB((uint8_t*)&system_status_word_g.status_word_union, (uint8_t*)&one_pack_data.status, 12, LITTLE_ENDIAN); |
| | | |
| | | arrayA_2_arrayB((uint8_t*)&one_pack_data, (uint8_t*)&send_buf[FIRST_DATA_SHIFT_SIZHU + DATA_PACKET_HEAD_LENGTH], DATA_PACKET_LENGTH, LITTLE_ENDIAN); |
| | | |
| | | #else |
| | | //?´Ó´æ´¢ÀïÃæ¶ÁÈ¡¶³½á¼Ç¼½øÐÐÉϱ¨ |
| | | |
| | | //´Ó´æ´¢ÀïÃæ¶ÁÈ¡¼ä¸ô¶³½á¼Ç¼½øÐÐÉϱ¨ |
| | | current_frame_data_num = (protocol_head_up_g.frame_num < protocol_head_up_g.frame_sum)? FRAME_DATA_MAX:report_ctrl_para_g.last_frame_data_num; |
| | | |
| | | for(uint8_t count_i =0;count_i < current_frame_data_num;count_i++ ){ |
| | |
| | | |
| | | //¼ÓÃÜ |
| | | if((protocol_head_up_g.key_ver & 0x80) == 0x80){ |
| | | DataAes128EcbEncrypt(protocol_head_up_g.key_ver,(uint8_t*)&send_buf[FIRST_DATA_SHIFT_SIZHU],(uint8_t*)&send_buf[FIRST_DATA_SHIFT_SIZHU],&protocol_head_up_g.data_length); |
| | | data_length = protocol_head_up_g.data_length; |
| | | DataAes128EcbEncrypt(protocol_head_up_g.key_ver,(uint8_t*)&send_buf[FIRST_DATA_SHIFT_SIZHU],(uint8_t*)&send_buf[FIRST_DATA_SHIFT_SIZHU],&data_length); |
| | | protocol_head_up_g.data_length = data_length; //¼ÓÃÜÐèÒªÌî³ä£¬³¤¶È»á±ä |
| | | } |
| | | |
| | | //ÓÉÓÚ¼ÓÃÜÌî³ä»áµ¼ÖÂÊý¾Ý³¤¶È±ä»¯£¬ËùÒÔÖ¡Í·µÄ×ªÒÆÐèÒª·ÅÔÚ¼ÓÃÜÖ®ºó |
| | |
| | | WRC_STATUS return_code = WRC_WAIT_REC_DATA; |
| | | if(*receive_buf == 0x00){ |
| | | //ÏàÓ¦³É¹¦ |
| | | report_sizhuV4_result_flag = PASS; |
| | | if(protocol_head_up_g.frame_num == 1){ |
| | | //?µÚÒ»ÕëÉϱ¨³É¹¦Ö®ºóÇå³ý±¨¾¯×Ö£¬½öÓÐһ֡ʱûÓÐÊý¾ÝÏìÓ¦Ö¡£¬ÔòÔÚ½áÊøÖ¡ÖлòÆäËûƽ̨±ØÏµÄÖ¸ÁîÖÐÔÙ´ÎÇå³ý±¨¾¯×Ö |
| | | for(uint8_t count_j =0;count_j < 7;count_j ++){ |
| | |
| | | { |
| | | WRC_STATUS return_code = WRC_OFF; |
| | | int difference_value; |
| | | sClockBCD time_after_cali; |
| | | |
| | | wrc_sizhuV4_result_flag = PASS; |
| | | report_sizhuV4_result_flag = PASS; |
| | | |
| | | //?µÚÒ»ÕëÉϱ¨³É¹¦Ö®ºóÇå³ý±¨¾¯×Ö£¬½öÓÐһ֡ʱûÓÐÊý¾ÝÏìÓ¦Ö¡£¬ÔòÔÚ½áÊøÖ¡ÖлòÆäËûƽ̨±ØÏµÄÖ¸ÁîÖÐÔÙ´ÎÇå³ý±¨¾¯×Ö |
| | | for(uint8_t count_j =0;count_j < 7;count_j ++){ |
| | |
| | | if(difference_value >= 300){ |
| | | Set_Extern_Rtc_Time(receive_buf[0],receive_buf[1],receive_buf[2],1,receive_buf[3],receive_buf[4],receive_buf[5]); |
| | | } |
| | | |
| | | //´æ´¢Ð£Ê±¼Ç¼ |
| | | arrayA_2_arrayB(receive_buf,(uint8_t *)&time_after_cali,sizeof(time_after_cali),LITTLE_ENDIAN); |
| | | sizhuSetTimeLogHandle(SET_TIME_SOURCE_AUTO , 0, time_after_cali); |
| | | |
| | | //ÒÅÁôÊý¾ÝÇå¿Õ |
| | | wrc_data_num_ctrl_para_sizhu_g.report_data_left_num = 0; |
| | |
| | | return return_code; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //ÉèÖÃÓà¶î¹Ø·§ |
| | | WRC_STATUS SetBalanceValveClosePro(uint8_t *receive_buf,uint8_t *ack_buf,uint16_t *ack_buf_length) |
| | | { |
| | | WRC_STATUS return_code = WRC_WAIT_REC_DATA; |
| | | |
| | | |
| | | //?´æ´¢ |
| | | |
| | | ack_buf[0] = 0;//³É¹¦ |
| | | *ack_buf_length = 1; //¼ÓÃÜǰµÄÊý¾Ý³¤¶È |
| | | return return_code; |
| | | } |
| | | |
| | | WRC_STATUS SetAccountPro(uint8_t *receive_buf,uint8_t *ack_buf,uint16_t *ack_buf_length) |
| | | { |
| | | WRC_STATUS return_code = WRC_WAIT_REC_DATA; |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | //OTA |
| | | WRC_STATUS OTA_config(uint8_t *receive_buf,uint16_t receive_data_length,uint8_t *ack_buf,uint16_t *ack_buf_length) |
| | | { |
| | | WRC_STATUS return_code = WRC_WAIT_REC_DATA; |
| | | uint8_t return_flag = SUCCESS_0; |
| | | ack_buf[0] = 0;//³É¹¦ |
| | | |
| | | return_flag = BootLoader_IapConfigSetHander(receive_buf,receive_data_length); |
| | | if(return_flag == SUCCESS_0){ |
| | | ack_buf[0] = 0; |
| | | }else{ |
| | | ack_buf[0] = return_flag; |
| | | } |
| | | |
| | | // ack_buf[0] = 0;//³É¹¦ |
| | | *ack_buf_length = 1; //¼ÓÃÜǰµÄÊý¾Ý³¤¶È |
| | | return return_code; |
| | | } |
| | | |
| | | //OTA |
| | | WRC_STATUS OTA_DiffData(uint8_t *receive_buf,uint16_t receive_data_length,uint8_t *ack_buf,uint16_t *ack_buf_length) |
| | | { |
| | | WRC_STATUS return_code = WRC_WAIT_REC_DATA; |
| | | uint8_t return_flag = SUCCESS_0; |
| | | uint32_t offset_addr = (receive_buf[3] << 24) | (receive_buf[2] << 16) | (receive_buf[1] << 8) | receive_buf[0]; |
| | | uint32_t data_len = receive_data_length - 4; //¼õÈ¥µØÖ· |
| | | ack_buf[0] = 0;//³É¹¦ |
| | | |
| | | //Êý¾Ý´Ó[4]¿ªÊ¼ |
| | | return_flag = BootLoader_IapDiffDataHandler(&receive_buf[4],offset_addr,data_len); |
| | | if(return_flag == SUCCESS_0){ |
| | | ack_buf[0] = 0; |
| | | }else{ |
| | | ack_buf[0] = return_flag; |
| | | } |
| | | |
| | | // ack_buf[0] = 0;//³É¹¦ |
| | | *ack_buf_length = 1; //¼ÓÃÜǰµÄÊý¾Ý³¤¶È |
| | | return return_code; |
| | | } |
| | | |
| | | //OTA |
| | | WRC_STATUS OTA_check(uint8_t *receive_buf,uint16_t receive_data_length,uint8_t *ack_buf,uint16_t *ack_buf_length) |
| | | { |
| | | WRC_STATUS return_code = WRC_WAIT_REC_DATA; |
| | | uint8_t return_flag = SUCCESS_0; |
| | | ack_buf[0] = 0;//³É¹¦ |
| | | |
| | | return_flag = BootLoader_IapConfigCheckHandler(); |
| | | if(return_flag == SUCCESS_0){ |
| | | ack_buf[0] = 0; |
| | | }else{ |
| | | ack_buf[0] = return_flag; |
| | | } |
| | | |
| | | // ack_buf[0] = 0;//³É¹¦ |
| | | *ack_buf_length = 1; //¼ÓÃÜǰµÄÊý¾Ý³¤¶È |
| | | return return_code; |
| | | } |
| | | |
| | | //OTA |
| | | WRC_STATUS OTA_DiffMap(uint8_t *receive_buf,uint16_t receive_data_length,uint8_t *ack_buf,uint16_t *ack_buf_length) |
| | | { |
| | | WRC_STATUS return_code = WRC_WAIT_REC_DATA; |
| | | uint8_t return_flag = SUCCESS_0; |
| | | uint32_t offset_addr = (receive_buf[3] << 24) | (receive_buf[2] << 16) | (receive_buf[1] << 8) | receive_buf[0]; |
| | | uint32_t data_len = receive_data_length - 4; //¼õÈ¥µØÖ· |
| | | ack_buf[0] = 0;//³É¹¦ |
| | | |
| | | //Êý¾Ý´Ó[4]¿ªÊ¼ |
| | | return_flag = BootLoader_IapDiffMapSetHandler(&receive_buf[4],offset_addr,data_len); |
| | | if(return_flag == SUCCESS_0){ |
| | | ack_buf[0] = 0; |
| | | }else{ |
| | | ack_buf[0] = return_flag; |
| | | } |
| | | |
| | | // ack_buf[0] = 0;//³É¹¦ |
| | | *ack_buf_length = 1; //¼ÓÃÜǰµÄÊý¾Ý³¤¶È |
| | | return return_code; |
| | | } |
| | | |
| | | //OTA |
| | | WRC_STATUS OTA_config_bsdiff_lzma(uint8_t *receive_buf,uint16_t receive_data_length,uint8_t *ack_buf,uint16_t *ack_buf_length) |
| | | { |
| | | WRC_STATUS return_code = WRC_WAIT_REC_DATA; |
| | | uint8_t return_flag = SUCCESS_0; |
| | | ack_buf[0] = 0;//³É¹¦ |
| | | |
| | | return_flag = BootLoader_IapConfigLzmaSetHander(receive_buf,receive_data_length); |
| | | if(return_flag == SUCCESS_0){ |
| | | ack_buf[0] = 0; |
| | | }else{ |
| | | ack_buf[0] = return_flag; |
| | | } |
| | | |
| | | // ack_buf[0] = 0;//³É¹¦ |
| | | *ack_buf_length = 1; //¼ÓÃÜǰµÄÊý¾Ý³¤¶È |
| | | return return_code; |
| | | } |
| | | |
| | | |
| | | WRC_STATUS SizhuV4ProtocolDataAnalysis(uint8_t *receive_buf,uint8_t *ack_buf,uint16_t *ack_buf_length) |
| | | { |
| | | char *buf_p = NULL; |
| | | uint8_t *buf_p = NULL; |
| | | uint16_t count_i = 0; |
| | | SIZHU_V4_PROTOCOL_HEAD_T protocol_head_rec; |
| | | uint16_t check_crc; |
| | | uint16_t check_crc,recv_crc; |
| | | uint16_t crc_addr; |
| | | WRC_STATUS return_code = WRC_WAIT_REC_DATA; |
| | | // uint8_t key_ver; |
| | | uint16_t ack_data_length = 0; //¼ÓÃÜǰµÄ³¤¶È |
| | | |
| | | count_i =0; |
| | | buf_p +=2; //ÒÆµ½ÏÂÒ»¸ö¶ººÅ |
| | | buf_p = receive_buf + 2; //ÒÆµ½ÏÂÒ»¸ö¶ººÅ |
| | | while(*buf_p != SIZHU_FRAME_HEAD) //buf_pÖ¸ÏòÖ¡Í· |
| | | { |
| | | count_i++; |
| | |
| | | } |
| | | |
| | | arrayA_2_arrayB((uint8_t*)buf_p, (uint8_t*)&protocol_head_rec, sizeof(protocol_head_rec), LITTLE_ENDIAN); |
| | | arrayA_2_arrayB((uint8_t*)(buf_p + FIRST_DATA_SHIFT_SIZHU + protocol_head_rec.data_length), (uint8_t*)&check_crc, 2, LITTLE_ENDIAN); |
| | | |
| | | if(check_crc == usMBCRC16(0xFFFF,(uint8_t *)buf_p,FIRST_DATA_SHIFT_SIZHU + protocol_head_rec.data_length)){ |
| | | arrayA_2_arrayB((uint8_t*)(buf_p + FIRST_DATA_SHIFT_SIZHU + protocol_head_rec.data_length), (uint8_t*)&recv_crc, 2, BIG_ENDIAN); |
| | | check_crc = usMBCRC16(0xFFFF,(uint8_t *)buf_p,FIRST_DATA_SHIFT_SIZHU + protocol_head_rec.data_length); |
| | | if(check_crc == recv_crc){ |
| | | |
| | | WRC_RX_DMA_CH3_reload(); //Êý¾ÝCRCͨ¹ý¿ÉÒÔÈÏΪµ±´ÎÏëÒª½ÓÊÕµÄÊý¾ÝÒѾÍê³É£¬ÐèÒªÖØÖÃDMA½ÓÊÕ, |
| | | |
| | | if((protocol_head_rec.key_ver & 0x80)==0x80){ |
| | | //? ¸ù¾ÝÃÜÔ¿ºÅ½âÃÜ |
| | | DataAes128EcbDecrypt(protocol_head_rec.key_ver,(uint8_t*)(buf_p + FIRST_DATA_SHIFT_SIZHU),(uint8_t*)(buf_p + FIRST_DATA_SHIFT_SIZHU),protocol_head_rec.data_length); |
| | |
| | | case SIZHU_CONTROL_CODE_MODIFY_KEY : return_code = SetKeyPro((uint8_t*)(buf_p + FIRST_DATA_SHIFT_SIZHU),ack_buf + FIRST_DATA_SHIFT_SIZHU,&ack_data_length); break; |
| | | case SIZHU_CONTROL_CODE_PUSH_SETTLEMENT_INFO : return_code = PushSettlementInfoPro((uint8_t*)(buf_p + FIRST_DATA_SHIFT_SIZHU),ack_buf + FIRST_DATA_SHIFT_SIZHU,&ack_data_length); break; |
| | | case SIZHU_CONTROL_CODE_ACCOUNT_STATUS : return_code = PushSettlementInfoPro((uint8_t*)(buf_p + FIRST_DATA_SHIFT_SIZHU),ack_buf + FIRST_DATA_SHIFT_SIZHU,&ack_data_length); break; |
| | | |
| | | case SIZHU_CONTROL_CODE_SET_BALANCE_INSUF_CLOSE_VALVE : return_code = SetBalanceValveClosePro((uint8_t*)(buf_p + FIRST_DATA_SHIFT_SIZHU),ack_buf + FIRST_DATA_SHIFT_SIZHU,&ack_data_length); break; |
| | | //?´ý²¹³ä |
| | | |
| | | case SIZHU_CONTROL_OTA_CONFIG : return_code = OTA_config((uint8_t*)(buf_p + FIRST_DATA_SHIFT_SIZHU),protocol_head_rec.data_length,ack_buf + FIRST_DATA_SHIFT_SIZHU,&ack_data_length); break; |
| | | case SIZHU_CONTROL_OTA_DIFF_DATA : return_code = OTA_DiffData((uint8_t*)(buf_p + FIRST_DATA_SHIFT_SIZHU),protocol_head_rec.data_length,ack_buf + FIRST_DATA_SHIFT_SIZHU,&ack_data_length); break; |
| | | case SIZHU_CONTROL_OTA_CHECK : return_code = OTA_check((uint8_t*)(buf_p + FIRST_DATA_SHIFT_SIZHU),protocol_head_rec.data_length,ack_buf + FIRST_DATA_SHIFT_SIZHU,&ack_data_length); break; |
| | | case SIZHU_CONTROL_OTA_DIFF_MAP : return_code = OTA_DiffMap((uint8_t*)(buf_p + FIRST_DATA_SHIFT_SIZHU),protocol_head_rec.data_length,ack_buf + FIRST_DATA_SHIFT_SIZHU,&ack_data_length); break; |
| | | case SIZHU_CONTROL_OTA_CONFIG_BSDIFF_LZMA : return_code = OTA_config_bsdiff_lzma((uint8_t*)(buf_p + FIRST_DATA_SHIFT_SIZHU),protocol_head_rec.data_length,ack_buf + FIRST_DATA_SHIFT_SIZHU,&ack_data_length); break; |
| | | default: break; |
| | | } |
| | | |