111 lines
3.5 KiB
C
111 lines
3.5 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.
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef IOT_CLI_WIRTE_LOG_TO_FLASH_H
|
|
#define IOT_CLI_WIRTE_LOG_TO_FLASH_H
|
|
|
|
/* os shim includes */
|
|
#include "os_types.h"
|
|
#include "iot_errno_api.h"
|
|
#include "iot_pkt_api.h"
|
|
|
|
#include "iot_log.h"
|
|
#include "iot_share_task.h"
|
|
#include "iot_cli.h"
|
|
#include "iot_cli_common.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define IOT_CLI_LOG_WRITE_FLASH 1
|
|
#define IOT_CLI_LOG_READ_FLASH 2
|
|
#define IOT_CLI_LOG_READ_FLASH_EX 3
|
|
|
|
#define MAX_BUF_SIZE_FOR_READ_FLASH 1900
|
|
#define MAX_BUF_SIZE_FOR_WRITE_FLASH (DBGLOG_MAX_BUFFER_SIZE + \
|
|
sizeof(cli_msg_hdr_t) + \
|
|
2 * MAX_FRAME_CODE_LEN)
|
|
|
|
#define IOT_CLI_LOG_DEFAULT_SIZE (32 * 1024)
|
|
|
|
#define CLI_TRANSFER_LOG_HDR_LEN sizeof(cli_transfer_log_from_flash_hdr)
|
|
#define CLI_TRANSFER_LOG_HDR_LEN_EX sizeof(cli_transfer_log_from_flash_ex_hdr)
|
|
|
|
#pragma pack(push) // save the pack status
|
|
#pragma pack(1) // 1 byte align
|
|
|
|
/** log param */
|
|
typedef struct _cli_host_get_log_param_t
|
|
{
|
|
/** addr */
|
|
uint8_t mac[6];
|
|
/** log size */
|
|
uint32_t size;
|
|
}cli_host_get_log_param_t;
|
|
|
|
typedef struct _cli_transfer_log_from_flash_hdr {
|
|
uint32_t block_id;
|
|
uint16_t datalen;
|
|
}cli_transfer_log_from_flash_hdr;
|
|
|
|
typedef struct _cli_transfer_log_from_flash {
|
|
cli_transfer_log_from_flash_hdr hdr;
|
|
uint8_t data[0];
|
|
}cli_transfer_log_from_flash;
|
|
|
|
/** log from falsh ex */
|
|
typedef struct _cli_transfer_log_from_flash_ex_hdr {
|
|
/** log device addr */
|
|
uint8_t mac[6];
|
|
uint32_t block_id;
|
|
/** data len */
|
|
uint16_t datalen;
|
|
/** data */
|
|
}cli_transfer_log_from_flash_ex_hdr;
|
|
|
|
typedef struct _cli_transfer_log_from_flash_ex {
|
|
cli_transfer_log_from_flash_ex_hdr hdr;
|
|
uint8_t data[0];
|
|
}cli_transfer_log_from_flash_ex;
|
|
|
|
typedef struct _remote_log_param {
|
|
uint8_t src_mac[6];
|
|
cli_transfer_log_from_flash_ex data;
|
|
}remote_log_param;
|
|
|
|
uint8_t required_to_write_to_flash();
|
|
void iot_cli_log_to_flash_msg_handle(iot_msg_entry_t *entry);
|
|
void iot_cli_log_to_flash_msg_cancel_handle(iot_msg_entry_t *entry);
|
|
void download_log_to_flash(iot_pkt_t *pkt);
|
|
void cli_read_log_from_flash(uint8_t* data, uint32_t datalen, uint8_t *src_mac);
|
|
void cli_read_log_from_flash_ex(uint8_t* data, uint32_t datalen, uint8_t *src_mac);
|
|
void write_log(uint8_t* data, uint32_t datalen);
|
|
void write_log_nolock(uint8_t* data, uint32_t datalen);
|
|
void read_log();
|
|
void read_remote_log(remote_log_param* param);
|
|
uint32_t add_flashlog_tag(iot_pkt_t *data);
|
|
uint32_t add_flashlog_tag_preamble(uint8_t* data);
|
|
uint32_t add_flashlog_tag_backcode(uint8_t* data);
|
|
void restore_pkt(iot_pkt_t *buf);
|
|
|
|
#pragma pack(pop) // restore the pack status
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* IOT_CLI_WIRTE_LOG_TO_FLASH_H */
|