Merge branch 'Branch_S550_Fast' of gitlab.sifar.tech:linux-em-group/s530-ntk into branch_s550_fast
This commit is contained in:
commit
295ac6478e
|
@ -35,37 +35,6 @@ echo "fs" > /proc/nvt_info/bootts
|
||||||
echo "/sbin/mdev" > /proc/sys/kernel/hotplug
|
echo "/sbin/mdev" > /proc/sys/kernel/hotplug
|
||||||
#modprobe mmc_na51055
|
#modprobe mmc_na51055
|
||||||
|
|
||||||
if [ 1 ] ; then
|
|
||||||
|
|
||||||
sleep ${DELAY}
|
|
||||||
|
|
||||||
echo 0x5 > /proc/adc
|
|
||||||
cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw
|
|
||||||
echo 0x3 > /proc/adc
|
|
||||||
sleep ${DELAY}
|
|
||||||
|
|
||||||
echo 1 > /sys/devices/gpiochip0/gpio/gpio${SF_ADC_MUXA}/value
|
|
||||||
echo 0 > /sys/devices/gpiochip0/gpio/gpio${SF_ADC_MUXB}/value
|
|
||||||
sleep ${DELAY}
|
|
||||||
cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw
|
|
||||||
echo 0x1 > /proc/adc
|
|
||||||
sleep ${DELAY}
|
|
||||||
|
|
||||||
echo 0 > /sys/devices/gpiochip0/gpio/gpio${SF_ADC_MUXA}/value
|
|
||||||
echo 0 > /sys/devices/gpiochip0/gpio/gpio${SF_ADC_MUXB}/value
|
|
||||||
sleep ${DELAY}
|
|
||||||
cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw
|
|
||||||
echo 0x0 > /proc/adc
|
|
||||||
sleep ${DELAY}
|
|
||||||
|
|
||||||
echo 0 > /sys/devices/gpiochip0/gpio/gpio${SF_ADC_MUXA}/value
|
|
||||||
echo 1 > /sys/devices/gpiochip0/gpio/gpio${SF_ADC_MUXB}/value
|
|
||||||
sleep ${DELAY}
|
|
||||||
echo 0x2 > /proc/adc
|
|
||||||
sleep ${DELAY}
|
|
||||||
cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
mdev -s
|
mdev -s
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,7 @@ SRC = \
|
||||||
./SrcCode/System/SysSensor_Exe.c \
|
./SrcCode/System/SysSensor_Exe.c \
|
||||||
./SrcCode/System/SysFW_Upgrade_Strg_Obj.c \
|
./SrcCode/System/SysFW_Upgrade_Strg_Obj.c \
|
||||||
./SrcCode/System/SysFW_Upgrade.c \
|
./SrcCode/System/SysFW_Upgrade.c \
|
||||||
|
./SrcCode/System/sys_usrmem.c \
|
||||||
./SrcCode/UIApp/UIAppObj.c \
|
./SrcCode/UIApp/UIAppObj.c \
|
||||||
./SrcCode/UIApp/ExifVendor.c \
|
./SrcCode/UIApp/ExifVendor.c \
|
||||||
./SrcCode/UIApp/Setup/UISetup_Exe.c \
|
./SrcCode/UIApp/Setup/UISetup_Exe.c \
|
||||||
|
|
|
@ -974,6 +974,7 @@
|
||||||
#ifndef ANR_FUNC
|
#ifndef ANR_FUNC
|
||||||
#define ANR_FUNC ENABLE
|
#define ANR_FUNC ENABLE
|
||||||
#endif
|
#endif
|
||||||
|
#define SF_NO_SD_SEND DISABLE
|
||||||
//////////////////////sf end///////////////////////////////
|
//////////////////////sf end///////////////////////////////
|
||||||
|
|
||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include <IOCfg.h>
|
#include <IOCfg.h>
|
||||||
#if HUNTING_CAMERA_MCU == ENABLE
|
#if HUNTING_CAMERA_MCU == ENABLE
|
||||||
#include <sf_inc.h>
|
#include <sf_inc.h>
|
||||||
|
#include "sf_log.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -407,6 +407,7 @@ int NvtMain(void)
|
||||||
nvt_hdal_init();
|
nvt_hdal_init();
|
||||||
nvt_user_init();
|
nvt_user_init();
|
||||||
#if HUNTING_CAMERA_MCU == ENABLE
|
#if HUNTING_CAMERA_MCU == ENABLE
|
||||||
|
sf_log_Level_set(SF_LOG_LEVEL_DEBUG);
|
||||||
sf_cardv_check_power_on_mode();
|
sf_cardv_check_power_on_mode();
|
||||||
BOOL inUsb = GxUSB_GetIsUSBPlug();
|
BOOL inUsb = GxUSB_GetIsUSBPlug();
|
||||||
if(TRUE == inUsb)//(!sf_gpio_get_status(GPIO_INT_USBPLUGIN))
|
if(TRUE == inUsb)//(!sf_gpio_get_status(GPIO_INT_USBPLUGIN))
|
||||||
|
|
264
code/application/source/cardv/SrcCode/System/sys_usrmem.c
Normal file
264
code/application/source/cardv/SrcCode/System/sys_usrmem.c
Normal file
|
@ -0,0 +1,264 @@
|
||||||
|
|
||||||
|
#include "sys_usrmem.h"
|
||||||
|
#include "rtosfdt.h"
|
||||||
|
#include "libfdt.h"
|
||||||
|
#include "compiler.h"
|
||||||
|
#include <kwrap/error_no.h>
|
||||||
|
#include <kwrap/debug.h>
|
||||||
|
#include "MemCheck.h"
|
||||||
|
#include "hdal.h"
|
||||||
|
|
||||||
|
#if !defined(__FREERTOS)
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__FREERTOS)
|
||||||
|
|
||||||
|
INT32 sys_usrmem_init(SYS_USRMEM* usrmem)
|
||||||
|
{
|
||||||
|
const void* fdt = fdt_get_base();
|
||||||
|
int nodeoffset = fdt_path_offset((const void*)fdt, SYS_USRMEM_NODE);
|
||||||
|
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if(usrmem == NULL){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
usrmem->is_init = FALSE;
|
||||||
|
|
||||||
|
if(nodeoffset >= 0){
|
||||||
|
const unsigned long *nodep;
|
||||||
|
nodep = (const unsigned long *)fdt_getprop(fdt, nodeoffset, "reg", &len);
|
||||||
|
|
||||||
|
usrmem->used_size = 0;
|
||||||
|
usrmem->addr = be32_to_cpu(nodep[0]);
|
||||||
|
usrmem->size = be32_to_cpu(nodep[1]);
|
||||||
|
|
||||||
|
usrmem->hdr = (SYS_USRMEM_HDR*) usrmem->addr;
|
||||||
|
usrmem->hdr->photo_ofs = 0;
|
||||||
|
usrmem->hdr->photo_size = 0;
|
||||||
|
usrmem->hdr->photo_sum = 0;
|
||||||
|
usrmem->hdr->tag = SYS_USRMEM_TAG;
|
||||||
|
usrmem->used_size += sizeof(SYS_USRMEM_HDR);
|
||||||
|
usrmem->addr_photo = usrmem->addr + usrmem->used_size;
|
||||||
|
|
||||||
|
DBG_DUMP("usrmem addr = %lx, size = %lx, addr_hdr = %lx, addr_photo = %lx\n",
|
||||||
|
usrmem->addr,
|
||||||
|
usrmem->size,
|
||||||
|
usrmem->hdr ,
|
||||||
|
usrmem->addr_photo);
|
||||||
|
|
||||||
|
usrmem->is_init = TRUE;
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG_ERR("fdt node %s not found!\n", SYS_USRMEM_NODE);
|
||||||
|
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 sys_usrmem_write_photo(SYS_USRMEM* usrmem, UINT32 buf, UINT32 size)
|
||||||
|
{
|
||||||
|
if(usrmem == NULL){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(usrmem->addr_photo == 0){
|
||||||
|
DBG_ERR("address photo can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(buf == 0){
|
||||||
|
DBG_ERR("buf can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(size == 0){
|
||||||
|
DBG_ERR("size can't be zero!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(usrmem->is_init == FALSE){
|
||||||
|
DBG_ERR("usrmem is not init yet!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
memcpy((void*)usrmem->addr_photo, (void*)buf, size);
|
||||||
|
usrmem->hdr->photo_ofs = usrmem->used_size;
|
||||||
|
usrmem->hdr->photo_size = size;
|
||||||
|
usrmem->hdr->photo_sum = MemCheck_CalcCheckSum16Bit(usrmem->addr_photo, size);
|
||||||
|
usrmem->used_size += size;
|
||||||
|
|
||||||
|
hd_common_mem_flush_cache((void*)usrmem->addr, usrmem->used_size);
|
||||||
|
|
||||||
|
DBG_DUMP("photo addr:%lx, size:%lx, sum:%lx\n", usrmem->addr_photo, usrmem->hdr->photo_size, usrmem->hdr->photo_sum);
|
||||||
|
|
||||||
|
return E_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
static void* usrmem_mmap(int fd, unsigned int mapped_size, off_t phy_addr)
|
||||||
|
{
|
||||||
|
void *map_base = NULL;
|
||||||
|
unsigned page_size = 0;
|
||||||
|
|
||||||
|
page_size = getpagesize();
|
||||||
|
map_base = mmap(NULL,
|
||||||
|
mapped_size,
|
||||||
|
PROT_READ | PROT_WRITE,
|
||||||
|
MAP_SHARED,
|
||||||
|
fd,
|
||||||
|
(phy_addr) & ~(off_t)(page_size - 1));
|
||||||
|
|
||||||
|
if (map_base == MAP_FAILED)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return map_base;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int usrmem_munmap(void* map_base, unsigned int mapped_size)
|
||||||
|
{
|
||||||
|
if (munmap(map_base, mapped_size) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int usrmem_init_dev(char* dev)
|
||||||
|
{
|
||||||
|
int fd = 0;
|
||||||
|
|
||||||
|
DBG_DUMP("open %s\n", dev);
|
||||||
|
|
||||||
|
fd = open(dev, O_RDWR | O_SYNC);
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 sys_usrmem_init(SYS_USRMEM* usrmem)
|
||||||
|
{
|
||||||
|
const void* fdt = fdt_get_base();
|
||||||
|
int nodeoffset = fdt_path_offset((const void*)fdt, SYS_USRMEM_NODE);
|
||||||
|
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if(usrmem == NULL){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
usrmem->is_init = FALSE;
|
||||||
|
|
||||||
|
if(nodeoffset >= 0){
|
||||||
|
const unsigned long *nodep;
|
||||||
|
nodep = (const unsigned long *)fdt_getprop(fdt, nodeoffset, "reg", &len);
|
||||||
|
|
||||||
|
usrmem->addr = be32_to_cpu(nodep[0]);
|
||||||
|
usrmem->size = be32_to_cpu(nodep[1]);
|
||||||
|
|
||||||
|
int fd = usrmem_init_dev("/dev/mem");
|
||||||
|
if(fd < 0){
|
||||||
|
DBG_ERR("open %s failed\n", "/dev/mem");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG_DUMP("usrmem addr:%lx size:%lx\n", usrmem->addr, usrmem->size);
|
||||||
|
|
||||||
|
void* va = usrmem_mmap(fd, usrmem->size ,usrmem->addr);
|
||||||
|
if(va){
|
||||||
|
|
||||||
|
usrmem->hdr = va;
|
||||||
|
usrmem->used_size = sizeof(SYS_USRMEM_HDR);
|
||||||
|
|
||||||
|
if(usrmem->hdr->tag == SYS_USRMEM_TAG){
|
||||||
|
|
||||||
|
DBG_DUMP("check tag ok, hdr ofs:%lx, size:%lx, sum:%lx\n",
|
||||||
|
usrmem->hdr->photo_ofs,
|
||||||
|
usrmem->hdr->photo_size,
|
||||||
|
usrmem->hdr->photo_sum);
|
||||||
|
|
||||||
|
usrmem->addr_photo = (UINT32)va + usrmem->hdr->photo_ofs;
|
||||||
|
|
||||||
|
DBG_DUMP("photo data = %lx\n", *((UINT32*)usrmem->addr_photo));
|
||||||
|
|
||||||
|
UINT32 sum = MemCheck_CalcCheckSum16Bit(usrmem->addr_photo, usrmem->hdr->photo_size);
|
||||||
|
|
||||||
|
usrmem->used_size += usrmem->hdr->photo_size;
|
||||||
|
|
||||||
|
if(sum == usrmem->hdr->photo_sum){
|
||||||
|
DBG_DUMP("checksum ok(%lx)\n", sum);
|
||||||
|
usrmem->is_init = TRUE;
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
DBG_ERR("checksum err(%lx)\n", sum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
DBG_WRN("invalid usrmem hdr tag(%lx)!\n", usrmem->hdr->tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
DBG_ERR("mmap failed(addr:%lx size:%lx)\n", usrmem->addr, usrmem->size);
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 sys_usrmem_read_photo(SYS_USRMEM* usrmem, UINT32* addr, UINT32* size)
|
||||||
|
{
|
||||||
|
if(usrmem == NULL){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(usrmem->is_init == FALSE){
|
||||||
|
DBG_ERR("usrmem not init yet!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(addr == NULL || size == NULL){
|
||||||
|
DBG_ERR("addr & size can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
*addr = usrmem->addr_photo;
|
||||||
|
*size = usrmem->hdr->photo_size;
|
||||||
|
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 sys_usrmem_hdr_uninit(SYS_USRMEM* usrmem)
|
||||||
|
{
|
||||||
|
if(usrmem == NULL ){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!usrmem->addr && !usrmem->size){
|
||||||
|
DBG_ERR("addr & size can't be zero!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return usrmem_munmap((void* )usrmem->addr, usrmem->size);;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
41
code/application/source/cardv/SrcCode/System/sys_usrmem.h
Normal file
41
code/application/source/cardv/SrcCode/System/sys_usrmem.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#ifndef SYS_USRMEM_H
|
||||||
|
#define SYS_USRMEM_H
|
||||||
|
|
||||||
|
#include "kwrap/type.h"
|
||||||
|
|
||||||
|
#define SYS_USRMEM_NODE "/nvt_memory_cfg/usrmem"
|
||||||
|
#define SYS_USRMEM_TAG MAKEFOURCC('U','S','R','M')
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
|
||||||
|
UINT32 tag;
|
||||||
|
UINT32 photo_ofs;
|
||||||
|
UINT32 photo_size;
|
||||||
|
UINT32 photo_sum;
|
||||||
|
|
||||||
|
} SYS_USRMEM_HDR;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
|
||||||
|
UINT32 addr;
|
||||||
|
UINT32 size;
|
||||||
|
UINT32 used_size;
|
||||||
|
SYS_USRMEM_HDR* hdr;
|
||||||
|
UINT32 addr_photo;
|
||||||
|
BOOL is_init;
|
||||||
|
|
||||||
|
} SYS_USRMEM;
|
||||||
|
|
||||||
|
INT32 sys_usrmem_init(SYS_USRMEM* usrmem);
|
||||||
|
|
||||||
|
#if defined(__FREERTOS)
|
||||||
|
|
||||||
|
INT32 sys_usrmem_write_photo(SYS_USRMEM* usrmem, UINT32 buf, UINT32 size);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
INT32 sys_usrmem_read_photo(SYS_USRMEM* usrmem, UINT32* addr, UINT32* size);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -2265,6 +2265,16 @@ static void PhotoExe_DispCB(void)
|
||||||
HD_VIDEO_FRAME video_frame = {0};
|
HD_VIDEO_FRAME video_frame = {0};
|
||||||
HD_RESULT ret;
|
HD_RESULT ret;
|
||||||
PHOTO_DISP_INFO *p_disp = NULL;
|
PHOTO_DISP_INFO *p_disp = NULL;
|
||||||
|
|
||||||
|
#if HUNTING_CAMERA_MCU == ENABLE
|
||||||
|
static int tmp = 1;
|
||||||
|
if(tmp)//test log
|
||||||
|
{
|
||||||
|
tmp = 0;
|
||||||
|
printf("[%s:%d]s\n", __FUNCTION__, __LINE__);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
p_disp = UIAppPhoto_get_DispConfig(UIAPP_PHOTO_DISP_ID_1);
|
p_disp = UIAppPhoto_get_DispConfig(UIAPP_PHOTO_DISP_ID_1);
|
||||||
//p_disp->enable = TRUE;
|
//p_disp->enable = TRUE;
|
||||||
if(0 != System_GetState(SYS_STATE_SLEEPLEVEL)){
|
if(0 != System_GetState(SYS_STATE_SLEEPLEVEL)){
|
||||||
|
|
|
@ -316,6 +316,7 @@ SRC = \
|
||||||
./code/source/systemMng/sf_systemMng.c \
|
./code/source/systemMng/sf_systemMng.c \
|
||||||
./code/source/systemMng/sf_commu_mcu_reg.c \
|
./code/source/systemMng/sf_commu_mcu_reg.c \
|
||||||
./code/source/systemMng/sf_commu_mcu.c \
|
./code/source/systemMng/sf_commu_mcu.c \
|
||||||
|
./code/source/systemMng/sys_usrmem.c \
|
||||||
./code/source/devMng/sf_dev_other.c \
|
./code/source/devMng/sf_dev_other.c \
|
||||||
./code/source/devMng/sf_dev_usb.c \
|
./code/source/devMng/sf_dev_usb.c \
|
||||||
./code/source/devMng/sf_keymng.c \
|
./code/source/devMng/sf_keymng.c \
|
||||||
|
|
|
@ -42,6 +42,8 @@ UINT32 sf_get_file_size(UINT8 * fname);
|
||||||
UINT8 sf_get_send_file_list(char *sendfileList, UINT8 *fileTotal);
|
UINT8 sf_get_send_file_list(char *sendfileList, UINT8 *fileTotal);
|
||||||
BOOL sf_check_auto_thumb_file(VOID);
|
BOOL sf_check_auto_thumb_file(VOID);
|
||||||
UINT8 sf_get_send_file_total(void);
|
UINT8 sf_get_send_file_total(void);
|
||||||
|
SINT32 sf_mem_upload_file_to_module(UINT32 MemPhotoAddr, UINT32 MemPhotosize);
|
||||||
|
SINT32 sf_usr_mem_photo_ch(void);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,5 +224,6 @@ SINT32 sf_low_power_warn_send_ftp(void);
|
||||||
double sf_sys_s_time_get(time_t end_time);
|
double sf_sys_s_time_get(time_t end_time);
|
||||||
time_t sf_time (time_t *__timer);
|
time_t sf_time (time_t *__timer);
|
||||||
SINT32 sf_gps_send_ftp(void);
|
SINT32 sf_gps_send_ftp(void);
|
||||||
|
SINT32 sf_test_send_file_to_ftp(void);
|
||||||
#endif /*_SF_FTP_H_*/
|
#endif /*_SF_FTP_H_*/
|
||||||
|
|
||||||
|
|
|
@ -187,8 +187,6 @@ extern "C" {
|
||||||
#define SF_THUMB_SMALL_DIR SF_SD_DISK"THUMB/small"
|
#define SF_THUMB_SMALL_DIR SF_SD_DISK"THUMB/small"
|
||||||
#define SF_THUMB_BIG_DIR SF_SD_DISK"THUMB/big"
|
#define SF_THUMB_BIG_DIR SF_SD_DISK"THUMB/big"
|
||||||
#define SF_THUMB_VIDEO_DIR SF_SD_DISK"THUMB/video"
|
#define SF_THUMB_VIDEO_DIR SF_SD_DISK"THUMB/video"
|
||||||
#define DCF_DIR_FREE_CHAR "MEDIA"
|
|
||||||
#define DCF_FILE_FREE_CHAR "SYFW"
|
|
||||||
|
|
||||||
#define SF_TRUE 1
|
#define SF_TRUE 1
|
||||||
#define SF_FALSE 0
|
#define SF_FALSE 0
|
||||||
|
|
|
@ -90,6 +90,7 @@ void app_FileSend_start(void);
|
||||||
SINT32 app_t110(void);
|
SINT32 app_t110(void);
|
||||||
SINT32 sf_app_to_cardv_capture(void);
|
SINT32 sf_app_to_cardv_capture(void);
|
||||||
SINT32 sf_module_reboot_reg_net(void);
|
SINT32 sf_module_reboot_reg_net(void);
|
||||||
|
SINT32 sf_restart_reg_net(void);
|
||||||
SINT32 sf_app_to_cardv_hd_ture(void);
|
SINT32 sf_app_to_cardv_hd_ture(void);
|
||||||
int sf_check_eth0(void);
|
int sf_check_eth0(void);
|
||||||
int sf_check_usb0(void);
|
int sf_check_usb0(void);
|
||||||
|
@ -103,6 +104,7 @@ void app_RegisterNet_stop(void);
|
||||||
int sf_check_sd(void);
|
int sf_check_sd(void);
|
||||||
void sf_save_camera_gps_info(void);
|
void sf_save_camera_gps_info(void);
|
||||||
void set_at_parament(void);
|
void set_at_parament(void);
|
||||||
|
int sf_net_dns_ck(void);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|
41
code/application/source/sf_app/code/include/sys_usrmem.h
Normal file
41
code/application/source/sf_app/code/include/sys_usrmem.h
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#ifndef SYS_USRMEM_H
|
||||||
|
#define SYS_USRMEM_H
|
||||||
|
|
||||||
|
#include "kwrap/type.h"
|
||||||
|
|
||||||
|
#define SYS_USRMEM_NODE "/nvt_memory_cfg/usrmem"
|
||||||
|
#define SYS_USRMEM_TAG MAKEFOURCC('U','S','R','M')
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
|
||||||
|
UINT32 tag;
|
||||||
|
UINT32 photo_ofs;
|
||||||
|
UINT32 photo_size;
|
||||||
|
UINT32 photo_sum;
|
||||||
|
|
||||||
|
} SYS_USRMEM_HDR;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
|
||||||
|
UINT32 addr;
|
||||||
|
UINT32 size;
|
||||||
|
UINT32 used_size;
|
||||||
|
SYS_USRMEM_HDR* hdr;
|
||||||
|
UINT32 addr_photo;
|
||||||
|
BOOL is_init;
|
||||||
|
|
||||||
|
} SYS_USRMEM;
|
||||||
|
|
||||||
|
INT32 sys_usrmem_init(SYS_USRMEM* usrmem);
|
||||||
|
|
||||||
|
#if defined(__FREERTOS)
|
||||||
|
|
||||||
|
INT32 sys_usrmem_write_photo(SYS_USRMEM* usrmem, UINT32 buf, UINT32 size);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
INT32 sys_usrmem_read_photo(SYS_USRMEM* usrmem, UINT32* addr, UINT32* size);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -18,6 +18,7 @@
|
||||||
* Description: creat
|
* Description: creat
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
#include "NvtUser/NvtUser.h"
|
#include "NvtUser/NvtUser.h"
|
||||||
|
#include "kwrap/nvt_type.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -50,6 +51,7 @@ extern "C" {
|
||||||
#include "sf_ledmng.h"
|
#include "sf_ledmng.h"
|
||||||
#include "ftp_manager.h"
|
#include "ftp_manager.h"
|
||||||
#include "sf_system.h"
|
#include "sf_system.h"
|
||||||
|
#include "curl/curl.h"
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* C O N S T A N T S *
|
* C O N S T A N T S *
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
@ -1059,7 +1061,7 @@ SINT32 sf_video_send_ftp(void)
|
||||||
|
|
||||||
sprintf((char *)ftpFileName, "%s%s", cameraID, videoFname);
|
sprintf((char *)ftpFileName, "%s%s", cameraID, videoFname);
|
||||||
sprintf((char *)filePath, "UFS:/%s", videoFname);
|
sprintf((char *)filePath, "UFS:/%s", videoFname);
|
||||||
sprintf((char *)videoDir, "%s\\%s%s\\%s", SF_DCIM_DIR, videoDirKey, DCF_DIR_FREE_CHAR, videoFname);
|
sprintf((char *)videoDir, "%s\\%s%s\\%s", SF_DCIM_DIR, videoDirKey, DCF_DIR_NAME, videoFname);
|
||||||
*/
|
*/
|
||||||
fileIndex = sf_check_file_video();
|
fileIndex = sf_check_file_video();
|
||||||
|
|
||||||
|
@ -1607,6 +1609,12 @@ SINT32 sf_concentrated_ftp_send(void)
|
||||||
SF_CONCENTRATED_RE://Try again once
|
SF_CONCENTRATED_RE://Try again once
|
||||||
ret1 = sf_ftp_send(ftpFileName, filePath, timeout);
|
ret1 = sf_ftp_send(ftpFileName, filePath, timeout);
|
||||||
|
|
||||||
|
if(CURLE_OPERATION_TIMEDOUT == ret1)
|
||||||
|
{
|
||||||
|
NET_SLOGE("CURLE_OPERATION_TIMEDOUT error\n");
|
||||||
|
sf_restart_reg_net();
|
||||||
|
}
|
||||||
|
|
||||||
if(SF_SUCCESS != ret1)
|
if(SF_SUCCESS != ret1)
|
||||||
{
|
{
|
||||||
printf("%s:%d err ret: [0x%08X] ftpFileName:%s filePath:%s\n", __FUNCTION__, __LINE__, ret, ftpFileName, filePath);
|
printf("%s:%d err ret: [0x%08X] ftpFileName:%s filePath:%s\n", __FUNCTION__, __LINE__, ret, ftpFileName, filePath);
|
||||||
|
@ -1698,7 +1706,7 @@ SF_CONCENTRATED_END:
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************
|
/*************************************************
|
||||||
Function: sf_concentrated_ftp_send
|
Function: sf_hd_ftp_send
|
||||||
Description: ftp send.
|
Description: ftp send.
|
||||||
Input: 1:send pic/video. 2:send dr.
|
Input: 1:send pic/video. 2:send dr.
|
||||||
Output: N/A
|
Output: N/A
|
||||||
|
@ -2306,6 +2314,721 @@ SINT32 sf_gps_send_ftp(void)
|
||||||
return ret2;
|
return ret2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SF_NO_SD_SEND == ENABLE
|
||||||
|
/*************************************************
|
||||||
|
Function: sf_ftp_config
|
||||||
|
Description: send pic to ftp
|
||||||
|
Input: N/A
|
||||||
|
Output: N/A
|
||||||
|
Return: 0 SUCCESS, 1 error
|
||||||
|
Others: N/A
|
||||||
|
*************************************************/
|
||||||
|
SINT32 sf_test_ftp_config(UINT8 ssl, UINT8 GprsMode, int timeout)
|
||||||
|
{
|
||||||
|
UIMenuStoreInfo *pPara = sf_app_ui_para_get();
|
||||||
|
SINT32 ret = SF_SUCCESS;
|
||||||
|
#if 1
|
||||||
|
FTP_SIM_E eFtpLocation = FTP_SIM_CGDCONT;
|
||||||
|
SINT32 ttyRet = 0;
|
||||||
|
UINT8 calltime = 0;
|
||||||
|
UINT16 time = 0;
|
||||||
|
UINT8 pdpIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
|
pdpIndex = sf_get_pdp_index();
|
||||||
|
|
||||||
|
sf_gsm_para_buff_clear();
|
||||||
|
printf("[%s:%d]ssl=%d GprsMode=%d\n", __FUNCTION__, __LINE__, ssl, GprsMode);
|
||||||
|
|
||||||
|
while(sf_app_while_flag())
|
||||||
|
{
|
||||||
|
switch(eFtpLocation)
|
||||||
|
{
|
||||||
|
case FTP_SIM_CGDCONT:
|
||||||
|
eFtpLocation = FTP_SIM_NETOPEN;
|
||||||
|
|
||||||
|
if(strstr((const char *)pPara->Sim4gApn, APN_4G_VERIZON))
|
||||||
|
{
|
||||||
|
sprintf((char *)gsmPara, "AT+QICSGP=%d\r", pdpIndex);
|
||||||
|
eFtpLocation = FTP_SIM_QICSGP0;
|
||||||
|
}
|
||||||
|
else if(strstr((const char *)pPara->Sim4gApn, APN_4G_ATT))
|
||||||
|
{
|
||||||
|
sprintf((char *)gsmPara, "AT+QICSGP=%d,1,\"%s\",\"%s\",\"%s\",1\r", pdpIndex, pPara->Sim4gApn, pPara->Sim4gUsr, pPara->Sim4gPwd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf((char *)gsmPara, "AT+QICSGP=%d,1,\"%s\",\"%s\",\"%s\",1\r", pdpIndex, pPara->Sim4gApn, pPara->Sim4gUsr, pPara->Sim4gPwd);
|
||||||
|
}
|
||||||
|
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_QICSGP0:
|
||||||
|
|
||||||
|
if(strstr((const char *)gsmPara, "OK"))
|
||||||
|
{
|
||||||
|
eFtpLocation = FTP_SIM_NETOPEN;
|
||||||
|
|
||||||
|
if(strstr((const char *)gsmPara, "+QICSGP: 0") || strstr((const char *)gsmPara, "+QICSGP: 1,\"\""))
|
||||||
|
{
|
||||||
|
sprintf((char *)gsmPara, "AT+QICSGP=%d,1,\"%s\",\"%s\",\"%s\",1\r", pdpIndex, pPara->Sim4gApn, pPara->Sim4gUsr, pPara->Sim4gPwd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eFtpLocation = FTP_SIM_CFTPSSTART;
|
||||||
|
sprintf((char *)gsmPara, "AT+QIACT=%d\r", pdpIndex);
|
||||||
|
calltime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_NETOPEN:
|
||||||
|
#if SF_TEST_ERROR_CODE
|
||||||
|
sf_test_code_err(eFtpLocation, "AT TIMEOUT TEST");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(strstr((const char *)gsmPara, "OK"))
|
||||||
|
{
|
||||||
|
eFtpLocation = FTP_SIM_CFTPSSTART;
|
||||||
|
sprintf((char *)gsmPara, "AT+QIACT=%d\r", pdpIndex);
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
calltime = 0;
|
||||||
|
}
|
||||||
|
else if(strstr((const char *)gsmPara, "ERROR"))
|
||||||
|
{
|
||||||
|
ret = SF_FTP_ERROR_AT_ERROR;
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]AT+QICSGP,Error Code:0x%08X", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(logStr);
|
||||||
|
goto SF_FTP_END_CONFIG;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
calltime++;
|
||||||
|
|
||||||
|
if(calltime < 10)
|
||||||
|
{
|
||||||
|
sf_sleep_ms(200);
|
||||||
|
}
|
||||||
|
else if(calltime > MAX_CALL_TIMES)
|
||||||
|
{
|
||||||
|
ret = SF_FTP_ERROR_AT_TIMEOUT;
|
||||||
|
printf("[%s:%d]FTP Configure Timeout!\n", __FUNCTION__, __LINE__);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]FTP CFG Timeout,Error Code:0x%08X", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(logStr);
|
||||||
|
goto SF_FTP_END_CONFIG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_CFTPSSTART:
|
||||||
|
#if SF_TEST_ERROR_CODE
|
||||||
|
sf_test_code_err(eFtpLocation, "ERROR: ");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(strstr((const char *)gsmPara, "OK"))
|
||||||
|
{
|
||||||
|
eFtpLocation = FTP_SIM_CFTPSSINGLEIP;
|
||||||
|
sprintf((char *)gsmPara, "AT+QFTPCFG=\"contextid\",%d\r", pdpIndex);
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
calltime = 0;
|
||||||
|
}
|
||||||
|
else if(strstr((const char *)gsmPara, "ERROR"))
|
||||||
|
{
|
||||||
|
calltime++;
|
||||||
|
|
||||||
|
if(calltime < 6)
|
||||||
|
{
|
||||||
|
sprintf((char *)gsmPara, "AT+QIACT=%d\r", pdpIndex);
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
sf_sleep_ms(800);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = SF_FTP_ERROR_AT_ACTIVE;
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]AT+QIACT Over Try 6 Times,Error Code:0x%08X", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(logStr);
|
||||||
|
goto SF_FTP_END_CONFIG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_CFTPSSINGLEIP:
|
||||||
|
|
||||||
|
if(strstr((const char *)gsmPara, "OK"))
|
||||||
|
{
|
||||||
|
if((0 == pPara->FtpSwitch))
|
||||||
|
{
|
||||||
|
eFtpLocation = FTP_SIM_CCHSTART;
|
||||||
|
sprintf((char *)gsmPara, "AT+QFTPCFG=\"account\",\"%s\",\"%s\"\r", pPara->FtpUsr, pPara->FtpPwd);
|
||||||
|
}
|
||||||
|
else if((2 == pPara->FtpSwitch))//ftps
|
||||||
|
{
|
||||||
|
eFtpLocation = FTP_SIM_QSSLCFG0;
|
||||||
|
sprintf((char *)gsmPara, "AT+QFTPCFG=\"account\",\"%s\",\"%s\"\r", pPara->FtpsUsr, pPara->FtpsPwd);
|
||||||
|
}
|
||||||
|
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_QSSLCFG0:
|
||||||
|
sprintf((char *)gsmPara, "AT+QFTPCFG=\"restenable\",0\r");
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
eFtpLocation = FTP_SIM_QSSLCFG1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_QSSLCFG1:
|
||||||
|
sprintf((char *)gsmPara, "AT+QFTPCFG=\"ssltype\",2\r");
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
eFtpLocation = FTP_SIM_QSSLCFG2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_QSSLCFG2:
|
||||||
|
sprintf((char *)gsmPara, "AT+QFTPCFG=\"sslctxid\",1\r");
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
eFtpLocation = FTP_SIM_QSSLCFG3;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_QSSLCFG3:
|
||||||
|
sprintf((char *)gsmPara, "AT+QSSLCFG=\"ciphersuite\",1,0xffff\r");
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
eFtpLocation = FTP_SIM_QSSLCFG4;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_QSSLCFG4:
|
||||||
|
sprintf((char *)gsmPara, "AT+QSSLCFG=\"seclevel\",1,0\r");
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
eFtpLocation = FTP_SIM_QSSLCFG5;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_QSSLCFG5:
|
||||||
|
sprintf((char *)gsmPara, "AT+QSSLCFG=\"sslversion\",1,4\r");
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
eFtpLocation = FTP_SIM_CFTPLOGIN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_CCHSTART:
|
||||||
|
sprintf((char *)gsmPara, "AT+QFTPCFG=\"filetype\",0\r");
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
eFtpLocation = FTP_SIM_CFTPSCFG;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_CFTPSCFG:
|
||||||
|
sprintf((char *)gsmPara, "AT+QFTPCFG=\"transmode\",1\r");
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
eFtpLocation = FTP_SIM_CFTPLOGIN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_CFTPLOGIN:
|
||||||
|
|
||||||
|
if(strstr((const char *)gsmPara, "OK"))
|
||||||
|
{
|
||||||
|
eFtpLocation = FTP_SIM_EXIT;
|
||||||
|
printf("[%s:%d]log ftp\n", __FUNCTION__, __LINE__);
|
||||||
|
|
||||||
|
if((0 == pPara->FtpSwitch))
|
||||||
|
{
|
||||||
|
sprintf((char *)gsmPara, "AT+QFTPOPEN=\"%s\",%s\r", pPara->FtpIp, pPara->FtpPort);
|
||||||
|
}
|
||||||
|
else if((2 == pPara->FtpSwitch))
|
||||||
|
{
|
||||||
|
sprintf((char *)gsmPara, "AT+QFTPOPEN=\"%s\",%s\r", pPara->FtpsIp, pPara->FtpsPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
calltime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_EXIT:
|
||||||
|
#if SF_TEST_ERROR_CODE
|
||||||
|
sf_test_code_err(eFtpLocation, "QFTPOPEN TEST");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(strstr((const char *)gsmPara, "+QFTPOPEN:"))
|
||||||
|
{
|
||||||
|
if(strstr((const char *)gsmPara, "+QFTPOPEN: 0"))
|
||||||
|
{
|
||||||
|
goto SF_FTP_END_CONFIG;
|
||||||
|
}
|
||||||
|
else //+CFTPSSTART: <errcode>
|
||||||
|
{
|
||||||
|
ret = SF_FTP_ERROR_OPEN;
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]AT+QFTPOPEN Error,Error Code:0x%08X", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(logStr);
|
||||||
|
goto SF_FTP_END_CONFIG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(strstr((const char *)gsmPara, "ERROR"))
|
||||||
|
{
|
||||||
|
ret = SF_FTP_ERROR_OPEN;
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]AT+QFTPOPEN,Error Code:0x%08X", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(logStr);
|
||||||
|
goto SF_FTP_END_CONFIG;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
calltime++;
|
||||||
|
sf_sleep_ms(800);
|
||||||
|
|
||||||
|
if(calltime > 30)
|
||||||
|
{
|
||||||
|
calltime = 0;
|
||||||
|
ret = SF_FTP_ERROR_TERM;
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]AT+QFTPOPEN Timeout,Error Code:0x%08X", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(logStr);
|
||||||
|
goto SF_FTP_END_CONFIG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sf_gsm_para_buff_clear();
|
||||||
|
|
||||||
|
sf_hal_ttyusb2_read(gsmPara, 200);
|
||||||
|
printf("eFtpLocation=%d,time=%d\n", eFtpLocation, time);
|
||||||
|
|
||||||
|
if((gsmPara[0] != '\0') && (FTP_SIM_EXIT != eFtpLocation) && (FTP_SIM_CCHSTART != eFtpLocation) && (FTP_SIM_QSSLCFG0 != eFtpLocation))
|
||||||
|
{
|
||||||
|
SLOGI("gsmPara:%s", gsmPara);
|
||||||
|
}
|
||||||
|
|
||||||
|
time++;
|
||||||
|
|
||||||
|
if(time > 800)
|
||||||
|
{
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]Wait Init Timeout.", __FUNCTION__, __LINE__);
|
||||||
|
printf("%s,GprsMode=%d\n", logStr, pPara->GprsMode);
|
||||||
|
SLOGE(logStr);
|
||||||
|
|
||||||
|
time = 0;
|
||||||
|
ret = SF_FTP_ERROR_SEND_TIMEOUT;
|
||||||
|
goto SF_FTP_END_CONFIG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SF_FTP_END_CONFIG:
|
||||||
|
printf("[%s:%d]ret:[0x%08X]\n\n", __FUNCTION__, __LINE__, ret);
|
||||||
|
if(SF_SUCCESS != ret){
|
||||||
|
sf_sys_status_led_set(SF_LED_SYS_STATE_SEND_FAIL);
|
||||||
|
}
|
||||||
|
FtpOpenOk = ret;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
Function: sf_ftp_send
|
||||||
|
Description: send pic to ftp
|
||||||
|
Input: N/A
|
||||||
|
Output: N/A
|
||||||
|
Return: 0 SUCCESS, 1 error
|
||||||
|
Others: N/A
|
||||||
|
*************************************************/
|
||||||
|
SINT32 sf_test_ftp_send(UINT8 *ftpFileName, UINT8 *filePath, int timeout)
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
SINT32 ret = SF_SUCCESS;
|
||||||
|
FTP_SIM_E eFtpLocation = FTP_SIM_CFTPSCFG;
|
||||||
|
SINT32 ttyRet = 0;
|
||||||
|
UINT8 calltime = 0;
|
||||||
|
UINT16 time = 0;
|
||||||
|
printf("[%s:%d]ftpFileName:%s,filePath:%s\n", __FUNCTION__, __LINE__, ftpFileName, filePath);
|
||||||
|
|
||||||
|
UIMenuStoreInfo *pPara = sf_app_ui_para_get();
|
||||||
|
//sfPara_t *sfParam = sf_ParaGet();
|
||||||
|
sf_gsm_para_buff_clear();
|
||||||
|
|
||||||
|
while(sf_app_while_flag())
|
||||||
|
{
|
||||||
|
switch(eFtpLocation)
|
||||||
|
{
|
||||||
|
case FTP_SIM_CFTPSCFG:
|
||||||
|
eFtpLocation = FTP_SIM_JPG;
|
||||||
|
sprintf((char *)gsmPara, "AT+QFTPPUT=\"%s\",\"%s\",0\r", ftpFileName, filePath);
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_JPG:
|
||||||
|
#if SF_TEST_ERROR_CODE
|
||||||
|
sf_test_code_err(eFtpLocation, "TIMEOUT TEST");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(strstr((const char *)gsmPara, "+QFTPPUT:") || strstr((const char *)gsmPara, "PUT:"))
|
||||||
|
{
|
||||||
|
#if SF_TEST_ERROR_CODE
|
||||||
|
sf_test_code_err(FTP_SIM_CFTPSCFG, "+QFTPPUT: 1");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(strstr((const char *)gsmPara, "+QFTPPUT: 0") || strstr((const char *)gsmPara, "PUT: 0,"))
|
||||||
|
{
|
||||||
|
if(sf_get_mode_flag() == 0) //auto mode
|
||||||
|
{
|
||||||
|
if(pPara->CamMode != SF_CAM_MODE_VIDEO)
|
||||||
|
{
|
||||||
|
sendPicSuccessFlag = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sendVideoSuccessFlag = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
goto SF_FTP_SEND_END;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = SF_FTP_ERROR_SEND;
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]AT+QFTPPUT Error,Error Code:0x%08X", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(logStr);
|
||||||
|
printf("%s", logStr);
|
||||||
|
goto SF_FTP_SEND_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(strstr((const char *)gsmPara, "ERROR"))
|
||||||
|
{
|
||||||
|
ret = SF_FTP_ERROR_SEND;
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]AT+QFTPPUT Error,Error Code:0x%08X", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(logStr);
|
||||||
|
printf("%s", logStr);
|
||||||
|
goto SF_FTP_SEND_END;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
calltime++;
|
||||||
|
sf_sleep_ms(800);
|
||||||
|
|
||||||
|
if(calltime > (timeout + 10))
|
||||||
|
{
|
||||||
|
calltime = 0;
|
||||||
|
ret = SF_FTP_ERROR_SEND_TIMEOUT;
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]AT+QFTPPUT Timeout,Error Code:0x%08X", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(logStr);
|
||||||
|
printf("%s", logStr);
|
||||||
|
goto SF_FTP_SEND_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sf_gsm_para_buff_clear();
|
||||||
|
|
||||||
|
sf_hal_ttyusb2_read(gsmPara, 200);
|
||||||
|
|
||||||
|
if(gsmPara[0] != '\0')
|
||||||
|
{
|
||||||
|
//printf("%s:%d %d \n%s\n", __FUNCTION__, __LINE__, eFtpLocation, gsmPara);
|
||||||
|
SLOGI(" %d \n%s\n", eFtpLocation, gsmPara);
|
||||||
|
}
|
||||||
|
|
||||||
|
time++;
|
||||||
|
|
||||||
|
if(time > 800)
|
||||||
|
{
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]Wait Init Timeout.", __FUNCTION__, __LINE__);
|
||||||
|
printf("%s,GprsMode=%d\n", logStr, pPara->GprsMode);
|
||||||
|
SLOGE(logStr);
|
||||||
|
|
||||||
|
time = 0;
|
||||||
|
ret = SF_FTP_ERROR_SEND_TIMEOUT;
|
||||||
|
goto SF_FTP_SEND_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SF_FTP_SEND_END:
|
||||||
|
printf("[%s:%d]ret:[0x%08X]\n\n", __FUNCTION__, __LINE__, ret);
|
||||||
|
return ret;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
Function: sf_ftp_send
|
||||||
|
Description: send pic to ftp
|
||||||
|
Input: N/A
|
||||||
|
Output: N/A
|
||||||
|
Return: 0 SUCCESS, 1 error
|
||||||
|
Others: N/A
|
||||||
|
*************************************************/
|
||||||
|
SINT32 sf_test_ftp_stop(UINT8 ssl, UINT8 GprsMode)
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
SINT32 ret = SF_SUCCESS;
|
||||||
|
FTP_SIM_E eFtpLocation = FTP_SIM_CFTPSLOGOUT;
|
||||||
|
SINT32 ttyRet = 0;
|
||||||
|
UINT8 calltime = 0;
|
||||||
|
UINT16 time = 0;
|
||||||
|
UINT8 pdpIndex = 0;
|
||||||
|
|
||||||
|
UIMenuStoreInfo *pPara = sf_app_ui_para_get();
|
||||||
|
|
||||||
|
pdpIndex = sf_get_pdp_index();
|
||||||
|
|
||||||
|
sf_gsm_para_buff_clear();
|
||||||
|
printf("%s:%d start ssl:%d GprsMode:%d\n", __FUNCTION__, __LINE__, ssl, GprsMode);
|
||||||
|
while(sf_app_while_flag())
|
||||||
|
{
|
||||||
|
switch(eFtpLocation)
|
||||||
|
{
|
||||||
|
case FTP_SIM_CFTPSLOGOUT:
|
||||||
|
eFtpLocation = FTP_SIM_CCHSTOP;
|
||||||
|
sprintf((char *)gsmPara, "AT+QFTPCLOSE\r");
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_CCHSTOP:
|
||||||
|
#if SF_TEST_ERROR_CODE
|
||||||
|
sf_test_code_err(eFtpLocation, "QFTPCLOSE TIMEOUT TEST");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(strstr((const char *)gsmPara, "OK"))
|
||||||
|
{
|
||||||
|
sprintf((char *)gsmPara, "AT+QIDEACT=%d\r", pdpIndex);
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
eFtpLocation = FTP_SIM_CFTPSSTOP;
|
||||||
|
}
|
||||||
|
else if(strstr((const char *)gsmPara, "ERROR"))
|
||||||
|
{
|
||||||
|
calltime++;
|
||||||
|
|
||||||
|
if(calltime < 3)
|
||||||
|
{
|
||||||
|
sprintf((char *)gsmPara, "AT+QFTPCLOSE\r");
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
sf_sleep_ms(400);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
calltime = 0;
|
||||||
|
ret = SF_FTP_ERROR_LOGOUT;
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]AT+QFTPCLOSE Try 3 Times,Error Code:0x%08X", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(logStr);
|
||||||
|
sprintf((char *)gsmPara, "AT+QIDEACT=%d\r", pdpIndex);
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
eFtpLocation = FTP_SIM_CFTPSSTOP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
calltime++;
|
||||||
|
sf_sleep_ms(800);
|
||||||
|
|
||||||
|
if(calltime > 60)
|
||||||
|
{
|
||||||
|
calltime = 0;
|
||||||
|
ret = SF_FTP_ERROR_LOGOUT_TIMEOUT;
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]AT+CFTPSLOGOUT Timeout,Error Code:0x%08X", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(logStr);
|
||||||
|
sprintf((char *)gsmPara, "AT+QIDEACT=%d\r", pdpIndex);
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
eFtpLocation = FTP_SIM_CFTPSSTOP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FTP_SIM_CFTPSSTOP:
|
||||||
|
#if SF_TEST_ERROR_CODE
|
||||||
|
sf_test_code_err(eFtpLocation, "ERROR");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(strstr((const char *)gsmPara, "OK"))
|
||||||
|
{
|
||||||
|
goto SF_FTP_STOP_END;
|
||||||
|
}
|
||||||
|
else if(strstr((const char *)gsmPara, "ERROR"))
|
||||||
|
{
|
||||||
|
calltime++;
|
||||||
|
|
||||||
|
if(calltime < 6)
|
||||||
|
{
|
||||||
|
sprintf((char *)gsmPara, "AT+QIDEACT=%d\r", pdpIndex);
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
sf_sleep_ms(400);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
calltime = 0;
|
||||||
|
ret = SF_FTP_ERROR_QIDEACT;
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]AT+QIDEACT Try 6 Times,Error Code:0x%08X", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(logStr);
|
||||||
|
goto SF_FTP_STOP_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
calltime++;
|
||||||
|
sf_sleep_ms(800);
|
||||||
|
|
||||||
|
if(calltime > 60)
|
||||||
|
{
|
||||||
|
calltime = 0;
|
||||||
|
ret = SF_FTP_ERROR_LOGOUT_TIMEOUT;
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]AT+QIDEACT Timeout,Error Code:0x%08X", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(logStr);
|
||||||
|
goto SF_FTP_STOP_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sf_gsm_para_buff_clear();
|
||||||
|
sf_hal_ttyusb2_read(gsmPara, 200);
|
||||||
|
|
||||||
|
if(gsmPara[0] != '\0')
|
||||||
|
{
|
||||||
|
//printf("eFtpLocation=%d,time=%d\ngsmPara:%s\n", eFtpLocation, time, gsmPara);
|
||||||
|
SLOGI("eFtpLocation=%d,time=%d\ngsmPara:%s", eFtpLocation, time, gsmPara);
|
||||||
|
}
|
||||||
|
|
||||||
|
time++;
|
||||||
|
|
||||||
|
if(time > 800)
|
||||||
|
{
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)logStr, "[%s:%d]Wait Init Timeout.", __FUNCTION__, __LINE__);
|
||||||
|
printf("%s,GprsMode=%d\n", logStr, pPara->GprsMode);
|
||||||
|
SLOGE(logStr);
|
||||||
|
|
||||||
|
time = 0;
|
||||||
|
ret = SF_FTP_ERROR_SEND_TIMEOUT;
|
||||||
|
goto SF_FTP_STOP_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SF_FTP_STOP_END:
|
||||||
|
printf("[%s:%d]ret:[0x%08X]\n\n", __FUNCTION__, __LINE__, ret);
|
||||||
|
return ret;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************
|
||||||
|
Function: sf send file to ftp
|
||||||
|
Description: ftp send.
|
||||||
|
Input: 1:send pic/video. 2:send dr.
|
||||||
|
Output: N/A
|
||||||
|
Return: 0:success; else:fail;
|
||||||
|
Others: N/A
|
||||||
|
*************************************************/
|
||||||
|
SINT32 sf_test_send_file_to_ftp(void)
|
||||||
|
{
|
||||||
|
SINT32 ret1 = SF_SUCCESS; //0:success; else:fail;
|
||||||
|
SINT32 ret2 = SF_SUCCESS; //0:success; else:fail;
|
||||||
|
UINT8 ssl = 0;
|
||||||
|
UINT8 gprsMode = 0;
|
||||||
|
int timeout = 120000;
|
||||||
|
UIMenuStoreInfo *puiPara = sf_app_ui_para_get();
|
||||||
|
UINT8 ftpFileName[64] = { 0 };
|
||||||
|
UINT8 filePath[64] = { 0 };
|
||||||
|
MLOGD("start\n");
|
||||||
|
|
||||||
|
UINT8 CamNameStr[64] = {0};
|
||||||
|
char cameraID[64] = { 0 };
|
||||||
|
UINT8 tempPicSize = 0;
|
||||||
|
UINT8 piccount = 0;
|
||||||
|
UINT8 pic = 0;
|
||||||
|
|
||||||
|
UINT8 csqlevel = 0;
|
||||||
|
MLOGD("start\n");
|
||||||
|
|
||||||
|
sf_custom_str_get(CamNameStr);
|
||||||
|
sf_4G_signal_level_get(puiPara->NetGeneration,sf_get_cq_signal(),&csqlevel);
|
||||||
|
|
||||||
|
snprintf(cameraID, sizeof(cameraID), "%s-%d-%d-%s-", puiPara->ModuleImei, sf_app_get_battery(), csqlevel, CamNameStr); /* DCF 8.3 naming rule */
|
||||||
|
|
||||||
|
printf("NetGeneration:%dG,tempPicSize=%d,piccount=%d,pic=%d\n", puiPara->NetGeneration, tempPicSize, piccount, pic);
|
||||||
|
|
||||||
|
sprintf((char *)ftpFileName, "%sMEMPHOTO.JPG", cameraID);
|
||||||
|
sprintf((char *)filePath, "UFS:MEMPHOTO.JPG");
|
||||||
|
|
||||||
|
printf("%s:%d ftpFileName:%s filePath:%s \n", __FUNCTION__, __LINE__, ftpFileName, filePath);
|
||||||
|
|
||||||
|
|
||||||
|
ssl = ((2 == puiPara->FtpSwitch) ? 1 : 0);
|
||||||
|
gprsMode = 0;//puiPara->GprsMode;
|
||||||
|
printf("[%s:%d] ssl:%d,GprsMode:%d\n", __FUNCTION__, __LINE__, ssl, gprsMode);
|
||||||
|
|
||||||
|
|
||||||
|
ret1 = sf_test_ftp_config(ssl, gprsMode, timeout);
|
||||||
|
|
||||||
|
if(SF_SUCCESS == ret1)
|
||||||
|
{
|
||||||
|
ret1 = sf_test_ftp_send(ftpFileName, filePath, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ret1 != SF_FTP_ERROR_TERM)
|
||||||
|
{
|
||||||
|
ret2 = sf_test_ftp_stop(ssl, gprsMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
MLOGD(" end ret1:[0x%08X],ret2:[0x%08X]\n", ret1, ret2);
|
||||||
|
|
||||||
|
if(ret1 != SF_SUCCESS)
|
||||||
|
{
|
||||||
|
return ret1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FtpOpenOk = SUCCESS;
|
||||||
|
return ret2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,7 +260,7 @@ SINT32 sf_USB_net_init(void)
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sf_net_dns_ck();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1254,6 +1254,13 @@ SINT32 sf_file_send_auto(void) {
|
||||||
if(SF_FAILURE == sf_check_sd())
|
if(SF_FAILURE == sf_check_sd())
|
||||||
{
|
{
|
||||||
MLOGE("ERROR sf_check_sd\n");
|
MLOGE("ERROR sf_check_sd\n");
|
||||||
|
#if SF_NO_SD_SEND == ENABLE
|
||||||
|
if( 0 == sf_usr_mem_photo_ch())
|
||||||
|
{
|
||||||
|
s32ret = sf_test_send_file_to_ftp();
|
||||||
|
return s32ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return SF_FAILURE;
|
return SF_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1348,9 +1355,13 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam)
|
||||||
UIMenuStoreInfo *pCustomerParam = sf_app_ui_para_get();
|
UIMenuStoreInfo *pCustomerParam = sf_app_ui_para_get();
|
||||||
SF_STARTUP_TYPE_E startup = sf_poweron_type_get();
|
SF_STARTUP_TYPE_E startup = sf_poweron_type_get();
|
||||||
sf_log_Level_set(SF_LOG_LEVEL_DEBUG);
|
sf_log_Level_set(SF_LOG_LEVEL_DEBUG);
|
||||||
|
#if SF_NO_SD_SEND == ENABLE
|
||||||
|
if (sf_usb_IsInsert())
|
||||||
|
#else
|
||||||
if (sf_usb_IsInsert() ||
|
if (sf_usb_IsInsert() ||
|
||||||
((0 == sf_in_card_exist()) && (SF_MCU_STARTUP_ONKEY != startup))) {
|
((0 == sf_in_card_exist()) && (SF_MCU_STARTUP_ONKEY != startup)))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
return SF_SUCCESS;
|
return SF_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1943,6 +1954,23 @@ SINT32 sf_module_reboot_reg_net(void)
|
||||||
s32ret = sf_4G_register_net_manual(&stpfncallback);
|
s32ret = sf_4G_register_net_manual(&stpfncallback);
|
||||||
//sf_share_mem_customer_down(1);
|
//sf_share_mem_customer_down(1);
|
||||||
SF_APPCOMM_CHECK_RETURN(s32ret, s32ret);
|
SF_APPCOMM_CHECK_RETURN(s32ret, s32ret);
|
||||||
|
set_at_parament();
|
||||||
|
s32ret = sf_USB_net_init();
|
||||||
|
|
||||||
|
return s32ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
SINT32 sf_restart_reg_net(void)
|
||||||
|
{
|
||||||
|
SINT32 s32ret = 0;
|
||||||
|
SF_FN_PARAM_S stpfncallback = {0};
|
||||||
|
stpfncallback.pstParam = sf_customer_param_get();
|
||||||
|
stpfncallback.pstaticParam = sf_app_ui_para_get();
|
||||||
|
// stpfncallback.pstaticParam = sf_statistics_param_get();
|
||||||
|
stpfncallback.pfn_AT_instruction_exit = (void *)app_disconnect_4g_module;
|
||||||
|
|
||||||
|
s32ret = sf_4G_register_net_manual(&stpfncallback);
|
||||||
|
|
||||||
return s32ret;
|
return s32ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2223,18 +2251,22 @@ static int sf_is_sdc_mounted(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
int sf_check_sd(void)
|
int sf_check_sd(void)
|
||||||
{
|
{
|
||||||
UINT8 i = 0;
|
UINT8 i = 0;
|
||||||
int ret = SF_SUCCESS;
|
int ret = SF_SUCCESS;
|
||||||
|
if(0 == sf_in_card_exist())
|
||||||
|
{
|
||||||
|
NET_SLOGE("NO SD\r\n");
|
||||||
|
return SF_FAILURE;
|
||||||
|
}
|
||||||
if (sf_sd_status_get() != SF_SD_OK) {
|
if (sf_sd_status_get() != SF_SD_OK) {
|
||||||
ret = SF_FAILURE;
|
ret = SF_FAILURE;
|
||||||
for (i = 0; i < 20; i++)
|
for (i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
ret = sf_sd_status_get();
|
if (SF_SD_OK == sf_sd_status_get())
|
||||||
if (SF_SD_OK == ret)
|
|
||||||
{
|
{
|
||||||
ret = SF_SUCCESS;
|
ret = SF_SUCCESS;
|
||||||
MLOGI("SD\r\n");
|
MLOGI("SD\r\n");
|
||||||
|
@ -2308,6 +2340,29 @@ void sf_save_camera_gps_info(void)
|
||||||
|
|
||||||
printf("[%s:%d] e\n", __FUNCTION__, __LINE__);
|
printf("[%s:%d] e\n", __FUNCTION__, __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sf_net_dns_ck(void)
|
||||||
|
{
|
||||||
|
int result = system("ping -c 3 www.baidu.com");
|
||||||
|
|
||||||
|
if (result == -1) {
|
||||||
|
perror("Error calling system");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
} else if (WIFEXITED(result)) {
|
||||||
|
int exit_status = WEXITSTATUS(result);
|
||||||
|
if (exit_status == 0) {
|
||||||
|
printf("Ping command executed successfully.\n");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
printf("Ping command failed with exit status %d.\n", exit_status);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("Ping command did not terminate normally.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1337,15 +1337,29 @@ UINT8 sf_battery_value_get(UINT8 nightMode)
|
||||||
*************************************************/
|
*************************************************/
|
||||||
UINT8 sf_battery_type_get(void)
|
UINT8 sf_battery_type_get(void)
|
||||||
{
|
{
|
||||||
|
UIMenuStoreInfo *puiPara = sf_app_ui_para_get();
|
||||||
|
|
||||||
if(IsPowerDcIn)
|
if(IsPowerDcIn)
|
||||||
|
{
|
||||||
return SF_POWER_TYPE_DC;
|
return SF_POWER_TYPE_DC;
|
||||||
|
}
|
||||||
else if(LiPolymerVoltageVal)
|
else if(LiPolymerVoltageVal)
|
||||||
|
{
|
||||||
|
if(SF_BATT_LI != puiPara->BatteryType)
|
||||||
|
{
|
||||||
|
puiPara->BatteryType = SF_BATT_LI;
|
||||||
|
}
|
||||||
return SF_POWER_TYPE_LI_POLYER;
|
return SF_POWER_TYPE_LI_POLYER;
|
||||||
|
}
|
||||||
else if(BatVoltageVal)
|
else if(BatVoltageVal)
|
||||||
|
{
|
||||||
return SF_POWER_TYPE_AA;
|
return SF_POWER_TYPE_AA;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return SF_POWER_TYPE_DC;
|
return SF_POWER_TYPE_DC;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************
|
/*************************************************
|
||||||
Function: sf_battery_type_get
|
Function: sf_battery_type_get
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <sys/vfs.h>
|
#include <sys/vfs.h>
|
||||||
#include<pthread.h>
|
#include<pthread.h>
|
||||||
#include <sf_message_queue.h>
|
#include <sf_message_queue.h>
|
||||||
|
#include "kwrap/nvt_type.h"
|
||||||
#include "sf_eg91_sim.h"
|
#include "sf_eg91_sim.h"
|
||||||
#include "sf_common.h"
|
#include "sf_common.h"
|
||||||
#include "sf_hal_ttyusb.h"
|
#include "sf_hal_ttyusb.h"
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include "sf_battery.h"
|
#include "sf_battery.h"
|
||||||
|
|
||||||
|
#include "sys_usrmem.h"
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -692,7 +694,7 @@ SINT32 sf_upload_send_files_to_module(UINT8 mode)
|
||||||
{
|
{
|
||||||
SendPicSize = tempPicSize;
|
SendPicSize = tempPicSize;
|
||||||
/*sf_get_send_video_fname(videoDirKey, videoFname);
|
/*sf_get_send_video_fname(videoDirKey, videoFname);
|
||||||
sprintf((char *)uploadAbsolutePath[0], "%s\\%s%s\\%s", SF_DCIM_DIR, videoDirKey, DCF_DIR_FREE_CHAR, videoFname);
|
sprintf((char *)uploadAbsolutePath[0], "%s\\%s%s\\%s", SF_DCIM_DIR, videoDirKey, DCF_DIR_NAME, videoFname);
|
||||||
sprintf((char *)uploadFname[0], "%s", videoFname);*/
|
sprintf((char *)uploadFname[0], "%s", videoFname);*/
|
||||||
|
|
||||||
fileIndex = sf_check_file_video();
|
fileIndex = sf_check_file_video();
|
||||||
|
@ -1561,6 +1563,212 @@ UINT8 sf_get_send_file_total(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if SF_NO_SD_SEND == ENABLE
|
||||||
|
/*************************************************
|
||||||
|
Function: sf_mem_upload_file_to_module
|
||||||
|
Description: upload file to module.
|
||||||
|
Input: N/A
|
||||||
|
Output: N/A
|
||||||
|
Return: 0:success; else:fail;
|
||||||
|
Others: N/A
|
||||||
|
*************************************************/
|
||||||
|
SINT32 sf_mem_upload_file_to_module(UINT32 MemPhotoAddr, UINT32 MemPhotosize)
|
||||||
|
{
|
||||||
|
UINT32 count = 0;
|
||||||
|
SINT32 uploadFsize = MemPhotosize;
|
||||||
|
SINT32 ret = SF_SUCCESS; //0:success; else:fail;
|
||||||
|
SINT32 ttyRet = SF_FAILURE;
|
||||||
|
UINT32 countflag = 0;
|
||||||
|
//UINT32 time = 0;
|
||||||
|
|
||||||
|
//UINT8 sdFname[64] = {0};
|
||||||
|
//UINT8 gsmPara[GPRS_INFO_LINE_MAX] = {0};
|
||||||
|
SF_QUECTEL_UPLOAD_E enUploadLocation = QUECTEL_UPLOAD_FRIST;
|
||||||
|
sf_set_upload_to_module_flag(0); // test
|
||||||
|
if(sf_get_del_flag() == FALSE)
|
||||||
|
{
|
||||||
|
sf_set_del_flag(TRUE);
|
||||||
|
enUploadLocation = QUECTEL_UPLOAD_QFDEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("[%s:%d] s\n", __FUNCTION__, __LINE__);
|
||||||
|
|
||||||
|
sf_gsm_para_buff_clear();
|
||||||
|
|
||||||
|
while(sf_app_while_flag())
|
||||||
|
{
|
||||||
|
sf_gsm_para_buff_clear();
|
||||||
|
sf_hal_ttyusb2_read(gsmPara, 200);
|
||||||
|
|
||||||
|
printf("-----enUploadLocation=%d-----count=%d-----\n", enUploadLocation, count);
|
||||||
|
|
||||||
|
if(gsmPara[0] != '\0')
|
||||||
|
{
|
||||||
|
printf("gsmPara:%s\n================end\n", gsmPara);
|
||||||
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
|
|
||||||
|
if(count > 500)
|
||||||
|
{
|
||||||
|
ret = SF_UPLOAD_ERROR_AT_TIMEOUT;
|
||||||
|
printf("[%s:%d]MMS AT Timeout,enUploadLocation=%d,Error Code:0x%08X\n",
|
||||||
|
__FUNCTION__, __LINE__, enUploadLocation, ret);
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)gsmPara, "[%s:%d]MMS AT Timeout,enUploadLocation=%d,Error Code:0x%08X\n",
|
||||||
|
__FUNCTION__, __LINE__, enUploadLocation, ret);
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
count = 0;
|
||||||
|
goto SF_QUECTEL_UPLOAD_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(enUploadLocation)
|
||||||
|
{
|
||||||
|
case QUECTEL_UPLOAD_QFDEL:
|
||||||
|
enUploadLocation = QUECTEL_UPLOAD_QFLST;
|
||||||
|
sprintf((char *)gsmPara, "AT+QFDEL=\"*\"\r");
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QUECTEL_UPLOAD_QFLST:
|
||||||
|
|
||||||
|
if(strstr((const char *)gsmPara, "ERROR"))
|
||||||
|
{
|
||||||
|
ret = SF_UPLOAD_ERROR_GET_FSIZE_FAIL;
|
||||||
|
sprintf((char *)gsmPara, "[%s:%d] AT+QFDEL,Error Code:0x%08X\n", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
goto SF_QUECTEL_UPLOAD_END;
|
||||||
|
}
|
||||||
|
else if(strstr((const char *)gsmPara, "OK"))
|
||||||
|
{
|
||||||
|
enUploadLocation = QUECTEL_UPLOAD_FRIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QUECTEL_UPLOAD_FRIST:
|
||||||
|
|
||||||
|
enUploadLocation = QUECTEL_UPLOAD_QFUPL;
|
||||||
|
sprintf((char *)gsmPara, "AT+QFUPL=\"UFS:MEMPHOTO.JPG\",%d\r", uploadFsize);
|
||||||
|
ttyRet = sf_hal_ttyusb2_write(gsmPara, strlen((const char *)gsmPara));
|
||||||
|
SF_CHECK_RETURN(ttyRet, SF_GPRS_MODULE_ERROR_WRITE);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QUECTEL_UPLOAD_QFUPL:
|
||||||
|
|
||||||
|
if(strstr((const char *)gsmPara, "ERROR"))
|
||||||
|
{
|
||||||
|
if(strstr((const char *)gsmPara, "+CME ERROR: 407"))
|
||||||
|
{
|
||||||
|
printf("[%s:%d]file already exist,continue.\n", __FUNCTION__, __LINE__);
|
||||||
|
//enUploadLocation = QUECTEL_UPLOAD_END;
|
||||||
|
sf_test_upload_tm_log = 1;
|
||||||
|
goto SF_QUECTEL_UPLOAD_END;
|
||||||
|
}
|
||||||
|
else if((strstr((const char *)gsmPara, "+CME ERROR: 423")) || (strstr((const char *)gsmPara, "+CME ERROR: 407")))
|
||||||
|
{
|
||||||
|
ret = SF_UPLOAD_ERROR_DATA;
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
printf("[%s:%d]Upload data error\n", __FUNCTION__, __LINE__);
|
||||||
|
sprintf((char *)gsmPara, "[%s:%d]Upload data error,Error Code:0x%08X\n", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
|
||||||
|
sf_test_upload_tm_log = 1;
|
||||||
|
goto SF_QUECTEL_UPLOAD_END;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = SF_UPLOAD_ERROR_DATA;
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
printf("[%s:%d]Upload data error\n", __FUNCTION__, __LINE__);
|
||||||
|
sprintf((char *)gsmPara, "[%s:%d]Upload data error,Error Code:0x%08X\n", __FUNCTION__, __LINE__, ret);
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
//enUploadLocation = QUECTEL_UPLOAD_END;
|
||||||
|
sf_test_upload_tm_log = 1;
|
||||||
|
goto SF_QUECTEL_UPLOAD_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if((sf_get_upload_to_module_flag() == 1) && (strstr((const char *)gsmPara, "+QFUPL:")))
|
||||||
|
{
|
||||||
|
printf("[%s:%d]upload success\n", __FUNCTION__, __LINE__);
|
||||||
|
|
||||||
|
sf_test_upload_tm_log = 1;
|
||||||
|
goto SF_QUECTEL_UPLOAD_END;
|
||||||
|
}
|
||||||
|
else if(strstr((const char *)gsmPara, "CONNECT") || (1 == countflag))
|
||||||
|
{
|
||||||
|
sf_test_uploadFsize = 0;
|
||||||
|
|
||||||
|
ret = sf_hal_ttyusb2_write((SF_CHAR *)MemPhotoAddr, MemPhotosize);
|
||||||
|
if(ret != SF_FAILURE)
|
||||||
|
{
|
||||||
|
printf("[%s:%d]Upload data error\n", __FUNCTION__, __LINE__);
|
||||||
|
}
|
||||||
|
sf_sleep_ms(300);
|
||||||
|
sf_set_upload_to_module_flag(1);
|
||||||
|
sf_test_uploadFsize = uploadFsize;
|
||||||
|
countflag = 2;
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sf_sleep_ms(1000);
|
||||||
|
countflag++;
|
||||||
|
|
||||||
|
if(count > sf_test_upload_tm) /*18S*/
|
||||||
|
{
|
||||||
|
//sf_cmd_camera_restart(1); //reboot modu
|
||||||
|
//enUploadLocation = QUECTEL_UPLOAD_END;
|
||||||
|
ret = SF_UPLOAD_ERROR_AT_TIMEOUT;
|
||||||
|
printf("[%s:%d]Upload To Module Timeout,enUploadLocation=%d,Error Code:0x%08X\n",
|
||||||
|
__FUNCTION__, __LINE__, enUploadLocation, ret);
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sprintf((char *)gsmPara, "[%s:%d]Upload To Module Timeout,enUploadLocation=%d,Error Code:0x%08X\n",
|
||||||
|
__FUNCTION__, __LINE__, enUploadLocation, ret);
|
||||||
|
SLOGE(gsmPara);
|
||||||
|
sf_test_upload_tm_log = 1;
|
||||||
|
goto SF_QUECTEL_UPLOAD_END;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QUECTEL_UPLOAD_END:
|
||||||
|
sf_test_upload_tm_log = 1;
|
||||||
|
goto SF_QUECTEL_UPLOAD_END;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SF_QUECTEL_UPLOAD_END:
|
||||||
|
SLOGD("End,ret=0x%08x\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
UINT32 MemPhotoAddr , MemPhotosize;
|
||||||
|
|
||||||
|
SINT32 sf_usr_mem_photo_ch(void)
|
||||||
|
{
|
||||||
|
SYS_USRMEM usrmem = {0};
|
||||||
|
|
||||||
|
if(sys_usrmem_init(&usrmem) == 0){
|
||||||
|
if(sys_usrmem_read_photo(&usrmem, &MemPhotoAddr, &MemPhotosize) == 0){
|
||||||
|
SLOGI("photo address %lx, size %lx", MemPhotoAddr, MemPhotosize);
|
||||||
|
return sf_mem_upload_file_to_module(MemPhotoAddr, MemPhotosize);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
SLOGE("read photo failed\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ static int sf_is_sdc_mounted(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
printf("%s:%d is_mounted:%d", __FUNCTION__, __LINE__,is_mounted);
|
//printf("%s:%d is_mounted:%d", __FUNCTION__, __LINE__,is_mounted);
|
||||||
|
|
||||||
return is_mounted;
|
return is_mounted;
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,7 +271,7 @@ static void sf_blue_command_get_camera_para(MSG_DEV_BLE_Param_Get_Rsp_T *CamPara
|
||||||
|
|
||||||
CamPara->batType = puiPara->BatteryType;
|
CamPara->batType = puiPara->BatteryType;
|
||||||
|
|
||||||
CamPara->cameraID = puiPara->CamNameSwitch == SF_CAMID_OFF ? 0:1;
|
CamPara->cameraID = puiPara->CamNameSwitch == SF_CAMID_OFF ? 1:0;
|
||||||
strcpy((char *)CamPara->cameraIDstr, (char *)puiPara->CamNameStr);
|
strcpy((char *)CamPara->cameraIDstr, (char *)puiPara->CamNameStr);
|
||||||
|
|
||||||
CamPara->dateTimeAuto = puiPara->DateAuto;
|
CamPara->dateTimeAuto = puiPara->DateAuto;
|
||||||
|
@ -791,7 +791,7 @@ static signed int sf_blue_command_request_process(U8 *val, unsigned int nval, U8
|
||||||
case BLE_SET_CAMERA_CameraID: //O
|
case BLE_SET_CAMERA_CameraID: //O
|
||||||
{
|
{
|
||||||
BLU_SLOGI("[BLE_SET_CAMERA_CameraID],cameraID:%d\n",pMsgStruct->msgBuf.setCameraID.cameraID);
|
BLU_SLOGI("[BLE_SET_CAMERA_CameraID],cameraID:%d\n",pMsgStruct->msgBuf.setCameraID.cameraID);
|
||||||
puiPara->CamNameSwitch = pMsgStruct->msgBuf.setCameraID.cameraID == 0 ? SF_CAMID_OFF : SF_CAMID_ON;
|
puiPara->CamNameSwitch = pMsgStruct->msgBuf.setCameraID.cameraID == 1 ? SF_CAMID_OFF : SF_CAMID_ON;
|
||||||
strncpy(puiPara->CamNameStr, (char *)pMsgStruct->msgBuf.setCameraID.cameraIDstr, 4); //Use SF_STRNCPY to avoid that APP has not send '\0'.
|
strncpy(puiPara->CamNameStr, (char *)pMsgStruct->msgBuf.setCameraID.cameraIDstr, 4); //Use SF_STRNCPY to avoid that APP has not send '\0'.
|
||||||
sf_camera_name_check(puiPara->CamNameStr);
|
sf_camera_name_check(puiPara->CamNameStr);
|
||||||
puiPara->CamNameStr[4] = '\0';
|
puiPara->CamNameStr[4] = '\0';
|
||||||
|
|
|
@ -0,0 +1,264 @@
|
||||||
|
|
||||||
|
#include "sys_usrmem.h"
|
||||||
|
#include "rtosfdt.h"
|
||||||
|
#include "libfdt.h"
|
||||||
|
#include "compiler.h"
|
||||||
|
#include <kwrap/error_no.h>
|
||||||
|
#include <kwrap/debug.h>
|
||||||
|
#include "MemCheck.h"
|
||||||
|
#include "hdal.h"
|
||||||
|
|
||||||
|
#if !defined(__FREERTOS)
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__FREERTOS)
|
||||||
|
|
||||||
|
INT32 sys_usrmem_init(SYS_USRMEM* usrmem)
|
||||||
|
{
|
||||||
|
const void* fdt = fdt_get_base();
|
||||||
|
int nodeoffset = fdt_path_offset((const void*)fdt, SYS_USRMEM_NODE);
|
||||||
|
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if(usrmem == NULL){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
usrmem->is_init = FALSE;
|
||||||
|
|
||||||
|
if(nodeoffset >= 0){
|
||||||
|
const unsigned long *nodep;
|
||||||
|
nodep = (const unsigned long *)fdt_getprop(fdt, nodeoffset, "reg", &len);
|
||||||
|
|
||||||
|
usrmem->used_size = 0;
|
||||||
|
usrmem->addr = be32_to_cpu(nodep[0]);
|
||||||
|
usrmem->size = be32_to_cpu(nodep[1]);
|
||||||
|
|
||||||
|
usrmem->hdr = (SYS_USRMEM_HDR*) usrmem->addr;
|
||||||
|
usrmem->hdr->photo_ofs = 0;
|
||||||
|
usrmem->hdr->photo_size = 0;
|
||||||
|
usrmem->hdr->photo_sum = 0;
|
||||||
|
usrmem->hdr->tag = SYS_USRMEM_TAG;
|
||||||
|
usrmem->used_size += sizeof(SYS_USRMEM_HDR);
|
||||||
|
usrmem->addr_photo = usrmem->addr + usrmem->used_size;
|
||||||
|
|
||||||
|
DBG_DUMP("usrmem addr = %lx, size = %lx, addr_hdr = %lx, addr_photo = %lx\n",
|
||||||
|
usrmem->addr,
|
||||||
|
usrmem->size,
|
||||||
|
usrmem->hdr ,
|
||||||
|
usrmem->addr_photo);
|
||||||
|
|
||||||
|
usrmem->is_init = TRUE;
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG_ERR("fdt node %s not found!\n", SYS_USRMEM_NODE);
|
||||||
|
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 sys_usrmem_write_photo(SYS_USRMEM* usrmem, UINT32 buf, UINT32 size)
|
||||||
|
{
|
||||||
|
if(usrmem == NULL){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(usrmem->addr_photo == 0){
|
||||||
|
DBG_ERR("address photo can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(buf == 0){
|
||||||
|
DBG_ERR("buf can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(size == 0){
|
||||||
|
DBG_ERR("size can't be zero!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(usrmem->is_init == FALSE){
|
||||||
|
DBG_ERR("usrmem is not init yet!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
memcpy((void*)usrmem->addr_photo, (void*)buf, size);
|
||||||
|
usrmem->hdr->photo_ofs = usrmem->used_size;
|
||||||
|
usrmem->hdr->photo_size = size;
|
||||||
|
usrmem->hdr->photo_sum = MemCheck_CalcCheckSum16Bit(usrmem->addr_photo, size);
|
||||||
|
usrmem->used_size += size;
|
||||||
|
|
||||||
|
hd_common_mem_flush_cache((void*)usrmem->addr, usrmem->used_size);
|
||||||
|
|
||||||
|
DBG_DUMP("photo addr:%lx, size:%lx, sum:%lx\n", usrmem->addr_photo, usrmem->hdr->photo_size, usrmem->hdr->photo_sum);
|
||||||
|
|
||||||
|
return E_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
static void* usrmem_mmap(int fd, unsigned int mapped_size, off_t phy_addr)
|
||||||
|
{
|
||||||
|
void *map_base = NULL;
|
||||||
|
unsigned page_size = 0;
|
||||||
|
|
||||||
|
page_size = getpagesize();
|
||||||
|
map_base = mmap(NULL,
|
||||||
|
mapped_size,
|
||||||
|
PROT_READ | PROT_WRITE,
|
||||||
|
MAP_SHARED,
|
||||||
|
fd,
|
||||||
|
(phy_addr) & ~(off_t)(page_size - 1));
|
||||||
|
|
||||||
|
if (map_base == MAP_FAILED)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return map_base;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int usrmem_munmap(void* map_base, unsigned int mapped_size)
|
||||||
|
{
|
||||||
|
if (munmap(map_base, mapped_size) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int usrmem_init_dev(char* dev)
|
||||||
|
{
|
||||||
|
int fd = 0;
|
||||||
|
|
||||||
|
DBG_DUMP("open %s\n", dev);
|
||||||
|
|
||||||
|
fd = open(dev, O_RDWR | O_SYNC);
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 sys_usrmem_init(SYS_USRMEM* usrmem)
|
||||||
|
{
|
||||||
|
const void* fdt = fdt_get_base();
|
||||||
|
int nodeoffset = fdt_path_offset((const void*)fdt, SYS_USRMEM_NODE);
|
||||||
|
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if(usrmem == NULL){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
usrmem->is_init = FALSE;
|
||||||
|
|
||||||
|
if(nodeoffset >= 0){
|
||||||
|
const unsigned long *nodep;
|
||||||
|
nodep = (const unsigned long *)fdt_getprop(fdt, nodeoffset, "reg", &len);
|
||||||
|
|
||||||
|
usrmem->addr = be32_to_cpu(nodep[0]);
|
||||||
|
usrmem->size = be32_to_cpu(nodep[1]);
|
||||||
|
|
||||||
|
int fd = usrmem_init_dev("/dev/mem");
|
||||||
|
if(fd < 0){
|
||||||
|
DBG_ERR("open %s failed\n", "/dev/mem");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG_DUMP("usrmem addr:%lx size:%lx\n", usrmem->addr, usrmem->size);
|
||||||
|
|
||||||
|
void* va = usrmem_mmap(fd, usrmem->size ,usrmem->addr);
|
||||||
|
if(va){
|
||||||
|
|
||||||
|
usrmem->hdr = va;
|
||||||
|
usrmem->used_size = sizeof(SYS_USRMEM_HDR);
|
||||||
|
|
||||||
|
if(usrmem->hdr->tag == SYS_USRMEM_TAG){
|
||||||
|
|
||||||
|
DBG_DUMP("check tag ok, hdr ofs:%lx, size:%lx, sum:%lx\n",
|
||||||
|
usrmem->hdr->photo_ofs,
|
||||||
|
usrmem->hdr->photo_size,
|
||||||
|
usrmem->hdr->photo_sum);
|
||||||
|
|
||||||
|
usrmem->addr_photo = (UINT32)va + usrmem->hdr->photo_ofs;
|
||||||
|
|
||||||
|
DBG_DUMP("photo data = %lx\n", *((UINT32*)usrmem->addr_photo));
|
||||||
|
|
||||||
|
UINT32 sum = MemCheck_CalcCheckSum16Bit(usrmem->addr_photo, usrmem->hdr->photo_size);
|
||||||
|
|
||||||
|
usrmem->used_size += usrmem->hdr->photo_size;
|
||||||
|
|
||||||
|
if(sum == usrmem->hdr->photo_sum){
|
||||||
|
DBG_DUMP("checksum ok(%lx)\n", sum);
|
||||||
|
usrmem->is_init = TRUE;
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
DBG_ERR("checksum err(%lx)\n", sum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
DBG_WRN("invalid usrmem hdr tag(%lx)!\n", usrmem->hdr->tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
DBG_ERR("mmap failed(addr:%lx size:%lx)\n", usrmem->addr, usrmem->size);
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 sys_usrmem_read_photo(SYS_USRMEM* usrmem, UINT32* addr, UINT32* size)
|
||||||
|
{
|
||||||
|
if(usrmem == NULL){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(usrmem->is_init == FALSE){
|
||||||
|
DBG_ERR("usrmem not init yet!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(addr == NULL || size == NULL){
|
||||||
|
DBG_ERR("addr & size can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
*addr = usrmem->addr_photo;
|
||||||
|
*size = usrmem->hdr->photo_size;
|
||||||
|
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 sys_usrmem_hdr_uninit(SYS_USRMEM* usrmem)
|
||||||
|
{
|
||||||
|
if(usrmem == NULL ){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!usrmem->addr && !usrmem->size){
|
||||||
|
DBG_ERR("addr & size can't be zero!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return usrmem_munmap((void* )usrmem->addr, usrmem->size);;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -561,7 +561,7 @@ void appsvr_getFileList(UINT8 *dirPath, UINT8 *startFileKey)
|
||||||
gDevFileList[nFileNums + gDevFileListNums].srcFileType = (ptr->d_name[0] == 'W' ? 0 : (ptr->d_name[0] == 'S' ? 1 : 1));//ptr->d_name[3] - '0';
|
gDevFileList[nFileNums + gDevFileListNums].srcFileType = (ptr->d_name[0] == 'W' ? 0 : (ptr->d_name[0] == 'S' ? 1 : 1));//ptr->d_name[3] - '0';
|
||||||
//printf("%s\n", g3g75DevFileList[nFileNums - idx + gDevFileListNums].fileName);
|
//printf("%s\n", g3g75DevFileList[nFileNums - idx + gDevFileListNums].fileName);
|
||||||
nFileNums ++ ;
|
nFileNums ++ ;
|
||||||
//MLOGI("fileNameString:%s.\n", gDevFileList[nFileNums + gDevFileListNums].fileNameString);
|
// MLOGI("fileNameString:%s. srcFileType:%d\n", gDevFileList[nFileNums + gDevFileListNums].fileNameString, gDevFileList[nFileNums + gDevFileListNums].srcFileType);
|
||||||
}
|
}
|
||||||
//printf("[appsvr_getFileList]%d,%s\n",nFileNums - idx, gDevFileList[nFileNums - idx].fileName);
|
//printf("[appsvr_getFileList]%d,%s\n",nFileNums - idx, gDevFileList[nFileNums - idx].fileName);
|
||||||
}
|
}
|
||||||
|
@ -659,7 +659,7 @@ UINT8 appCmpFileList(void)
|
||||||
//appThumbNameToKey(&fileType, &dirKey, &fileKey, gDevFileList[i].fileNameString);ERROR:dirKey always zero
|
//appThumbNameToKey(&fileType, &dirKey, &fileKey, gDevFileList[i].fileNameString);ERROR:dirKey always zero
|
||||||
//printf("dirkey=%d\n",dirKey);
|
//printf("dirkey=%d\n",dirKey);
|
||||||
sprintf(fileName,"D:/DCIM/%.3s%s/%s%.4s%s",
|
sprintf(fileName,"D:/DCIM/%.3s%s/%s%.4s%s",
|
||||||
gDevFileList[i].fileNameString,DCF_DIR_FREE_CHAR,DCF_FILE_FREE_CHAR,gDevFileList[i].fileNameString+4,
|
gDevFileList[i].fileNameString,DCF_DIR_NAME,DCF_FILE_NAME,gDevFileList[i].fileNameString+4,
|
||||||
(gDevFileList[i].fileNameString[3] == '0' ? ".JPG" : (gDevFileList[i].fileNameString[3] == '1' ? ".MP4" : ".MP4")));
|
(gDevFileList[i].fileNameString[3] == '0' ? ".JPG" : (gDevFileList[i].fileNameString[3] == '1' ? ".MP4" : ".MP4")));
|
||||||
//profLogPrintf(0,"file:%s", fileName);
|
//profLogPrintf(0,"file:%s", fileName);
|
||||||
//printf("str:%s,name:%s,\n",gDevFileList[i].fileNameString,fileName);
|
//printf("str:%s,name:%s,\n",gDevFileList[i].fileNameString,fileName);
|
||||||
|
@ -702,10 +702,10 @@ void appCreatThumbList(S8 *fileName)//start file name example: 10010032.JPG
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MLOGI("fileName3:%s\n",fileName);
|
MLOGI("fileName3:%s\n",fileName);
|
||||||
//startDirKey[0] = '\0';
|
startDirKey[0] = '\0';
|
||||||
//startFileKey[0] = '\0';
|
startFileKey[0] = '\0';
|
||||||
strncpy((char *)startDirKey, "100", 3);
|
//strncpy((char *)startDirKey, "100", 3);
|
||||||
strncpy((char *)startFileKey, "0001", 4);
|
//strncpy((char *)startFileKey, "0001", 4);
|
||||||
}
|
}
|
||||||
//MLOGI("startDirKey:%s startFileKey:%s sizeof:%d\n",startDirKey,startFileKey, FILE_LIST_NUM_MAX*(sizeof(MSG_DEV_THUMB_LIST_Get_Data_Rsp_T)));
|
//MLOGI("startDirKey:%s startFileKey:%s sizeof:%d\n",startDirKey,startFileKey, FILE_LIST_NUM_MAX*(sizeof(MSG_DEV_THUMB_LIST_Get_Data_Rsp_T)));
|
||||||
//memset(gDevFileList, 0, FILE_LIST_NUM_MAX*(sizeof(MSG_DEV_THUMB_LIST_Get_Data_Rsp_T)));
|
//memset(gDevFileList, 0, FILE_LIST_NUM_MAX*(sizeof(MSG_DEV_THUMB_LIST_Get_Data_Rsp_T)));
|
||||||
|
@ -975,7 +975,7 @@ void sf_app_Get_Camera_Para(MSG_DEV_Param_Get_Rsp_T *CamPara)
|
||||||
|
|
||||||
CamPara->batType = puiPara->BatteryType;
|
CamPara->batType = puiPara->BatteryType;
|
||||||
|
|
||||||
CamPara->cameraID = puiPara->CamNameSwitch == SF_CAMID_OFF ? 0:1;
|
CamPara->cameraID = puiPara->CamNameSwitch == SF_CAMID_OFF ? 1:0;
|
||||||
strcpy((char *)CamPara->cameraIDstr, (char *)puiPara->CamNameStr);
|
strcpy((char *)CamPara->cameraIDstr, (char *)puiPara->CamNameStr);
|
||||||
|
|
||||||
CamPara->dateTimeAuto = puiPara->DateAuto;
|
CamPara->dateTimeAuto = puiPara->DateAuto;
|
||||||
|
@ -1261,8 +1261,8 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen)
|
||||||
// printf("nRet = %d\n", nRet);
|
// printf("nRet = %d\n", nRet);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i =0 ; i<16; i++)
|
for(i =0 ; i<(SINT32)gDevFileListNums; i++)
|
||||||
printf("%s\n",gDevFileList[i].fileNameString);
|
printf("%s %d\n",gDevFileList[i].fileNameString, gDevFileList[i].srcFileType);
|
||||||
|
|
||||||
memdump(gDevFileList, sendSize);
|
memdump(gDevFileList, sendSize);
|
||||||
|
|
||||||
|
@ -1284,17 +1284,18 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen)
|
||||||
{
|
{
|
||||||
strcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.getHdFile.dirName);
|
strcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.getHdFile.dirName);
|
||||||
strncpy((char *)tempbuf2, (char *)pMsgStruct->msgBuf.getHdFile.dirName, 3);
|
strncpy((char *)tempbuf2, (char *)pMsgStruct->msgBuf.getHdFile.dirName, 3);
|
||||||
sprintf((char *)gFileName, "%s/%s/%s", THUMB_PATH, tempbuf2, tempbuf);
|
sprintf((char *)gFileName, "%s%s/%s", THUMB_PATH, tempbuf2, tempbuf);
|
||||||
}
|
}
|
||||||
else if(pMsgStruct->msgBuf.getHdFile.type == 1) //srouce file
|
else if(pMsgStruct->msgBuf.getHdFile.type == 1) //srouce file
|
||||||
{
|
{
|
||||||
strcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.getHdFile.dirName);
|
strcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.getHdFile.dirName);
|
||||||
strncpy((char *)tempbuf2, (char *)tempbuf, 3);
|
strncpy((char *)tempbuf2, (char *)tempbuf, 3);
|
||||||
tempbuf[8] = '\0';
|
tempbuf[8] = '\0';
|
||||||
sprintf((char *)gFileName, "D:/DCIM/%s%s/%s%s%s",
|
sprintf((char *)gFileName, "%sDCIM/%s%s/%s%s%s",
|
||||||
|
SF_SD_ROOT,
|
||||||
tempbuf2,
|
tempbuf2,
|
||||||
DCF_DIR_FREE_CHAR,
|
DCF_DIR_NAME,
|
||||||
DCF_FILE_FREE_CHAR,
|
DCF_FILE_NAME,
|
||||||
tempbuf+4,
|
tempbuf+4,
|
||||||
(tempbuf[3] == '0' ? ".JPG" : (tempbuf[3] == '1' ? ".MP4" : ".MP4")));
|
(tempbuf[3] == '0' ? ".JPG" : (tempbuf[3] == '1' ? ".MP4" : ".MP4")));
|
||||||
}
|
}
|
||||||
|
@ -1685,7 +1686,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen)
|
||||||
|
|
||||||
case WIFI_SET_CAMERA_CameraID: //O
|
case WIFI_SET_CAMERA_CameraID: //O
|
||||||
MLOGI("[WIFI_SET_CAMERA_CameraID],cameraID:%d\n",pMsgStruct->msgBuf.setCameraID.cameraID);
|
MLOGI("[WIFI_SET_CAMERA_CameraID],cameraID:%d\n",pMsgStruct->msgBuf.setCameraID.cameraID);
|
||||||
puiPara->CamNameSwitch = pMsgStruct->msgBuf.setCameraID.cameraID == 0 ? SF_CAMID_OFF : SF_CAMID_ON;
|
puiPara->CamNameSwitch = pMsgStruct->msgBuf.setCameraID.cameraID == 1 ? SF_CAMID_OFF : SF_CAMID_ON;
|
||||||
strncpy(puiPara->CamNameStr, (char *)pMsgStruct->msgBuf.setCameraID.cameraIDstr, 4); //Use SF_STRNCPY to avoid that APP has not send '\0'.
|
strncpy(puiPara->CamNameStr, (char *)pMsgStruct->msgBuf.setCameraID.cameraIDstr, 4); //Use SF_STRNCPY to avoid that APP has not send '\0'.
|
||||||
sf_camera_name_check(puiPara->CamNameStr);
|
sf_camera_name_check(puiPara->CamNameStr);
|
||||||
puiPara->CamNameStr[4] = '\0';
|
puiPara->CamNameStr[4] = '\0';
|
||||||
|
@ -1809,10 +1810,12 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WIFI_CONTROL_CAMERA_FileTransfer:
|
case WIFI_CONTROL_CAMERA_FileTransfer:
|
||||||
|
//printf("WIFI_CONTROL_CAMERA_FileTransfer\n");
|
||||||
keyMap = ntohl(pMsgStruct->msgBuf.ctrlFileTransfer.PORT);
|
keyMap = ntohl(pMsgStruct->msgBuf.ctrlFileTransfer.PORT);
|
||||||
function = pMsgStruct->msgBuf.ctrlFileTransfer.function;
|
function = pMsgStruct->msgBuf.ctrlFileTransfer.function;
|
||||||
|
|
||||||
MLOGI("[WIFI_CONTROL_CAMERA_FileTransfer], keyMap=%d, function=%d,type:%d \n",keyMap,function,pMsgStruct->msgBuf.ctrlFileTransfer.type);
|
MLOGI("[WIFI_CONTROL_CAMERA_FileTransfer], keyMap=%d, function=%d,type:%d \n",keyMap,function,pMsgStruct->msgBuf.ctrlFileTransfer.type);
|
||||||
|
|
||||||
if(function)
|
if(function)
|
||||||
{
|
{
|
||||||
if(pMsgStruct->msgBuf.ctrlFileTransfer.type == 0) //thumbnail
|
if(pMsgStruct->msgBuf.ctrlFileTransfer.type == 0) //thumbnail
|
||||||
|
@ -1820,7 +1823,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen)
|
||||||
//strcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName);
|
//strcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName);
|
||||||
memcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName,strlen((char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName));
|
memcpy((char *)tempbuf, (char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName,strlen((char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName));
|
||||||
|
|
||||||
sprintf((char *)fileName, "%s/%s", THUMB_PATH, tempbuf);
|
sprintf((char *)fileName, "%s%s", THUMB_PATH, tempbuf);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(pMsgStruct->msgBuf.ctrlFileTransfer.type == 1) //srouce file
|
else if(pMsgStruct->msgBuf.ctrlFileTransfer.type == 1) //srouce file
|
||||||
|
@ -1829,11 +1832,11 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen)
|
||||||
strncpy((char *)tempbuf2, (char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName +1, 3);
|
strncpy((char *)tempbuf2, (char *)pMsgStruct->msgBuf.ctrlFileTransfer.fileName +1, 3);
|
||||||
|
|
||||||
tempbuf[8] = '\0';
|
tempbuf[8] = '\0';
|
||||||
sprintf((char *)fileName, "%s/DCIM/%s%s/%s%s%s",
|
sprintf((char *)fileName, "%sDCIM/%s%s/%s%s%s",
|
||||||
SD_PATH,
|
SD_PATH,
|
||||||
tempbuf2,
|
tempbuf2,
|
||||||
DCF_DIR_FREE_CHAR,
|
DCF_DIR_NAME,
|
||||||
DCF_FILE_FREE_CHAR,
|
DCF_FILE_NAME,
|
||||||
tempbuf+4,
|
tempbuf+4,
|
||||||
(tempbuf[0] == 'W' ? ".JPG" : (tempbuf[0] == 'S' ? ".MP4" : ".MP4")));
|
(tempbuf[0] == 'W' ? ".JPG" : (tempbuf[0] == 'S' ? ".MP4" : ".MP4")));
|
||||||
}
|
}
|
||||||
|
@ -1841,7 +1844,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen)
|
||||||
{
|
{
|
||||||
sprintf((char *)fileName, "%s%s",SF_SD_ROOT,pMsgStruct->msgBuf.ctrlFileTransfer.fileName);
|
sprintf((char *)fileName, "%s%s",SF_SD_ROOT,pMsgStruct->msgBuf.ctrlFileTransfer.fileName);
|
||||||
}
|
}
|
||||||
// printf("rec file cmd:%s\n", fileName);
|
//MLOGI("rec file cmd:%s\n", fileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1865,6 +1868,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen)
|
||||||
// msgParse.msgBuf.rctrlFileTransferInfo.filePath[13]=0;
|
// msgParse.msgBuf.rctrlFileTransferInfo.filePath[13]=0;
|
||||||
msgParse.msgBuf.rctrlFileTransferInfo.type = (tempbuf[0] == 'W' ? 0 : (tempbuf[0] == 'S' ? 1 : 1));
|
msgParse.msgBuf.rctrlFileTransferInfo.type = (tempbuf[0] == 'W' ? 0 : (tempbuf[0] == 'S' ? 1 : 1));
|
||||||
fileFd = open((char *)fileName, O_RDONLY);
|
fileFd = open((char *)fileName, O_RDONLY);
|
||||||
|
//printf("fileFd = %d rctrlFileTransferInfo.type:%d\n", fileFd,msgParse.msgBuf.rctrlFileTransferInfo.type);
|
||||||
if(fileFd > 0)
|
if(fileFd > 0)
|
||||||
{
|
{
|
||||||
fSize = sp5kFsFileSizeGet((char *)fileName);
|
fSize = sp5kFsFileSizeGet((char *)fileName);
|
||||||
|
@ -1935,9 +1939,9 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen)
|
||||||
ret = remove((char *)fileName);
|
ret = remove((char *)fileName);
|
||||||
MLOGI("delete thumb name=%s ret=%d\n",fileName,ret);
|
MLOGI("delete thumb name=%s ret=%d\n",fileName,ret);
|
||||||
if(fileType == STILL_THUMB)
|
if(fileType == STILL_THUMB)
|
||||||
sprintf((char *)fileName,"./%3dMEDIA/%s%04d.JPG", dirKey, DCF_FILE_FREE_CHAR, fileKey);
|
sprintf((char *)fileName,"./%3dMEDIA/%s%04d.JPG", dirKey, DCF_FILE_NAME, fileKey);
|
||||||
else
|
else
|
||||||
sprintf((char *)fileName,"./%3dMEDIA/%s%04d.MP4", dirKey, DCF_FILE_FREE_CHAR, fileKey);
|
sprintf((char *)fileName,"./%3dMEDIA/%s%04d.MP4", dirKey, DCF_FILE_NAME, fileKey);
|
||||||
ret = remove((char *)fileName);
|
ret = remove((char *)fileName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2097,11 +2101,12 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
WIFI_SLOGI("[WIFI_CMD_MAX] default\n");
|
||||||
msgParse.msgBuf.camreaSetRsp.cmdRet = -1;
|
msgParse.msgBuf.camreaSetRsp.cmdRet = -1;
|
||||||
msgParse.msgBuf.camreaSetRsp.suffix = htons(MSG_END_FIX);
|
msgParse.msgBuf.camreaSetRsp.suffix = htons(MSG_END_FIX);
|
||||||
/* add the cmd + resp total 2*2 bytes */
|
/* add the cmd + resp total 2*2 bytes */
|
||||||
msgParse.msglen = htons(sizeof(MSG_DEV_SET_Rsp_T) + 2*sizeof(UINT16) );
|
msgParse.msglen = htons(sizeof(MSG_DEV_SET_Rsp_T) + 2*sizeof(UINT16) );
|
||||||
respFlag = 1;
|
respFlag = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,6 +142,7 @@ SRC = \
|
||||||
./SrcCode/System/SysStrg_CB.c \
|
./SrcCode/System/SysStrg_CB.c \
|
||||||
./SrcCode/System/SysStrg_Exe.c \
|
./SrcCode/System/SysStrg_Exe.c \
|
||||||
./SrcCode/System/SysSensor_Exe.c \
|
./SrcCode/System/SysSensor_Exe.c \
|
||||||
|
./SrcCode/System/sys_usrmem.c \
|
||||||
./SrcCode/UIApp/UIAppObj.c \
|
./SrcCode/UIApp/UIAppObj.c \
|
||||||
./SrcCode/UIApp/ExifVendor.c \
|
./SrcCode/UIApp/ExifVendor.c \
|
||||||
./SrcCode/UIApp/Setup/UISetup_Exe.c \
|
./SrcCode/UIApp/Setup/UISetup_Exe.c \
|
||||||
|
|
|
@ -150,8 +150,11 @@ UINT32 DrvGPIO_GetPhotoMovieModeFromMonitor(void)
|
||||||
UIMenuStoreInfo *puiPara = sf_ui_para_get();
|
UIMenuStoreInfo *puiPara = sf_ui_para_get();
|
||||||
vos_perf_mark(&t1);
|
vos_perf_mark(&t1);
|
||||||
value = sf_get_power_on_mode();
|
value = sf_get_power_on_mode();
|
||||||
|
#if SF_NO_SD_SEND == ENABLE
|
||||||
|
if(gpio_getIntStatus(GPIO_INT_USBPLUGIN) /*|| FALSE == (gpio_getPin(GPIO_CARD_DETECT) == 0 ? TRUE : FALSE)*/)
|
||||||
|
#else
|
||||||
if(gpio_getIntStatus(GPIO_INT_USBPLUGIN) || FALSE == (gpio_getPin(GPIO_CARD_DETECT) == 0 ? TRUE : FALSE))
|
if(gpio_getIntStatus(GPIO_INT_USBPLUGIN) || FALSE == (gpio_getPin(GPIO_CARD_DETECT) == 0 ? TRUE : FALSE))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
g_uiBootMode = DX_HUNTING_MODE_OTHER;
|
g_uiBootMode = DX_HUNTING_MODE_OTHER;
|
||||||
Save_MenuInfo();
|
Save_MenuInfo();
|
||||||
|
|
|
@ -153,7 +153,7 @@ static HD_RESULT flowpreview_mem_relayout(void)
|
||||||
+VDO_CA_BUF_SIZE(CA_WIN_NUM_W, CA_WIN_NUM_H)
|
+VDO_CA_BUF_SIZE(CA_WIN_NUM_W, CA_WIN_NUM_H)
|
||||||
+VDO_LA_BUF_SIZE(LA_WIN_NUM_W, LA_WIN_NUM_H);
|
+VDO_LA_BUF_SIZE(LA_WIN_NUM_W, LA_WIN_NUM_H);
|
||||||
|
|
||||||
mem_cfg.pool_info[idx].blk_cnt = 6;
|
mem_cfg.pool_info[idx].blk_cnt = 7;
|
||||||
mem_cfg.pool_info[idx].ddr_id = DDR_ID0;
|
mem_cfg.pool_info[idx].ddr_id = DDR_ID0;
|
||||||
// config common pool (main)
|
// config common pool (main)
|
||||||
// mem_cfg.pool_info[1].type = HD_COMMON_MEM_COMMON_POOL;
|
// mem_cfg.pool_info[1].type = HD_COMMON_MEM_COMMON_POOL;
|
||||||
|
|
|
@ -985,6 +985,7 @@
|
||||||
#ifndef ANR_FUNC
|
#ifndef ANR_FUNC
|
||||||
#define ANR_FUNC ENABLE
|
#define ANR_FUNC ENABLE
|
||||||
#endif
|
#endif
|
||||||
|
#define SF_NO_SD_SEND DISABLE
|
||||||
////////////////////sf end////////////////////////////////
|
////////////////////sf end////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
264
rtos/code/application/source/cardv/SrcCode/System/sys_usrmem.c
Normal file
264
rtos/code/application/source/cardv/SrcCode/System/sys_usrmem.c
Normal file
|
@ -0,0 +1,264 @@
|
||||||
|
|
||||||
|
#include "sys_usrmem.h"
|
||||||
|
#include "rtosfdt.h"
|
||||||
|
#include "libfdt.h"
|
||||||
|
#include "compiler.h"
|
||||||
|
#include <kwrap/error_no.h>
|
||||||
|
#include <kwrap/debug.h>
|
||||||
|
#include "MemCheck.h"
|
||||||
|
#include "hdal.h"
|
||||||
|
|
||||||
|
#if !defined(__FREERTOS)
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__FREERTOS)
|
||||||
|
|
||||||
|
INT32 sys_usrmem_init(SYS_USRMEM* usrmem)
|
||||||
|
{
|
||||||
|
const void* fdt = fdt_get_base();
|
||||||
|
int nodeoffset = fdt_path_offset((const void*)fdt, SYS_USRMEM_NODE);
|
||||||
|
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if(usrmem == NULL){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
usrmem->is_init = FALSE;
|
||||||
|
|
||||||
|
if(nodeoffset >= 0){
|
||||||
|
const unsigned long *nodep;
|
||||||
|
nodep = (const unsigned long *)fdt_getprop(fdt, nodeoffset, "reg", &len);
|
||||||
|
|
||||||
|
usrmem->used_size = 0;
|
||||||
|
usrmem->addr = be32_to_cpu(nodep[0]);
|
||||||
|
usrmem->size = be32_to_cpu(nodep[1]);
|
||||||
|
|
||||||
|
usrmem->hdr = (SYS_USRMEM_HDR*) usrmem->addr;
|
||||||
|
usrmem->hdr->photo_ofs = 0;
|
||||||
|
usrmem->hdr->photo_size = 0;
|
||||||
|
usrmem->hdr->photo_sum = 0;
|
||||||
|
usrmem->hdr->tag = SYS_USRMEM_TAG;
|
||||||
|
usrmem->used_size += sizeof(SYS_USRMEM_HDR);
|
||||||
|
usrmem->addr_photo = usrmem->addr + usrmem->used_size;
|
||||||
|
|
||||||
|
DBG_DUMP("usrmem addr = %lx, size = %lx, addr_hdr = %lx, addr_photo = %lx\n",
|
||||||
|
usrmem->addr,
|
||||||
|
usrmem->size,
|
||||||
|
usrmem->hdr ,
|
||||||
|
usrmem->addr_photo);
|
||||||
|
|
||||||
|
usrmem->is_init = TRUE;
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG_ERR("fdt node %s not found!\n", SYS_USRMEM_NODE);
|
||||||
|
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 sys_usrmem_write_photo(SYS_USRMEM* usrmem, UINT32 buf, UINT32 size)
|
||||||
|
{
|
||||||
|
if(usrmem == NULL){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(usrmem->addr_photo == 0){
|
||||||
|
DBG_ERR("address photo can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(buf == 0){
|
||||||
|
DBG_ERR("buf can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(size == 0){
|
||||||
|
DBG_ERR("size can't be zero!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(usrmem->is_init == FALSE){
|
||||||
|
DBG_ERR("usrmem is not init yet!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
memcpy((void*)usrmem->addr_photo, (void*)buf, size);
|
||||||
|
usrmem->hdr->photo_ofs = usrmem->used_size;
|
||||||
|
usrmem->hdr->photo_size = size;
|
||||||
|
usrmem->hdr->photo_sum = MemCheck_CalcCheckSum16Bit(usrmem->addr_photo, size);
|
||||||
|
usrmem->used_size += size;
|
||||||
|
|
||||||
|
hd_common_mem_flush_cache((void*)usrmem->addr, usrmem->used_size);
|
||||||
|
|
||||||
|
DBG_DUMP("photo addr:%lx, size:%lx, sum:%lx\n", usrmem->addr_photo, usrmem->hdr->photo_size, usrmem->hdr->photo_sum);
|
||||||
|
|
||||||
|
return E_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
static void* usrmem_mmap(int fd, unsigned int mapped_size, off_t phy_addr)
|
||||||
|
{
|
||||||
|
void *map_base = NULL;
|
||||||
|
unsigned page_size = 0;
|
||||||
|
|
||||||
|
page_size = getpagesize();
|
||||||
|
map_base = mmap(NULL,
|
||||||
|
mapped_size,
|
||||||
|
PROT_READ | PROT_WRITE,
|
||||||
|
MAP_SHARED,
|
||||||
|
fd,
|
||||||
|
(phy_addr) & ~(off_t)(page_size - 1));
|
||||||
|
|
||||||
|
if (map_base == MAP_FAILED)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return map_base;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int usrmem_munmap(void* map_base, unsigned int mapped_size)
|
||||||
|
{
|
||||||
|
if (munmap(map_base, mapped_size) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int usrmem_init_dev(char* dev)
|
||||||
|
{
|
||||||
|
int fd = 0;
|
||||||
|
|
||||||
|
DBG_DUMP("open %s\n", dev);
|
||||||
|
|
||||||
|
fd = open(dev, O_RDWR | O_SYNC);
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 sys_usrmem_init(SYS_USRMEM* usrmem)
|
||||||
|
{
|
||||||
|
const void* fdt = fdt_get_base();
|
||||||
|
int nodeoffset = fdt_path_offset((const void*)fdt, SYS_USRMEM_NODE);
|
||||||
|
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if(usrmem == NULL){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
usrmem->is_init = FALSE;
|
||||||
|
|
||||||
|
if(nodeoffset >= 0){
|
||||||
|
const unsigned long *nodep;
|
||||||
|
nodep = (const unsigned long *)fdt_getprop(fdt, nodeoffset, "reg", &len);
|
||||||
|
|
||||||
|
usrmem->addr = be32_to_cpu(nodep[0]);
|
||||||
|
usrmem->size = be32_to_cpu(nodep[1]);
|
||||||
|
|
||||||
|
int fd = usrmem_init_dev("/dev/mem");
|
||||||
|
if(fd < 0){
|
||||||
|
DBG_ERR("open %s failed\n", "/dev/mem");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG_DUMP("usrmem addr:%lx size:%lx\n", usrmem->addr, usrmem->size);
|
||||||
|
|
||||||
|
void* va = usrmem_mmap(fd, usrmem->size ,usrmem->addr);
|
||||||
|
if(va){
|
||||||
|
|
||||||
|
usrmem->hdr = va;
|
||||||
|
usrmem->used_size = sizeof(SYS_USRMEM_HDR);
|
||||||
|
|
||||||
|
if(usrmem->hdr->tag == SYS_USRMEM_TAG){
|
||||||
|
|
||||||
|
DBG_DUMP("check tag ok, hdr ofs:%lx, size:%lx, sum:%lx\n",
|
||||||
|
usrmem->hdr->photo_ofs,
|
||||||
|
usrmem->hdr->photo_size,
|
||||||
|
usrmem->hdr->photo_sum);
|
||||||
|
|
||||||
|
usrmem->addr_photo = (UINT32)va + usrmem->hdr->photo_ofs;
|
||||||
|
|
||||||
|
DBG_DUMP("photo data = %lx\n", *((UINT32*)usrmem->addr_photo));
|
||||||
|
|
||||||
|
UINT32 sum = MemCheck_CalcCheckSum16Bit(usrmem->addr_photo, usrmem->hdr->photo_size);
|
||||||
|
|
||||||
|
usrmem->used_size += usrmem->hdr->photo_size;
|
||||||
|
|
||||||
|
if(sum == usrmem->hdr->photo_sum){
|
||||||
|
DBG_DUMP("checksum ok(%lx)\n", sum);
|
||||||
|
usrmem->is_init = TRUE;
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
DBG_ERR("checksum err(%lx)\n", sum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
DBG_WRN("invalid usrmem hdr tag(%lx)!\n", usrmem->hdr->tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
DBG_ERR("mmap failed(addr:%lx size:%lx)\n", usrmem->addr, usrmem->size);
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 sys_usrmem_read_photo(SYS_USRMEM* usrmem, UINT32* addr, UINT32* size)
|
||||||
|
{
|
||||||
|
if(usrmem == NULL){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(usrmem->is_init == FALSE){
|
||||||
|
DBG_ERR("usrmem not init yet!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(addr == NULL || size == NULL){
|
||||||
|
DBG_ERR("addr & size can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
*addr = usrmem->addr_photo;
|
||||||
|
*size = usrmem->hdr->photo_size;
|
||||||
|
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT32 sys_usrmem_hdr_uninit(SYS_USRMEM* usrmem)
|
||||||
|
{
|
||||||
|
if(usrmem == NULL ){
|
||||||
|
DBG_ERR("usrmem can't be null!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!usrmem->addr && !usrmem->size){
|
||||||
|
DBG_ERR("addr & size can't be zero!\n");
|
||||||
|
return E_SYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return usrmem_munmap((void* )usrmem->addr, usrmem->size);;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
#ifndef SYS_USRMEM_H
|
||||||
|
#define SYS_USRMEM_H
|
||||||
|
|
||||||
|
#include "kwrap/type.h"
|
||||||
|
|
||||||
|
#define SYS_USRMEM_NODE "/nvt_memory_cfg/usrmem"
|
||||||
|
#define SYS_USRMEM_TAG MAKEFOURCC('U','S','R','M')
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
|
||||||
|
UINT32 tag;
|
||||||
|
UINT32 photo_ofs;
|
||||||
|
UINT32 photo_size;
|
||||||
|
UINT32 photo_sum;
|
||||||
|
|
||||||
|
} SYS_USRMEM_HDR;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
|
||||||
|
UINT32 addr;
|
||||||
|
UINT32 size;
|
||||||
|
UINT32 used_size;
|
||||||
|
SYS_USRMEM_HDR* hdr;
|
||||||
|
UINT32 addr_photo;
|
||||||
|
BOOL is_init;
|
||||||
|
|
||||||
|
} SYS_USRMEM;
|
||||||
|
|
||||||
|
INT32 sys_usrmem_init(SYS_USRMEM* usrmem);
|
||||||
|
|
||||||
|
#if defined(__FREERTOS)
|
||||||
|
|
||||||
|
INT32 sys_usrmem_write_photo(SYS_USRMEM* usrmem, UINT32 buf, UINT32 size);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
INT32 sys_usrmem_read_photo(SYS_USRMEM* usrmem, UINT32* addr, UINT32* size);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -1732,6 +1732,11 @@ THREAD_RETTYPE PhotoFast_FlowPreviewThread(void *arg)
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
DBG_WRN("enq frame failed...\n");
|
DBG_WRN("enq frame failed...\n");
|
||||||
|
/* release */
|
||||||
|
if ((hd_ret = hd_videoproc_release_out_buf(vprc_path, &video_frame))!= HD_OK) {
|
||||||
|
DBG_ERR("failed to hd_videoproc_release_out_buf, er=%d\n", (int)hd_ret);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_u32PrvCapCnt >= max_cnt) {
|
if (g_u32PrvCapCnt >= max_cnt) {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "DxHunting.h"
|
#include "DxHunting.h"
|
||||||
#include "UIAppPhoto_Param.h"
|
#include "UIAppPhoto_Param.h"
|
||||||
#include "DCF.h"
|
#include "DCF.h"
|
||||||
|
#include "sys_usrmem.h"
|
||||||
#if HUNTING_CAMERA_MCU == ENABLE
|
#if HUNTING_CAMERA_MCU == ENABLE
|
||||||
#include <sf_mcu.h>
|
#include <sf_mcu.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,7 +41,7 @@
|
||||||
#define PHOTOFAST_SLICE_ENC_DBG_SCREENNAIL_JPG 0
|
#define PHOTOFAST_SLICE_ENC_DBG_SCREENNAIL_JPG 0
|
||||||
#define PHOTOFAST_SLICE_ENC_DBG_THUMBNAIL_JPG 0
|
#define PHOTOFAST_SLICE_ENC_DBG_THUMBNAIL_JPG 0
|
||||||
|
|
||||||
#define PHOTOFAST_SLICE_ENC_QUEUE12_MAX_SIZE 2
|
#define PHOTOFAST_SLICE_ENC_QUEUE12_MAX_SIZE 1
|
||||||
#define PHOTOFAST_SLICE_ENC_QUEUE23_MAX_SIZE 1
|
#define PHOTOFAST_SLICE_ENC_QUEUE23_MAX_SIZE 1
|
||||||
|
|
||||||
#if PHOTOFAST_SLICE_ENC_DBG_PRIMARY_JPG || PHOTOFAST_SLICE_ENC_DBG_SCREENNAIL_JPG || PHOTOFAST_SLICE_ENC_DBG_THUMBNAIL_JPG
|
#if PHOTOFAST_SLICE_ENC_DBG_PRIMARY_JPG || PHOTOFAST_SLICE_ENC_DBG_SCREENNAIL_JPG || PHOTOFAST_SLICE_ENC_DBG_THUMBNAIL_JPG
|
||||||
|
@ -2074,7 +2075,7 @@ INT32 PhotoFast_SliceEncode_CB2(void* user_data)
|
||||||
if(PhotoFast_SliceEncode_Alloc_Buffer_Retry(
|
if(PhotoFast_SliceEncode_Alloc_Buffer_Retry(
|
||||||
&slice_encode_primary_info->bs_buf_mem_info,
|
&slice_encode_primary_info->bs_buf_mem_info,
|
||||||
"slice_enc_primary",
|
"slice_enc_primary",
|
||||||
10,
|
50,
|
||||||
100
|
100
|
||||||
) != E_OK){
|
) != E_OK){
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
|
@ -2245,7 +2246,9 @@ INT32 PhotoFast_SliceEncode_CB2(void* user_data)
|
||||||
param->cnt++;
|
param->cnt++;
|
||||||
if(param->cnt >= param->max_cnt)
|
if(param->cnt >= param->max_cnt)
|
||||||
break;
|
break;
|
||||||
|
if(fastboot_wait_done_timeout(BOOT_INIT_FILESYSOK, 1) != E_OK){
|
||||||
|
goto EXIT;
|
||||||
|
}
|
||||||
} while(1);
|
} while(1);
|
||||||
|
|
||||||
EXIT:
|
EXIT:
|
||||||
|
@ -2310,7 +2313,23 @@ INT32 PhotoFast_SliceEncode_CB3(void* user_data)
|
||||||
* Output jpg file
|
* Output jpg file
|
||||||
******************************************************************/
|
******************************************************************/
|
||||||
extern INT32 PhotoFast_WriteFile(UINT32 Addr, UINT32 Size, UINT32 Fmt, UINT32 uiPathId, char* Path);
|
extern INT32 PhotoFast_WriteFile(UINT32 Addr, UINT32 Size, UINT32 Fmt, UINT32 uiPathId, char* Path);
|
||||||
|
#if SF_NO_SD_SEND == ENABLE
|
||||||
|
if(fastboot_wait_done_timeout(BOOT_INIT_FILESYSOK, FASTBOOT_WAIT_FILESYS_TIMEOUT_MS) != E_OK || fastboot_wait_done_timeout(BOOT_INIT_FILENAMINGOK, FASTBOOT_WAIT_FILENAMING_TIMEOUT_MS) != E_OK){
|
||||||
|
|
||||||
|
DBG_WRN("filesys not ready, store data into mem\n");
|
||||||
|
|
||||||
|
SYS_USRMEM usrmem = {0};
|
||||||
|
|
||||||
|
if(sys_usrmem_init(&usrmem) == E_OK){
|
||||||
|
sys_usrmem_write_photo(
|
||||||
|
&usrmem,
|
||||||
|
(UINT32) queue_ele_in->jpg_combined_addr,
|
||||||
|
queue_ele_in->jpg_combined_size
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#else
|
||||||
if(fastboot_wait_done_timeout(BOOT_INIT_FILESYSOK, FASTBOOT_WAIT_FILESYS_TIMEOUT_MS) != E_OK){
|
if(fastboot_wait_done_timeout(BOOT_INIT_FILESYSOK, FASTBOOT_WAIT_FILESYS_TIMEOUT_MS) != E_OK){
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
}
|
}
|
||||||
|
@ -2318,7 +2337,8 @@ INT32 PhotoFast_SliceEncode_CB3(void* user_data)
|
||||||
if(fastboot_wait_done_timeout(BOOT_INIT_FILENAMINGOK, FASTBOOT_WAIT_FILENAMING_TIMEOUT_MS) != E_OK){
|
if(fastboot_wait_done_timeout(BOOT_INIT_FILENAMINGOK, FASTBOOT_WAIT_FILENAMING_TIMEOUT_MS) != E_OK){
|
||||||
goto EXIT;
|
goto EXIT;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
{
|
||||||
vos_perf_mark(&t1);
|
vos_perf_mark(&t1);
|
||||||
|
|
||||||
#if !PHOTOFAST_FAST_CLOSE
|
#if !PHOTOFAST_FAST_CLOSE
|
||||||
|
@ -2399,6 +2419,7 @@ INT32 PhotoFast_SliceEncode_CB3(void* user_data)
|
||||||
vos_perf_duration(t3, t4) / 1000
|
vos_perf_duration(t3, t4) / 1000
|
||||||
);
|
);
|
||||||
|
|
||||||
|
}
|
||||||
/* check user bs buffer is freed */
|
/* check user bs buffer is freed */
|
||||||
if(queue_ele_in->mem_info_combined.va){
|
if(queue_ele_in->mem_info_combined.va){
|
||||||
PhotoFast_SliceEncode_Free_Buffer(&queue_ele_in->mem_info_combined);
|
PhotoFast_SliceEncode_Free_Buffer(&queue_ele_in->mem_info_combined);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user