1、添加virfat备份与恢复;
2、修复sensorhub低功耗越界问题; 3、修复rcsp传输相关问题; 4、更新flash_params_v3.bin; 5、修复摄像头、科大讯飞相关问题;
This commit is contained in:
@@ -1027,6 +1027,8 @@ void __attribute__((weak)) app_common_device_event_handler(int *msg)
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
extern void hidden_file(u8 flag);
|
||||
extern const int FATFS_BACKUP_ENABLE; //文件系统安全备份功能使能
|
||||
extern void fatfs_backup_clear_null_dir();
|
||||
static void dev_manager_task(void *p)
|
||||
{
|
||||
int res;
|
||||
@@ -1081,6 +1083,10 @@ static void dev_manager_task(void *p)
|
||||
#if TCFG_VIRFAT_FLASH_ENABLE
|
||||
dev_manager_add("virfat_flash");
|
||||
dev_manager_set_valid_by_logo("virfat_flash", 0);///将设备设置为无效设备
|
||||
//安全备份删除异常断电存留下来的空文件
|
||||
if (FATFS_BACKUP_ENABLE) {
|
||||
fatfs_backup_clear_null_dir();
|
||||
}
|
||||
|
||||
#endif
|
||||
#if (TCFG_SDFILE_INSERT_FLASH_ENABLE||TCFG_SDFILE_EXTERN_FLASH_ENABLE)
|
||||
|
||||
@@ -1802,6 +1802,8 @@ int uvc_host_camera_out(const usb_dev usb_id)
|
||||
if (!host_dev) {
|
||||
return 0;
|
||||
}
|
||||
//前移,防止free buf到设置变量期间来中断
|
||||
hdl->open = 0;
|
||||
if (uvc->offline) {
|
||||
uvc->offline(uvc->priv);
|
||||
}
|
||||
@@ -1829,7 +1831,7 @@ int uvc_host_camera_out(const usb_dev usb_id)
|
||||
|
||||
free(uvc);
|
||||
uvc_host_inf[usb_id].dev.uvc = NULL;
|
||||
hdl->open = 0;
|
||||
/* hdl->open = 0; */
|
||||
atomic_set(&(device->ref), 0);
|
||||
device->private_data = NULL;
|
||||
return 0;
|
||||
|
||||
@@ -359,6 +359,245 @@ static int virfat_ioctl(void *fd, u32 cmd, u32 arg)
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////sdfile_fat 备份fat表和目录项/////////////////////////////////////////////////
|
||||
#define BACKUPS_SPACE ((virfat_flash.database - virfat_flash.fatbase) * 512)
|
||||
#define DIR_ENTRY_DEV_ADDR ((virfat_flash.dirbase - virfat_flash.fatbase) * 512)
|
||||
//sdfile_fat的fat表和目录项都是4K对齐的地址和长度
|
||||
#define BK_BUF_LEN 4096
|
||||
|
||||
//记入VM,序号需要整理成独立的
|
||||
/* #define CFG_FATFS_BACKUP_FLAG 145 */
|
||||
|
||||
extern const int FATFS_BACKUP_ENABLE; //文件系统安全备份功能使能
|
||||
static u8 backup_record_flag = 0;
|
||||
|
||||
|
||||
typedef enum {
|
||||
BK_OK = 0,
|
||||
BK_DATA_IS_FF,
|
||||
BK_DATA_LEN_ISNOT_ALIGN,
|
||||
BK_FATFS_DATA_IS_WRONG,
|
||||
BK_ALREADY_RECORD,
|
||||
BK_NOT_RECORD,
|
||||
|
||||
BK_DEV_READ_DATA_ERROR = 8,
|
||||
BK_DEV_ERASE_DATA_ERROR,
|
||||
BK_DEV_WRITE_DATA_ERROR,
|
||||
|
||||
BK_FATFS_NOT_USED = 0xFF,
|
||||
} BK_RESULT;
|
||||
|
||||
static u8 bk_check_is_FF(u8 *data, u32 len)
|
||||
{
|
||||
u8 is_ff_flag = 0;
|
||||
int sub_len = len / 32;
|
||||
if (len % 32) {
|
||||
return BK_DATA_LEN_ISNOT_ALIGN;
|
||||
}
|
||||
for (int j = 0; j < sub_len; j++) {
|
||||
is_ff_flag = 1;
|
||||
for (int i = 0; i < 32; i++) {
|
||||
if (data[i] != 0xFF) {
|
||||
is_ff_flag = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (is_ff_flag) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return is_ff_flag;
|
||||
}
|
||||
|
||||
static int virfat_flash_backups_fat_dir_data()
|
||||
{
|
||||
u8 *buf = zalloc(BK_BUF_LEN);
|
||||
ASSERT(buf);
|
||||
int ret = BK_OK;
|
||||
for (int offset = 0; offset < BACKUPS_SPACE; offset += BK_BUF_LEN) {
|
||||
int rw_len;
|
||||
rw_len = virfat_read(fd, buf, BACKUPS_SPACE + offset, BK_BUF_LEN);
|
||||
if (rw_len != BK_BUF_LEN) {
|
||||
ret = BK_DEV_READ_DATA_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
if (bk_check_is_FF(buf, BK_BUF_LEN)) {
|
||||
ret = BK_DATA_IS_FF;
|
||||
goto __exit;
|
||||
}
|
||||
//check fat table data
|
||||
if (offset == 0) {
|
||||
if (buf[0] != 0xF8 || buf[1] != 0xFF) {
|
||||
ret = BK_FATFS_DATA_IS_WRONG;
|
||||
goto __exit;
|
||||
}
|
||||
}
|
||||
//check dir entry data
|
||||
/* if (offset == DIR_ENTRY_DEV_ADDR) { */
|
||||
/* } */
|
||||
ret = virfat_ioctl(fd, IOCTL_ERASE_SECTOR, offset);
|
||||
if (ret) {
|
||||
ret = BK_DEV_ERASE_DATA_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
rw_len = virfat_write(fd, buf, offset, BK_BUF_LEN);
|
||||
if (rw_len != BK_BUF_LEN) {
|
||||
ret = BK_DEV_WRITE_DATA_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
}
|
||||
//VM 标记放在备份后面
|
||||
u8 bk_info = 1;
|
||||
syscfg_write(CFG_FATFS_BACKUP_FLAG, &bk_info, sizeof(u8));
|
||||
y_printf(">>>[test]:write bk_info = 0x%x\n", bk_info);
|
||||
__exit:
|
||||
y_printf("\n >>>[test]:func = %s,line= %d, ret = %d\n", __FUNCTION__, __LINE__, ret);
|
||||
if (buf) {
|
||||
free(buf);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int virfat_flash_resume_fat_dir_data()
|
||||
{
|
||||
u8 *buf = zalloc(BK_BUF_LEN);
|
||||
ASSERT(buf);
|
||||
int ret = BK_OK;
|
||||
for (int offset = 0; offset < BACKUPS_SPACE; offset += BK_BUF_LEN) {
|
||||
int rw_len;
|
||||
rw_len = virfat_read(fd, buf, offset, BK_BUF_LEN);
|
||||
if (rw_len != BK_BUF_LEN) {
|
||||
ret = BK_DEV_READ_DATA_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
/* y_printf(">>>[test]:offset = %d, fd = 0x%p, buf = 0x%p\n", offset, fd, buf); */
|
||||
/* put_buf(buf, rw_len); */
|
||||
if (bk_check_is_FF(buf, BK_BUF_LEN)) {
|
||||
ret = BK_DATA_IS_FF;
|
||||
goto __exit;
|
||||
}
|
||||
//check fat table data
|
||||
if (offset == 0) {
|
||||
if (buf[0] != 0xF8 || buf[1] != 0xFF) {
|
||||
ret = BK_FATFS_DATA_IS_WRONG;
|
||||
goto __exit;
|
||||
}
|
||||
}
|
||||
ret = virfat_ioctl(fd, IOCTL_ERASE_SECTOR, BACKUPS_SPACE + offset);
|
||||
if (ret) {
|
||||
ret = BK_DEV_ERASE_DATA_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
/* y_printf(">>>[test]:offset = %d, fd = 0x%p, buf = 0x%p\n", offset, fd, buf); */
|
||||
rw_len = virfat_write(fd, buf, BACKUPS_SPACE + offset, BK_BUF_LEN);
|
||||
if (rw_len != BK_BUF_LEN) {
|
||||
ret = BK_DEV_WRITE_DATA_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
}
|
||||
//清VM 标记放在还原后面
|
||||
u8 bk_info = 0;
|
||||
syscfg_write(CFG_FATFS_BACKUP_FLAG, (void *)&bk_info, sizeof(u8));
|
||||
y_printf(">>>[test]:write bk_info = 0x%x\n", bk_info);
|
||||
__exit:
|
||||
y_printf("\n >>>[test]:func = %s,line= %d, ret = %d\n", __FUNCTION__, __LINE__, ret);
|
||||
if (buf) {
|
||||
free(buf);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int virfat_flash_check_resume_flag()
|
||||
{
|
||||
//: fatfs 需要预留区域增加备份还原标志, sdfile_fat不需要,使用VM备份标志处理
|
||||
int ret;
|
||||
u8 *buf = zalloc(BK_BUF_LEN);
|
||||
ASSERT(buf);
|
||||
u8 bk_info;
|
||||
syscfg_read(CFG_FATFS_BACKUP_FLAG, (void *)&bk_info, sizeof(u8));
|
||||
y_printf(">>>[test]:read bk_info = 0x%x\n", bk_info);
|
||||
y_printf(">>>[test]:BACKUPS_SPACE = %d\n", BACKUPS_SPACE);
|
||||
u8 resume_flag = 0;
|
||||
for (int offset = 0; offset < BACKUPS_SPACE; offset += BK_BUF_LEN) {
|
||||
ret = virfat_read(fd, buf, BACKUPS_SPACE + offset, BK_BUF_LEN);
|
||||
if (ret != BK_BUF_LEN) {
|
||||
ret = BK_DEV_READ_DATA_ERROR;
|
||||
goto __exit;
|
||||
}
|
||||
if (bk_check_is_FF(buf, BK_BUF_LEN)) {
|
||||
resume_flag = 1;
|
||||
break;
|
||||
}
|
||||
//check fat table data
|
||||
if (offset == 0) {
|
||||
if (buf[0] != 0xF8 || buf[1] != 0xFF) {
|
||||
resume_flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
r_printf(">>>[test]:bk_info, resume_flag = 0x%x, 0x%x\n", bk_info, resume_flag);
|
||||
if (bk_info || resume_flag) {
|
||||
ret = virfat_flash_resume_fat_dir_data();
|
||||
}
|
||||
__exit:
|
||||
if (buf) {
|
||||
free(buf);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fatfs_sdfile_fat_backup_fat_dir_data()
|
||||
{
|
||||
if (backup_record_flag) {
|
||||
return BK_ALREADY_RECORD;
|
||||
}
|
||||
int ret = virfat_flash_backups_fat_dir_data();
|
||||
if (ret == BK_OK) {
|
||||
backup_record_flag = 1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fatfs_backup_flag_clear()
|
||||
{
|
||||
printf("\n >>>[test]:func = %s,line= %d\n", __FUNCTION__, __LINE__);
|
||||
if (!backup_record_flag) {
|
||||
return BK_NOT_RECORD;
|
||||
}
|
||||
backup_record_flag = 0;
|
||||
u8 bk_info = 0;
|
||||
syscfg_write(CFG_FATFS_BACKUP_FLAG, (void *)&bk_info, sizeof(u8));
|
||||
y_printf(">>>[test]:write bk_info = 0x%x\n", bk_info);
|
||||
return BK_OK;
|
||||
}
|
||||
|
||||
void fatfs_backup_clear_null_dir()
|
||||
{
|
||||
backup_record_flag = 1; //避免此时刻进行备份
|
||||
struct vfscan *fs = fscan("storage/virfat_flash/C/", "-r -tALL -sn ", 4);
|
||||
r_printf(">>>[test]:all filenum = %d\n", fs->file_number);
|
||||
for (int i = fs->file_number; i >= 1; i--) {
|
||||
FILE *fd = fselect(fs, FSEL_BY_NUMBER, i);
|
||||
if (fd) {
|
||||
struct vfs_attr attr;
|
||||
fget_attrs(fd, &attr);
|
||||
//空文件进行删除
|
||||
if (0 == attr.sclust || 0 == attr.fsize) {
|
||||
fdelete(fd);
|
||||
} else {
|
||||
fclose(fd);
|
||||
}
|
||||
backup_record_flag = 1; //避免此时刻进行备份
|
||||
}
|
||||
}
|
||||
fscan_release(fs);
|
||||
backup_record_flag = 0;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
AT_VOLATILE_RAM_CODE
|
||||
static u32 virfat_flash_read(void *buf, u32 addr_sec, u32 len)
|
||||
{
|
||||
@@ -425,6 +664,16 @@ static u32 virfat_flash_write(void *buf, u32 addr_sec, u32 len)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//backup deal
|
||||
if (FATFS_BACKUP_ENABLE && (addr_sec >= virfat_flash.fatbase) && (addr_sec < virfat_flash.database)) {
|
||||
u8 ret = fatfs_sdfile_fat_backup_fat_dir_data();
|
||||
if (ret != BK_OK && ret != BK_ALREADY_RECORD) {
|
||||
wlen = 0;
|
||||
goto __exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (addr_sec == 0) {
|
||||
wlen = len;
|
||||
goto __exit;
|
||||
@@ -564,6 +813,16 @@ u32 virfat_flash_write_watch(void *buf, u32 addr_sec, u32 len)
|
||||
{
|
||||
u32 wlen;
|
||||
u32 real_addrsec = 0;
|
||||
|
||||
|
||||
//backup deal
|
||||
if (FATFS_BACKUP_ENABLE && (addr_sec >= virfat_flash.fatbase) && (addr_sec < virfat_flash.database)) {
|
||||
u8 ret = fatfs_sdfile_fat_backup_fat_dir_data();
|
||||
if (ret != BK_OK && ret != BK_ALREADY_RECORD) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (addr_sec == 0) {
|
||||
return len;
|
||||
} else if (addr_sec < 4096) {
|
||||
@@ -642,35 +901,6 @@ u32 virfat_flash_get_real_capacity() //获取实际flash容量
|
||||
return jlfat_capacity;
|
||||
}
|
||||
|
||||
#define BACKUPS_SPACE 8192
|
||||
void virfat_flash_backups_fat_dir_data()
|
||||
{
|
||||
u8 *buf = zalloc(4096);
|
||||
ASSERT(buf);
|
||||
for (int offset = 0; offset < BACKUPS_SPACE; offset += 4096) {
|
||||
virfat_flash_read_watch(buf, 4096 + BACKUPS_SPACE + offset, 4096);
|
||||
virfat_flash_erase_watch(IOCTL_ERASE_SECTOR, 4096 + offset);
|
||||
virfat_flash_write_watch(buf, 4096 + offset, 4096);
|
||||
}
|
||||
if (buf) {
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
|
||||
void virfat_flash_resume_fat_dir_data()
|
||||
{
|
||||
u8 *buf = zalloc(4096);
|
||||
ASSERT(buf);
|
||||
for (int offset = 0; offset < BACKUPS_SPACE; offset += 4096) {
|
||||
virfat_flash_read_watch(buf, 4096 + offset, 4096);
|
||||
virfat_flash_erase_watch(IOCTL_ERASE_SECTOR, 4096 + BACKUPS_SPACE + offset);
|
||||
virfat_flash_write_watch(buf, 4096 + BACKUPS_SPACE + offset, 4096);
|
||||
}
|
||||
if (buf) {
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/** @brief:
|
||||
@param:
|
||||
@@ -841,6 +1071,10 @@ static int flash_virfat_open(const char *name, struct device **device, void *arg
|
||||
ASSERT(fd);
|
||||
virfat_flash_init();
|
||||
|
||||
if (FATFS_BACKUP_ENABLE) {
|
||||
virfat_flash_check_resume_flag();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#if 0
|
||||
@@ -961,6 +1195,9 @@ static int flash_virfat_ioctrl(struct device *device, u32 cmd, u32 arg)
|
||||
/* y_printf("\n >>>[test]:func = %s,line= %d\n",__FUNCTION__, __LINE__); */
|
||||
virfat_flash_flush();
|
||||
virfat_ioctl(fd, IOCTL_FLUSH, arg);
|
||||
if (FATFS_BACKUP_ENABLE) {
|
||||
fatfs_backup_flag_clear();
|
||||
}
|
||||
break;
|
||||
case IOCTL_CMD_RESUME:
|
||||
break;
|
||||
@@ -1137,6 +1374,7 @@ const struct device_operations private_sfc_dev_ops = {
|
||||
.ioctl = private_sfc_ioctrl,
|
||||
.close = private_sfc_close,
|
||||
};
|
||||
|
||||
#else
|
||||
void virfat_flash_get_dirinfo(void *file_buf, u32 *file_num)
|
||||
{
|
||||
|
||||
@@ -162,6 +162,11 @@ static JL_PRO_CB bt_rcsp_callback = {
|
||||
.wait_resp_timeout = NULL,
|
||||
};
|
||||
|
||||
void rcsp_clear_all_buffer(void)
|
||||
{
|
||||
JL_protocol_dev_switch(&bt_rcsp_callback);
|
||||
}
|
||||
|
||||
void rcsp_init(void)
|
||||
{
|
||||
if (__this) {
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "debug.h"
|
||||
|
||||
extern u8 is_bredr_close(void);
|
||||
|
||||
extern void rcsp_clear_all_buffer(void);
|
||||
extern void rcsp_resume(void);
|
||||
extern void rcsp_find_device_reset(void);
|
||||
extern void sport_data_func_init(void);
|
||||
@@ -253,6 +253,9 @@ static void rcsp_ble_disconnect(void)
|
||||
#endif
|
||||
sport_data_func_release();
|
||||
rcsp_timer_contrl(0);
|
||||
|
||||
// 防止上一次接收长度太长且未接收完成就中断,影响到下一次连接后的交互
|
||||
rcsp_clear_all_buffer();
|
||||
}
|
||||
|
||||
static void rcsp_ble_connect(void)
|
||||
|
||||
+1
-1
@@ -414,7 +414,7 @@ void rcsp_browser_start(u8 *data, u16 len)
|
||||
return ;
|
||||
}
|
||||
///解析数据
|
||||
memcpy((u8 *)browser, data, sizeof(struct __browser));
|
||||
memcpy((u8 *)browser, data, len);
|
||||
browser->start_num = app_ntohs(browser->start_num);
|
||||
browser->dev_handle = app_ntohl(browser->dev_handle);
|
||||
browser->path_len = app_ntohs(browser->path_len);
|
||||
|
||||
+173
-93
@@ -789,12 +789,12 @@ static int rcsp_extra_flash_opt_dial_backgroud_set(u8 *file_path, u16 *data_len)
|
||||
|
||||
//*----------------------------------------------------------------------------*/
|
||||
/**@brief 通过路径获取表盘背景
|
||||
@param file_path:文件路径(也用作出参),file_path_len:路径长度
|
||||
@param resp_buf:用作出参; file_path:文件路径; file_path_len:路径长度
|
||||
@return 0-成功,其他-失败
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static int rcsp_extra_flash_opt_dial_backgroud_get(u8 *data, u8 *file_path, u16 *data_len)
|
||||
static int rcsp_extra_flash_opt_dial_backgroud_get(u8 **resp_buf, u8 *file_path, u16 *data_len)
|
||||
{
|
||||
rcsp_printf("rcsp_extra_flash_opt_dial_backgroud_get, %s\n", file_path);
|
||||
int result = 0;
|
||||
@@ -809,28 +809,41 @@ static int rcsp_extra_flash_opt_dial_backgroud_get(u8 *data, u8 *file_path, u16
|
||||
int watch_item = watch_get_style_by_name(watch);
|
||||
if (watch_item < 0) {
|
||||
// 找不到
|
||||
memcpy(data, "null", sizeof("null"));
|
||||
*resp_buf = zalloc(sizeof("null"));
|
||||
if (*resp_buf == NULL) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(*resp_buf, "null", sizeof("null"));
|
||||
} else {
|
||||
char *bgp = watch_bgp_get_related(watch_item);
|
||||
if (bgp) {
|
||||
memcpy(data, bgp, strlen((const char *)bgp) + 1);
|
||||
*resp_buf = zalloc(strlen((const char *)bgp) + 1);
|
||||
if (*resp_buf == NULL) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(*resp_buf, bgp, strlen((const char *)bgp) + 1);
|
||||
} else {
|
||||
memcpy(data, "null", sizeof("null"));
|
||||
*resp_buf = zalloc(sizeof("null"));
|
||||
if (*resp_buf == NULL) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(*resp_buf, "null", sizeof("null"));
|
||||
}
|
||||
}
|
||||
*data_len = strlen((const char *)data) + 1;
|
||||
|
||||
*data_len = strlen((const char *)(*resp_buf)) + 1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取表盘版本号操作
|
||||
@param file_path:文件路径(也用作出参),file_path_len:路径长度
|
||||
@param resp_buf:用作出参; file_path:文件路径; file_path_len:路径长度
|
||||
@return 0-成功,其他-失败
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static int rcsp_extra_flash_opt_dial_version_get(u8 *data, u8 *file_path, u16 *data_len)
|
||||
static int rcsp_extra_flash_opt_dial_version_get(u8 **resp_buf, u8 *file_path, u16 *data_len)
|
||||
{
|
||||
int ret = 0;
|
||||
rcsp_printf("rcsp_extra_flash_opt_dial_version_get, %s\n", file_path);
|
||||
@@ -853,22 +866,27 @@ static int rcsp_extra_flash_opt_dial_version_get(u8 *data, u8 *file_path, u16 *d
|
||||
goto _end;
|
||||
}
|
||||
|
||||
*resp_buf = zalloc(DIAL_PRJ_UUDI_LEN + DIAL_VERSION_ID);
|
||||
if (*resp_buf == NULL) {
|
||||
ret = -1;
|
||||
goto _end;
|
||||
}
|
||||
// 获取version
|
||||
ret = watch_get_version(watch, (char *)data + offset);
|
||||
ret = watch_get_version(watch, (char *)*resp_buf + offset);
|
||||
if (!ret) {
|
||||
offset += strlen((const char *)data + offset) + 1;
|
||||
offset += strlen((const char *)*resp_buf + offset) + 1;
|
||||
}
|
||||
|
||||
// 获取uuid
|
||||
ret = watch_get_uuid(watch, (char *)data + offset);
|
||||
ret = watch_get_uuid(watch, (char *)*resp_buf + offset);
|
||||
if (!ret) {
|
||||
offset += strlen((const char *)data + offset) + 1;
|
||||
offset += strlen((const char *)*resp_buf + offset) + 1;
|
||||
}
|
||||
|
||||
// 填充分隔符
|
||||
for (u8 i = 0; i < offset; i++) {
|
||||
if ((i + 1 != offset) && 0 == data[i]) {
|
||||
data[i] = ',';
|
||||
if ((i + 1 != offset) && 0 == (*resp_buf)[i]) {
|
||||
(*resp_buf)[i] = ',';
|
||||
}
|
||||
}
|
||||
_end:
|
||||
@@ -999,12 +1017,12 @@ static u16 rcsp_extra_flash_opt_data_fill(u8 *desc, u8 *src, u8 len)
|
||||
|
||||
//*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取当前表盘操作
|
||||
@param buffer:获取结果存放的buffer,data_len:获取结果的长度(出参)
|
||||
@param resp_buf:获取结果存放的buffer,data_len:获取结果的长度(出参)
|
||||
@return 0-成功,其他-失败
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static int rcsp_extra_flash_opt_dial_get(u8 *buffer, u16 *data_len)
|
||||
static int rcsp_extra_flash_opt_dial_get(u8 **resp_buf, u16 *data_len)
|
||||
{
|
||||
rcsp_printf("rcsp_extra_flash_opt_dial_get\n");
|
||||
int result = 0;
|
||||
@@ -1023,7 +1041,12 @@ static int rcsp_extra_flash_opt_dial_get(u8 *buffer, u16 *data_len)
|
||||
if (result) {
|
||||
goto __end;
|
||||
}
|
||||
memcpy(buffer + offset, file_path, file_path_size);
|
||||
*resp_buf = zalloc(file_path_size);
|
||||
if (*resp_buf == NULL) {
|
||||
result = -1;
|
||||
goto __end;
|
||||
}
|
||||
memcpy(*resp_buf + offset, file_path, file_path_size);
|
||||
offset += file_path_size;
|
||||
}
|
||||
|
||||
@@ -1362,12 +1385,12 @@ static u8 rcsp_extra_flash_op_state_get(u8 state)
|
||||
|
||||
//*----------------------------------------------------------------------------*/
|
||||
/**@brief 读数据操作
|
||||
@param data:数据, data_len:数据长度(也用作出参),offset:遍历数据时的偏移量,state:操作类型
|
||||
@param data:数据, data_len:数据长度(也用作出参),offset:遍历数据时的偏移量,state:操作类型, resp_buf:用作出参
|
||||
@return 0-成功,其他-失败
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static int rcsp_extra_flash_read_opt(u8 *data, u16 *data_len, u8 offset, u8 state)
|
||||
static int rcsp_extra_flash_read_opt(u8 *data, u16 *data_len, u8 offset, u8 state, u8 **resp_buf)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
@@ -1375,8 +1398,12 @@ static int rcsp_extra_flash_read_opt(u8 *data, u16 *data_len, u8 offset, u8 stat
|
||||
*data_len = (data[offset + 4] << (8 * 1)) | data[offset + 5];
|
||||
|
||||
state = rcsp_extra_flash_op_state_get(state);
|
||||
result = rcsp_extra_flash_opt_read(data + 1, *data_len, start_addr, state);
|
||||
data[0] = result;
|
||||
*resp_buf = zalloc(*data_len);
|
||||
if (*resp_buf == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
result = rcsp_extra_flash_opt_read(*resp_buf, *data_len, start_addr, state);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1403,7 +1430,6 @@ static int rcsp_extra_flash_write_opt(u8 *data, u16 *data_len, u8 offset, u8 sta
|
||||
} else {
|
||||
result = rcsp_extra_flash_write_no_resp(data + offset, *data_len, start_addr);
|
||||
}
|
||||
data[0] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1421,50 +1447,61 @@ static int rcsp_extra_flash_insert_opt(u8 *data, u16 *data_len, u8 offset, u8 st
|
||||
u32 start_addr = (data[offset + 0] << (8 * 3)) | (data[offset + 1] << (8 * 2)) | (data[offset + 2] << (8 * 1)) | data[offset + 3];
|
||||
offset += 4;
|
||||
*data_len -= offset;
|
||||
data[offset + *data_len] = 0;
|
||||
result = rcsp_extra_flash_opt_insert_start(data + offset, *data_len, start_addr);
|
||||
u8 *path = zalloc(*data_len + 1);
|
||||
if (path == NULL) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(path, &data[offset], *data_len);
|
||||
result = rcsp_extra_flash_opt_insert_start(path, *data_len, start_addr);
|
||||
free(path);
|
||||
} else {
|
||||
result = rcsp_extra_flash_opt_insert_stop();
|
||||
}
|
||||
data[0] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
//*----------------------------------------------------------------------------*/
|
||||
/**@brief 表盘操作
|
||||
@param data:数据, data_len:数据长度(也用作出参),offset:遍历数据时的偏移量,state:操作类型
|
||||
@param data:数据, data_len:数据长度(也用作出参),offset:遍历数据时的偏移量,state:操作类型, resp_buf:用作出参
|
||||
@return 0-成功,其他-失败
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static int rcsp_extra_flash_dial_opt(u8 *data, u16 *data_len, u8 offset, u8 state)
|
||||
static int rcsp_extra_flash_dial_opt(u8 *data, u16 *data_len, u8 offset, u8 state, u8 **resp_buf)
|
||||
{
|
||||
int result = 0;
|
||||
u8 *path = NULL;
|
||||
if (state) {
|
||||
*data_len -= offset;
|
||||
data[*data_len + offset] = 0;
|
||||
path = zalloc(*data_len + 1);
|
||||
if (path == NULL) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(path, &data[offset], *data_len);
|
||||
} else {
|
||||
*data_len = 0;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case 0:
|
||||
result = rcsp_extra_flash_opt_dial_get(data + 1, data_len);
|
||||
result = rcsp_extra_flash_opt_dial_get(resp_buf, data_len);
|
||||
break;
|
||||
case 1:
|
||||
result = rcsp_extra_flash_opt_dial_set(data + offset, data_len);
|
||||
result = rcsp_extra_flash_opt_dial_set(path, data_len);
|
||||
break;
|
||||
case 3:
|
||||
result = rcsp_extra_flash_opt_dial_version_get(data + 1, data + offset, data_len);
|
||||
result = rcsp_extra_flash_opt_dial_version_get(resp_buf, path, data_len);
|
||||
break;
|
||||
case 4:
|
||||
result = rcsp_extra_flash_opt_dial_backgroud_set(data + offset, data_len);
|
||||
result = rcsp_extra_flash_opt_dial_backgroud_set(path, data_len);
|
||||
break;
|
||||
case 5:
|
||||
result = rcsp_extra_flash_opt_dial_backgroud_get(data + 1, data + offset, data_len);
|
||||
result = rcsp_extra_flash_opt_dial_backgroud_get(resp_buf, path, data_len);
|
||||
break;
|
||||
}
|
||||
data[0] = result;
|
||||
if (path) {
|
||||
free(path);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1481,7 +1518,6 @@ static int rcsp_extra_flash_erase_opt(u8 *data, u16 *data_len, u8 offset, u8 sta
|
||||
u32 start_addr = (data[offset + 0] << (8 * 3)) | (data[offset + 1] << (8 * 2)) | (data[offset + 2] << (8 * 1)) | data[offset + 3];
|
||||
*data_len = (data[offset + 4] << (8 * 1)) | data[offset + 5];
|
||||
result = rcsp_extra_flash_opt_erase(start_addr, (*data_len) * 256);
|
||||
data[0] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1497,12 +1533,16 @@ static int rcsp_extra_flash_delete_opt(u8 *data, u16 *data_len, u8 offset, u8 st
|
||||
int result = 0;
|
||||
if (state) {
|
||||
*data_len -= offset;
|
||||
data[offset + *data_len] = 0;
|
||||
result = rcsp_extra_flash_opt_delete_start(data + offset, *data_len);
|
||||
u8 *path = zalloc(*data_len + 1);
|
||||
if (path == NULL) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(path, &data[offset], *data_len);
|
||||
result = rcsp_extra_flash_opt_delete_start(path, *data_len);
|
||||
free(path);
|
||||
} else {
|
||||
result = rcsp_extra_flash_opt_delete_end();
|
||||
}
|
||||
data[0] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1524,7 +1564,6 @@ static int rcsp_extra_flash_update_fat_opt(u8 *data, u16 *data_len, u8 offset, u
|
||||
result = rcsp_extra_flash_opt_update_fat_begin();
|
||||
break;
|
||||
}
|
||||
data[0] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1539,18 +1578,17 @@ static int rcsp_extra_flash_update_ui_opt(u8 *data, u16 *data_len, u8 offset, u8
|
||||
{
|
||||
int result = 0;
|
||||
result = rcsp_extra_flash_opt_update_ui_opt(state);
|
||||
data[0] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
//*----------------------------------------------------------------------------*/
|
||||
/**@brief app获取状态指令
|
||||
@param data:数据, data_len:数据长度(也用作出参),offset:遍历数据时的偏移量,state:操作类型
|
||||
@param data:数据, data_len:数据长度(也用作出参),offset:遍历数据时的偏移量,state:操作类型, resp_buf:用作出参
|
||||
@return 0-成功,其他-失败
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static int rcsp_extra_flash_update_state_to_app(u8 *data, u16 *data_len, u8 offset, u8 state)
|
||||
static int rcsp_extra_flash_update_state_to_app(u8 *data, u16 *data_len, u8 offset, u8 state, u8 **resp_buf)
|
||||
{
|
||||
rcsp_printf("rcsp_extra_flash_update_state_to_app\n");
|
||||
int result = 0;
|
||||
@@ -1565,12 +1603,15 @@ static int rcsp_extra_flash_update_state_to_app(u8 *data, u16 *data_len, u8 offs
|
||||
// 回复buffer剩余大小
|
||||
if (state) {
|
||||
u16 recieve_max = rcsp_packet_write_alloc_len() - 13;
|
||||
data[1] = ((u8 *)&recieve_max)[1];
|
||||
data[2] = ((u8 *)&recieve_max)[0];
|
||||
*resp_buf = zalloc(sizeof(recieve_max));
|
||||
if (*resp_buf == NULL) {
|
||||
return -1;
|
||||
}
|
||||
(*resp_buf)[0] = ((u8 *)&recieve_max)[1];
|
||||
(*resp_buf)[1] = ((u8 *)&recieve_max)[0];
|
||||
*data_len = sizeof(recieve_max);
|
||||
}
|
||||
}
|
||||
data[0] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1600,7 +1641,6 @@ static int rcsp_extra_flash_ota_update_state(u8 *data, u16 *data_len, u8 offset,
|
||||
} else {
|
||||
result = 1;
|
||||
}
|
||||
data[0] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1618,12 +1658,12 @@ static int rcsp_extra_flash_restore(u8 *data, u16 *data_len, u8 offset, u8 state
|
||||
|
||||
//*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取文件信息命令
|
||||
@param data:数据, data_len:数据长度(也用作出参),offset:遍历数据时的偏移量,state:操作类型
|
||||
@param data:数据, data_len:数据长度(也用作出参),offset:遍历数据时的偏移量,state:操作类型, resp_buf:用作出参
|
||||
@return 0-成功,其他-失败
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static int rcsp_extra_flash_file_info_get(u8 *data, u16 *data_len, u8 offset, u8 state)
|
||||
static int rcsp_extra_flash_file_info_get(u8 *data, u16 *data_len, u8 offset, u8 state, u8 **resp_buf)
|
||||
{
|
||||
rcsp_printf("rcsp_extra_flash_file_info_get, file_len %d, file_name :", *data_len);
|
||||
log_info_hexdump(data + offset, *data_len - offset);
|
||||
@@ -1633,11 +1673,15 @@ static int rcsp_extra_flash_file_info_get(u8 *data, u16 *data_len, u8 offset, u8
|
||||
char *root_path = watch_get_root_path();
|
||||
char watch[64] = {0};
|
||||
|
||||
u8 *data_ptr = data + 1;
|
||||
|
||||
ASCII_ToUpper(data + offset, *data_len - offset);
|
||||
strcpy(watch, root_path);
|
||||
strncpy(&watch[strlen((const char *)root_path)], (const char *)data + offset + 1, *data_len - offset - 1);
|
||||
|
||||
u8 *tmp_buf = zalloc(256);
|
||||
if (tmp_buf == NULL) {
|
||||
result = -1;
|
||||
goto __rcsp_extra_flash_file_info_get_err;
|
||||
}
|
||||
file = fopen(watch, "r");
|
||||
if (NULL == file) {
|
||||
result = -1;
|
||||
@@ -1650,50 +1694,61 @@ static int rcsp_extra_flash_file_info_get(u8 *data, u16 *data_len, u8 offset, u8
|
||||
wdt_clear();
|
||||
u32 crc_len = (file_len - crc_offset) > 256 ? 256 : (file_len - crc_offset);
|
||||
fseek(file, crc_offset, SEEK_SET);
|
||||
if (crc_len != fread(data, crc_len, 1, file)) {
|
||||
if (crc_len != fread(tmp_buf, crc_len, 1, file)) {
|
||||
log_error("err : read fail, %s, %d\n", watch, crc_offset);
|
||||
result = -1;
|
||||
goto __rcsp_extra_flash_file_info_get_err;
|
||||
}
|
||||
file_crc = CRC16_with_initval(data, crc_len, file_crc);
|
||||
file_crc = CRC16_with_initval(tmp_buf, crc_len, file_crc);
|
||||
crc_offset += crc_len;
|
||||
}
|
||||
|
||||
*data_len = 0;
|
||||
|
||||
*resp_buf = zalloc(sizeof(file_len) + sizeof(file_crc));
|
||||
if (*resp_buf == NULL) {
|
||||
result = -1;
|
||||
goto __rcsp_extra_flash_file_info_get_err;
|
||||
}
|
||||
// 文件长度
|
||||
for (u8 i = 0; i < sizeof(file_len); i++, data_ptr++, (*data_len)++) {
|
||||
*data_ptr = ((u8 *)&file_len)[sizeof(file_len) - i - 1];
|
||||
for (u8 i = 0; i < sizeof(file_len); i++, (*resp_buf)++, (*data_len)++) {
|
||||
*(*resp_buf) = ((u8 *)&file_len)[sizeof(file_len) - i - 1];
|
||||
}
|
||||
|
||||
// 还需要获取文件crc
|
||||
for (u8 i = 0; i < sizeof(file_crc); i++, data_ptr++, (*data_len)++) {
|
||||
*data_ptr = ((u8 *)&file_crc)[sizeof(file_crc) - i - 1];
|
||||
for (u8 i = 0; i < sizeof(file_crc); i++, (*resp_buf)++, (*data_len)++) {
|
||||
*(*resp_buf) = ((u8 *)&file_crc)[sizeof(file_crc) - i - 1];
|
||||
}
|
||||
|
||||
__rcsp_extra_flash_file_info_get_err:
|
||||
if (tmp_buf) {
|
||||
free(tmp_buf);
|
||||
}
|
||||
if (file) {
|
||||
fclose(file);
|
||||
}
|
||||
data[0] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
//*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取FLASH剩余空间命令
|
||||
@param data:数据, data_len:数据长度(也用作出参),offset:遍历数据时的偏移量,state:操作类型
|
||||
@param data:数据, data_len:数据长度(也用作出参),offset:遍历数据时的偏移量,state:操作类型, resp_buf:用作出参
|
||||
@return 0-成功,其他-失败
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static int rcsp_extra_flash_remain_space(u8 *data, u16 *data_len, u8 offset, u8 state)
|
||||
static int rcsp_extra_flash_remain_space(u8 *data, u16 *data_len, u8 offset, u8 state, u8 **resp_buf)
|
||||
{
|
||||
rcsp_printf("rcsp_extra_flash_remain_space");
|
||||
int result = 0;
|
||||
char *root_path = watch_get_root_path();
|
||||
u32 space = 0;
|
||||
*data_len = 0;
|
||||
u8 *data_ptr = data + 1;
|
||||
*resp_buf = zalloc(sizeof(space));
|
||||
if (*resp_buf == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if (CONFIG_REUSABLE_RESERVE)
|
||||
result = reusable_area_flash_space(NULL, &space);
|
||||
#elif (CONFIG_RESFS_UPDATE_ENABLE)
|
||||
@@ -1703,38 +1758,39 @@ static int rcsp_extra_flash_remain_space(u8 *data, u16 *data_len, u8 offset, u8
|
||||
printf("err : get flash space fail\n");
|
||||
result = -1;
|
||||
} else {
|
||||
for (u8 i = 0; i < sizeof(space); i++, data_ptr++, (*data_len)++) {
|
||||
*data_ptr = ((u8 *)&space)[sizeof(space) - i - 1];
|
||||
for (u8 i = 0; i < sizeof(space); i++, (*resp_buf)++, (*data_len)++) {
|
||||
*(*resp_buf) = ((u8 *)&space)[sizeof(space) - i - 1];
|
||||
}
|
||||
result = 0;
|
||||
}
|
||||
data[0] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
//*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取FLASH剩余空间命令
|
||||
@param data:数据, data_len:数据长度(也用作出参),offset:遍历数据时的偏移量,state:操作类型
|
||||
@param data:数据, data_len:数据长度(也用作出参),offset:遍历数据时的偏移量,state:操作类型, resp_buf:用作出参
|
||||
@return 0-成功,其他-失败
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
static int rcsp_extra_flash_res_space(u8 *data, u16 *data_len, u8 offset, u8 state)
|
||||
static int rcsp_extra_flash_res_space(u8 *data, u16 *data_len, u8 offset, u8 state, u8 **resp_buf)
|
||||
{
|
||||
rcsp_printf("rcsp_extra_flash_res_space");
|
||||
int result = 0;
|
||||
u32 space = 0;
|
||||
*data_len = 0;
|
||||
u8 *data_ptr = data + 1;
|
||||
*resp_buf = zalloc(sizeof(space));
|
||||
if (*resp_buf == NULL) {
|
||||
return -1;
|
||||
}
|
||||
#if (CONFIG_REUSABLE_RESERVE)
|
||||
space = reusable_area_flash_space(NULL, NULL);
|
||||
#elif (CONFIG_RESFS_UPDATE_ENABLE)
|
||||
space = resfs_area_flash_space(NULL, NULL);
|
||||
#endif
|
||||
for (u8 i = 0; i < sizeof(space); i++, data_ptr++, (*data_len)++) {
|
||||
*data_ptr = ((u8 *)&space)[sizeof(space) - i - 1];
|
||||
for (u8 i = 0; i < sizeof(space); i++, (*resp_buf)++, (*data_len)++) {
|
||||
*(*resp_buf) = ((u8 *)&space)[sizeof(space) - i - 1];
|
||||
}
|
||||
data[0] = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1752,61 +1808,78 @@ int rcsp_extra_flash_opt(u8 *param, u16 len, u8 OpCode, u8 OpCode_SN)
|
||||
u8 offset = 0;
|
||||
u8 opt_flag = param[offset++];
|
||||
u8 state = param[offset++];
|
||||
u8 *resp_buf = zalloc(100);
|
||||
if (!resp_buf) {
|
||||
return -1;
|
||||
}
|
||||
ASSERT(len <= 100);
|
||||
memcpy(resp_buf, param, len);
|
||||
u8 *resp_buf = NULL;
|
||||
u8 *resp_data = NULL;
|
||||
|
||||
switch (opt_flag) {
|
||||
case CURR_SYSTEM_OPT_READ:
|
||||
result = rcsp_extra_flash_read_opt(resp_buf, &len, offset, state);
|
||||
result = rcsp_extra_flash_read_opt(param, &len, offset, state, &resp_buf);
|
||||
break;
|
||||
case CURR_SYSTEM_OPT_WRITE:
|
||||
result = rcsp_extra_flash_write_opt(resp_buf, &len, offset, state, OpCode);
|
||||
result = rcsp_extra_flash_write_opt(param, &len, offset, state, OpCode);
|
||||
break;
|
||||
case CURR_SYSTEM_OPT_INSERT:
|
||||
result = rcsp_extra_flash_insert_opt(resp_buf, &len, offset, state);
|
||||
result = rcsp_extra_flash_insert_opt(param, &len, offset, state);
|
||||
break;
|
||||
case CURR_SYSTEM_OPT_DIAL:
|
||||
result = rcsp_extra_flash_dial_opt(resp_buf, &len, offset, state);
|
||||
result = rcsp_extra_flash_dial_opt(param, &len, offset, state, &resp_buf);
|
||||
break;
|
||||
case CURR_SYSTEM_OPT_ERASE:
|
||||
result = rcsp_extra_flash_erase_opt(resp_buf, &len, offset, state);
|
||||
result = rcsp_extra_flash_erase_opt(param, &len, offset, state);
|
||||
break;
|
||||
case CURR_SYSTEM_OPT_DELETE:
|
||||
result = rcsp_extra_flash_delete_opt(resp_buf, &len, offset, state);
|
||||
result = rcsp_extra_flash_delete_opt(param, &len, offset, state);
|
||||
break;
|
||||
case CURR_SYSTEM_OPT_UPDATE_FAT:
|
||||
result = rcsp_extra_flash_update_fat_opt(resp_buf, &len, offset, state);
|
||||
result = rcsp_extra_flash_update_fat_opt(param, &len, offset, state);
|
||||
break;
|
||||
case CURR_SYSTEM_OPT_UPDATE_UI:
|
||||
result = rcsp_extra_flash_update_ui_opt(resp_buf, &len, offset, state);
|
||||
result = rcsp_extra_flash_update_ui_opt(param, &len, offset, state);
|
||||
break;
|
||||
case CURR_SYSTEM_OPT_TRAN_REPLY:
|
||||
result = rcsp_extra_flash_update_state_to_app(resp_buf, &len, offset, state);
|
||||
result = rcsp_extra_flash_update_state_to_app(param, &len, offset, state, &resp_buf);
|
||||
break;
|
||||
case CURR_SYSTEM_OPT_UPDATE_FLAG:
|
||||
result = rcsp_extra_flash_ota_update_state(resp_buf, &len, offset, state);
|
||||
result = rcsp_extra_flash_ota_update_state(param, &len, offset, state);
|
||||
break;
|
||||
case CURR_SYSTEM_OPT_RESTORE:
|
||||
result = rcsp_extra_flash_restore(resp_buf, &len, offset, state);
|
||||
result = rcsp_extra_flash_restore(param, &len, offset, state);
|
||||
break;
|
||||
case CURR_SYSTEM_OPT_FILE_INFO_GET:
|
||||
result = rcsp_extra_flash_file_info_get(resp_buf, &len, offset, state);
|
||||
result = rcsp_extra_flash_file_info_get(param, &len, offset, state, &resp_buf);
|
||||
break;
|
||||
case CURR_SYSTEM_OPT_REMAIN_SPACE:
|
||||
result = rcsp_extra_flash_remain_space(resp_buf, &len, offset, state);
|
||||
result = rcsp_extra_flash_remain_space(param, &len, offset, state, &resp_buf);
|
||||
break;
|
||||
case CURR_SYSTEM_OPT_RES_SPACE:
|
||||
result = rcsp_extra_flash_res_space(resp_buf, &len, offset, state);
|
||||
result = rcsp_extra_flash_res_space(param, &len, offset, state, &resp_buf);
|
||||
break;
|
||||
}
|
||||
|
||||
u16 resp_len = rcsp_extra_flash_opt_resp_data_get(resp_buf + 1, len, opt_flag, state) + 1;
|
||||
rcsp_extra_flash_opt_resp(0, OpCode, OpCode_SN, resp_buf, resp_len);
|
||||
free(resp_buf);
|
||||
if (result < 0) {
|
||||
goto __end;
|
||||
}
|
||||
|
||||
u16 resp_len = rcsp_extra_flash_opt_resp_data_get(resp_buf, len, opt_flag, state) + 1;
|
||||
resp_data = zalloc(resp_len);
|
||||
if (resp_data == NULL) {
|
||||
result = -1;
|
||||
goto __end;
|
||||
}
|
||||
resp_data[0] = result;
|
||||
if (resp_len > 1) {
|
||||
memcpy(&resp_data[1], resp_buf, len);
|
||||
}
|
||||
|
||||
rcsp_extra_flash_opt_resp(0, OpCode, OpCode_SN, resp_data, resp_len);
|
||||
|
||||
__end:
|
||||
if (resp_buf) {
|
||||
free(resp_buf);
|
||||
}
|
||||
if (resp_data) {
|
||||
free(resp_data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1886,7 +1959,11 @@ void rcsp_extra_flash_opt_dial_backgroud_nodify(void)
|
||||
data[offset++] = state;
|
||||
|
||||
u16 get_len = 0;
|
||||
rcsp_extra_flash_opt_dial_backgroud_get((u8 *)data + offset, (u8 *)file_path, &get_len);
|
||||
u8 *path_buf = NULL;
|
||||
rcsp_extra_flash_opt_dial_backgroud_get(&path_buf, (u8 *)file_path, &get_len);
|
||||
if (path_buf) {
|
||||
memcpy((u8 *)data + offset, path_buf, get_len);
|
||||
}
|
||||
log_info("cur dial_backgroud path:%s", data + offset);
|
||||
len = get_len + offset;
|
||||
|
||||
@@ -1894,6 +1971,9 @@ void rcsp_extra_flash_opt_dial_backgroud_nodify(void)
|
||||
if (data) {
|
||||
free(data);
|
||||
}
|
||||
if (path_buf) {
|
||||
free(path_buf);
|
||||
}
|
||||
}
|
||||
|
||||
//*----------------------------------------------------------------------------*/
|
||||
|
||||
+4
@@ -3,6 +3,10 @@
|
||||
#include "typedef.h"
|
||||
#include "system/event.h"
|
||||
|
||||
#define DIAL_PRJ_UUDI_LEN (36+1) //Example: "c0f95f48-14fd-4344-9fbf-effbb701473c"
|
||||
#define DIAL_VERSION_ID (4+1) //Example: "W003"
|
||||
|
||||
|
||||
//*----------------------------------------------------------------------------*/
|
||||
/**@brief 外部flash操作函数
|
||||
@param param:数据, len:数据长度,OpCode:命令号,OpCode_SN:数据包序列号
|
||||
|
||||
+13
-1
@@ -11,6 +11,7 @@
|
||||
#include "rcsp_browser.h"
|
||||
#include "rcsp_config.h"
|
||||
|
||||
#include "res_config.h"
|
||||
#include "rcsp_extra_flash_opt.h"
|
||||
#include "JL_rcsp_protocol.h"
|
||||
#include "ascii.h"
|
||||
@@ -634,7 +635,18 @@ void rcsp_file_transfer_file_rename(u8 status, u8 *data, u16 len)
|
||||
if (err) {
|
||||
rcsp_file_transfer_close();
|
||||
}
|
||||
dev_manager_set_valid(ftp_d->dev, 1);
|
||||
char *watch_ptr = (char *)data;
|
||||
/* printf("%s name:%s",__func__,watch_ptr); */
|
||||
if ((!strncmp(watch_ptr, WATCH_RES_NAME, strlen(WATCH_RES_NAME))) ||
|
||||
(!strncmp(watch_ptr, WATCH_RES_NAME_SMALL, strlen(WATCH_RES_NAME_SMALL))) ||
|
||||
(!strncmp(watch_ptr, BGP_RES_NAME, strlen(BGP_RES_NAME))) ||
|
||||
(!strncmp(watch_ptr, BGP_RES_NAME_SMALL, strlen(BGP_RES_NAME_SMALL)))
|
||||
) {
|
||||
//表盘相关操作,不设置active
|
||||
/* printf("%s %d",__func__,__LINE__); */
|
||||
} else {
|
||||
dev_manager_set_valid(ftp_d->dev, 1);
|
||||
}
|
||||
file_transfer_watch_opt(2, 0);
|
||||
} else {
|
||||
//有重名的, 重新获取新名称, 如:“xxx_n.mp3”,n为数字
|
||||
|
||||
Reference in New Issue
Block a user