diff --git a/code/application/source/sf_app/Makefile b/code/application/source/sf_app/Makefile index 8022f99b9..e6decaf7c 100755 --- a/code/application/source/sf_app/Makefile +++ b/code/application/source/sf_app/Makefile @@ -33,6 +33,9 @@ SIFAR_DIR = $(LIBRARY_DIR)/source/sifar/code SIFAR_APP_DIR = $(APP_DIR)/source/sf_app/code/include SIFAR_APP_LPA_DIR = $(APP_DIR)/source/sf_app/code/source/sf_lpa/LPA_SDK/include +LD_LIBRARY_PATH=$(LIBRARY_DIR)/output/ + + #LIB DIRs for C_LDFLAGS EXTRA_LIB_DIR += \ -L$(LIBC_LIB_DIR) \ @@ -54,6 +57,7 @@ EXTRA_LIB_DIR += \ -L$(NVT_VOS_DIR)/output \ -L$(NVT_DRIVER_DIR)/output \ -L$(APP_DIR)/sifarsdk/out/libs \ + -L$(APP_DIR)/source/sf_app/tools/blue/lib \ # public includes EXTRA_INCLUDE += \ @@ -78,7 +82,14 @@ EXTRA_INCLUDE += \ -I$(SIFAR_APP_DIR) \ -I$(SIFAR_APP_LPA_DIR) \ -I$(APP_DIR)/sifarsdk/out/libs/include \ - + -I$(APP_DIR)/source/sf_app/code/source/sf_blue \ + -I$(APP_DIR)/source/sf_app/code/source/sf_blue/src \ + -I$(APP_DIR)/source/sf_app/code/source/sf_blue/inc/bluetooth \ + -I$(APP_DIR)/source/sf_app/code/source/sf_blue/inc/dbus \ + -I$(APP_DIR)/source/sf_app/code/source/sf_blue/inc/glib \ + -I$(APP_DIR)/source/sf_app/tools/blue/include \ + -I$(APP_DIR)/source/sf_app/tools/blue/include/dbus-1.0 \ + # application local includes EXTRA_INCLUDE += \ -I$(APP_DIR)/source/cardv/SrcCode \ @@ -116,8 +127,17 @@ EXTRA_LIB = \ -lgcc_s \ -lrt \ -lm \ - -l:libstdc++.a \ + -lstdc++ \ -lpthread \ + -lgettextlib -Wl,-rpath-link=$(LD_LIBRARY_PATH) \ + -lgettextpo \ + -lintl \ + -lncurses \ + -lbluetooth \ + -ldbus-1 \ + -lglib-2.0 \ + +# -rpath $(LIBRARY_DIR)/output \ # vos EXTRA_LIB += \ @@ -305,7 +325,17 @@ SRC = \ ./code/source/debugMng/sf_debug.c \ ./code/source/updataMng/sf_md5.c \ ./code/source/updataMng/sf_otamng.c \ - ./code/source/battery/sf_battery.c + ./code/source/battery/sf_battery.c \ + ./code/source/sf_blue/src/client.c \ + ./code/source/sf_blue/src/gatt_service.c \ + ./code/source/sf_blue/src/hciconfig.c \ + ./code/source/sf_blue/src/mainloop.c \ + ./code/source/sf_blue/src/object.c \ + ./code/source/sf_blue/src/polkit.c \ + ./code/source/sf_blue/src/sf_blue_app.c \ + ./code/source/sf_blue/src/sf_blue_hal.c \ + ./code/source/sf_blue/src/util.c \ + ./code/source/sf_blue/src/watch.c \ # ./code/source/wifi/sf_data_transfer.c \ # ./code/source/wifi/sf_svr_send.c \ @@ -363,6 +393,7 @@ clean: else all: $(BIN) + $(BIN): $(OBJ) $(CC) -o $@ $(OBJ) $(LD_FLAGS) $(NM) -n $@ > $@.sym @@ -390,8 +421,8 @@ install: #@mkdir -p $(ROOTFS_DIR)/rootfs/home/payton/blue/share/dbus-1/system.d #@mkdir -p $(ROOTFS_DIR)/rootfs/home/payton/blue/var/run/dbus @mkdir -p $(ROOTFS_DIR)/rootfs/usr/local/share/dbus-1/system-services - #@mkdir -p $(ROOTFS_DIR)/rootfs/usr/share/dbus-1/system-services - #@mkdir -p $(ROOTFS_DIR)/rootfs/usr/share/dbus-1/system.d + @mkdir -p $(ROOTFS_DIR)/rootfs/usr/share/dbus-1/system-services + @mkdir -p $(ROOTFS_DIR)/rootfs/usr/share/dbus-1/system.d @mkdir -p $(ROOTFS_DIR)/rootfs/lib/dbus-1/system-services @mkdir -p $(ROOTFS_DIR)/rootfs/usr/etc/dbus-1/system-services @mkdir -p $(ROOTFS_DIR)/rootfs/usr/etc/dbus-1/system.d @@ -429,5 +460,4 @@ install: @cp -avf $(APP_DIR)/source/sf_app/tools/blue/share/dbus-1 $(ROOTFS_DIR)/rootfs/usr/etc #@cp -avf /home/payton/blue/etc/dbus-1 $(ROOTFS_DIR)/rootfs/home/payton/blue @cp -avf $(APP_DIR)/source/sf_app/tools/blue/dbus-1/system.d/bluetooth.conf $(ROOTFS_DIR)/rootfs/usr/etc/dbus-1/system.d/bluetooth.conf - @cp -darvf $(APP_DIR)/source/sf_app/tools/blue/lib/*.* $(LIBRARY_DIR)/output @echo ">>>>>>>>>>>>>>>>>>> $@ >>>>>>>>>>>>>>>>>>>" diff --git a/code/application/source/sf_app/build/rtk_hciattach b/code/application/source/sf_app/build/rtk_hciattach index 7e6d4832e..58225aaac 100755 Binary files a/code/application/source/sf_app/build/rtk_hciattach and b/code/application/source/sf_app/build/rtk_hciattach differ diff --git a/code/application/source/sf_app/code/source/app/sf_app.c b/code/application/source/sf_app/code/source/app/sf_app.c index d60980f9f..b53980778 100755 --- a/code/application/source/sf_app/code/source/app/sf_app.c +++ b/code/application/source/sf_app/code/source/app/sf_app.c @@ -103,7 +103,7 @@ int main(int argc, char *argv[]) { printf("*********************************************\n"); printf("* *\n"); - printf("* sf_app-v5-0912 *\n"); + printf("* sf_app *\n"); printf("* *\n"); printf("*********************************************\n"); //gpio_direction_input(C_GPIO(10)); diff --git a/code/application/source/sf_app/code/source/app/sf_common.c b/code/application/source/sf_app/code/source/app/sf_common.c index d00dd76b0..704908bd3 100755 --- a/code/application/source/sf_app/code/source/app/sf_common.c +++ b/code/application/source/sf_app/code/source/app/sf_common.c @@ -56,6 +56,8 @@ extern "C" { #include #include "sf_battery.h" #include "sf_hal_ttyusb.h" +#include "sf_blue_app.h" + extern pthread_mutex_t Param_mutexLock; SINT8 longClickhold = 0; SINT8 bmoduleupdate = 0; @@ -761,6 +763,7 @@ static SINT32 sf_app_proccess_cmd_mcu(SF_MESSAGE_BUF_S *pMessageBuf) stMessageBuf.arg3 = (SINT32)sf_get_mcu_ver(); stMessageBuf.cmdId = CMD_MCU; sf_com_message_send_to_cardv(&stMessageBuf); + sf_blue_app_start(); break; case SF_MCU_CMD_MODULE_SLEEP: sf_set_module_sleep_flag(0); diff --git a/code/application/source/sf_app/code/source/sf_blue/src/hciconfig.c b/code/application/source/sf_app/code/source/sf_blue/src/hciconfig.c index 796825abc..425e0e7c7 100755 --- a/code/application/source/sf_app/code/source/sf_blue/src/hciconfig.c +++ b/code/application/source/sf_app/code/source/sf_blue/src/hciconfig.c @@ -26,6 +26,9 @@ #include "hci.h" #include "hci_lib.h" +static struct hci_dev_info di; +static char g_sf_ble_ssid[14] = {0}; + static void cmd_up(int ctl, int hdev) { /* Start HCI device */ @@ -74,6 +77,30 @@ static void cmd_name(int ctl, int hdev, char *name) hdev, strerror(errno), errno); return; } + printf("Name: '%s'\n", name); + hci_close_dev(dd); +} +static int sf_ba2str(const bdaddr_t *ba, char *str) +{ + return sprintf(str, "%2.2X%2.2X%2.2X",ba->b[2], ba->b[1], ba->b[0]); +} +static void cmd_address(int ctl, int hdev, char *ssid) +{ + int dd; + + dd = hci_open_dev(hdev); + if (dd < 0) + { + fprintf(stderr, "Can't open device hci%d: %s (%d)\n", + hdev, strerror(errno), errno); + return; + } + + hci_read_bd_addr(dd, &di.bdaddr, 1000); + + sf_ba2str(&di.bdaddr, ssid); + + printf("BT Address: %s.\n", ssid); hci_close_dev(dd); } @@ -160,6 +187,8 @@ int hciconfig_open_piscan(void) cmd_up(ctl, hdev); usleep(100*1000); + cmd_name(ctl, hdev, g_sf_ble_ssid); + usleep(100*1000); cmd_piscan(ctl, hdev); usleep(100*1000); @@ -173,6 +202,27 @@ int hciconfig_open_piscan(void) } int hciconfig_set_name(char *name) +{ + snprintf(g_sf_ble_ssid, sizeof(g_sf_ble_ssid), "%s",name); + printf("set bluename:%s\n",g_sf_ble_ssid); + // int ctl = -1; + // int hdev = 0; + + // /* Open HCI socket */ + // if ((ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI)) < 0) + // { + // perror("Can't open HCI socket."); + // return -1; + // } + // cmd_up(ctl, hdev); + // cmd_name(ctl, hdev, name); + // usleep(100*1000); + // close(ctl); + // printf("set bluename.\n"); + return 0; +} + +int hciconfig_get_address(char *ssid) { int ctl = -1; int hdev = 0; @@ -184,9 +234,14 @@ int hciconfig_set_name(char *name) return -1; } cmd_up(ctl, hdev); - cmd_name(ctl, hdev, name); + if (ioctl(ctl, HCIGETDEVINFO, (void *) &di)) { + perror("Can't get device info"); + } + + cmd_address(ctl, hdev, ssid); + usleep(100*1000); close(ctl); - printf("set bluename.\n"); + printf("get blueaddress.\n"); return 0; } diff --git a/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_app.c b/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_app.c index c99ceb80a..4762e491c 100755 --- a/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_app.c +++ b/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_app.c @@ -18,166 +18,260 @@ * Description: creat **************************************************************************/ #include -#include "sf_syslib.h" #include "sf_blue_hal.h" #include "sf_blue_app.h" -#include "sf_sm.h" +//#include "sf_sm.h" +#include "UIInfo/UIInfo.h" +#include +#include "sf_system.h" +#include "sf_log.h" +#include "sf_commu_mcu_reg.h" +#include "sf_systemMng.h" +#include +#include //usleep() #define MSG_BLE_PRE_FIX 0x55AA #define MSG_BLE_END_FIX 0xFFEE #define MSG_APP_2_BLE 0 #define MSG_BLE_2_APP 1 +#define SF_HW_TYPE "REVEAL-X3.0" +#define SF_WIFI_AP_PWD_LEN 16 +#define SF_WIFI_AP_SSID_LEN 16 static BLE_APP_PACKET_T gst_msgResult = {0}; -static U32 gmsgResultLen = 0; +static unsigned int gmsgResultLen = 0; +static void sf_clear_poweroff_time(void) +{ + +} +static void sf_set_cam_mode(char mode) +{ + +} + +int sf_set_ble_name(char *name) +{ + UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); + snprintf((char *)puiPara->BluSsid, sizeof(puiPara->BluSsid), "%s", (char *)name); + MLOGI("BluSsid:%s\n", puiPara->BluSsid); +} +static UINT32 sf_set_pir_sensitivity(UINT8 pirs) +{ + UINT8 digPirLevel[10] = {200, 38, 30, 24, 18, 16, 10, 9, 8, 7}; + UINT8 digPirCount[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1}; + + UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); + //UIMenuStoreInfo *puiPara = sf_ui_para_get(); + if(pirs >= 10) + return FAIL; + puiPara->PirSensitivity = pirs; + puiPara->DigitPirSensitivity = digPirLevel[pirs]; + puiPara->DigitPirCnt = digPirCount[pirs]; + puiPara->DigitPirWindowTime = 0; + //#if SF_IS_RELEASE == ENABLE + if(puiPara->PirSensitivity) + { + puiPara->TimelapseSwitch = SF_OFF; + puiPara->TimelapseTime.Hour = 0; + puiPara->TimelapseTime.Min = 0; + puiPara->TimelapseTime.Sec = 0; + //Save_MenuInfo(); + } + //#endif + return SUCCESS; +} +static void sf_camera_name_check(char* str) +{ + SINT16 i = 0; + SINT16 len = 0; + + len = strlen(str); + if(len > 4) + { + str[4] = '\0'; + len = 4; + } + + MLOGI("str:%s,len:%d\n", str, len); + for(i = 0; i < len; i++) + { + if((str[i] >= 'a') && (str[i] <= 'z')) + { + str[i] = toupper(str[i]); + } + else if(((str[i] >= 'A') && (str[i] <= 'Z')) + || ((str[i] >= '1') && (str[i] <= '9')) + || (str[i] == ' ')) + { + //nothing to do + } + else + { + str[i] = ' '; + } + } +} static void *sf_blue_preset_reboot_task(void *arg) { - sleep(2); //delay - sf_sys_reboot(); + //sf_sleep(2); //delay + sf_power_off_msg_to_cardv(); + return NULL; } static void sf_blue_command_get_wifi_info(MSG_DEV_BLE_WIFI_Get_Rsp_T *wifiInfo) { - SF_PDT_PARAM_CFG_S* puiPara = sf_get_sifar_param(); - - LOGI("wifiInfo:%x\n",wifiInfo->cmdRet); + UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); + SLOGI("wifiInfo:%x\n",wifiInfo->cmdRet); printf("[sf_blue_get_wifi_info],sf_get_sifar_param\n"); wifiInfo->cmdRet = 0; - wifiInfo->SSIDlength = strlen(puiPara->WifiApSSID); - strcpy(wifiInfo->SSID, puiPara->WifiApSSID); - printf("[sf_blue_get_wifi_info],len:%d, SSID:%s\n", wifiInfo->SSIDlength, puiPara->WifiApSSID); + wifiInfo->SSIDlength = strlen((const char*)puiPara->strSSID); + snprintf((char *)wifiInfo->SSID, sizeof(wifiInfo->SSID), "%s", (char *)puiPara->strSSID); - wifiInfo->PWDlength = strlen(puiPara->WifiApPWD); - strcpy(wifiInfo->PWD, puiPara->WifiApPWD); - printf("[sf_blue_get_wifi_info],len:%d, PWD:%s\n", wifiInfo->PWDlength, puiPara->WifiApPWD); + SLOGI("len:%d, SSID:%s\n", wifiInfo->SSIDlength, wifiInfo->SSID); + + wifiInfo->PWDlength = strlen((const char*)puiPara->WifiApPWD); + snprintf((char *)wifiInfo->PWD, sizeof(wifiInfo->PWD), "%s", (char *)puiPara->WifiApPWD); + SLOGI("len:%d, PWD:%s\n", wifiInfo->PWDlength, puiPara->WifiApPWD); wifiInfo->suffix = htons(0xFFEE); - printf("[sf_blue_get_wifi_info],End\n"); + SLOGI("end\n"); } static void sf_blue_command_get_camera_para(MSG_DEV_BLE_Param_Get_Rsp_T *CamPara) { - SF_PDT_PARAM_CFG_S* puiPara = sf_get_sifar_param(); + UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); //printf("[sf_app_Get_Camera_Para],snapnum:%d\n",puiPara->snapnum); CamPara->cmdRet = 0; - CamPara->zoom = puiPara->Zoom; + CamPara->zoom = puiPara->Zoom; - if(puiPara->CameraMode == 0) - { - CamPara->cameraMode = 0; - } - else if (puiPara->CameraMode == 2) - { - CamPara->cameraMode = 1; - } - else if (puiPara->CameraMode == 1) - { - CamPara->cameraMode = 2; - } - else - { - CamPara->cameraMode = 0; - } + CamPara->cameraMode = (puiPara->CamMode==2)?1:0; printf("Camera Mode:%d\n", CamPara->cameraMode); //CamPara->cameraMode = puiPara->CameraMode; - if(puiPara->ImgSize == 3) - { - CamPara->imageSize = 0; - } - else if(puiPara->ImgSize == 4) - { - CamPara->imageSize = 1; - } - else if(puiPara->ImgSize == 2) - { - CamPara->imageSize = 2; - } - else - { - CamPara->imageSize = 2; - } - - printf("Image Size:%d\n", CamPara->imageSize); + if(PHOTO_SIZE_16M == puiPara->ImgSize) + { + CamPara->imageSize = 0; + } + else if(PHOTO_SIZE_12M == puiPara->ImgSize) + { + CamPara->imageSize = 1; + } + else if(PHOTO_SIZE_8M == puiPara->ImgSize) + { + CamPara->imageSize = 2; + } + /*else if(PHOTO_SIZE_16M == puiPara->ImgSize) + { + CamPara->imageSize = 3; + } + else if(PHOTO_SIZE_32M == puiPara->ImgSize) + { + CamPara->imageSize = 2; + }*/ + else + { + CamPara->imageSize = 2; + } + MLOGI("Image Size:%d\n", CamPara->imageSize); //CamPara->imageSize = puiPara->ImgSize; - CamPara->multiShot = puiPara->Multishot-1; - CamPara->multiInterval = puiPara->MultishotInterval; - CamPara->sendMulti = puiPara->SendMultishot; + CamPara->multiShot = puiPara->Multishot; + CamPara->multiInterval = puiPara->MultiShotIntevel; + CamPara->sendMulti = puiPara->SendMulti; CamPara->PirSensitivity = puiPara->PirSensitivity; - CamPara->timer = puiPara->TimerFlag[0]; - CamPara->timerStartHour = puiPara->TimerStartH[0]; - CamPara->timerStartMinute = puiPara->TimerStartM[0]; - CamPara->timerEndHour = puiPara->TimerStopH[0]; - CamPara->timerEndMinute = puiPara->TimerStopM[0]; - printf("timer:%d\n", puiPara->TimerFlag[0]); - printf("TimerHstart[0]:%d\n", puiPara->TimerStartH[0]); - printf("TimerMstart[0]:%d\n", puiPara->TimerStartM[0]); - printf("TimerHstop[0]:%d\n", puiPara->TimerStopH[0]); - printf("TimerMstop[0]:%d\n", puiPara->TimerStopM[0]); + CamPara->timer = puiPara->WorkTime1Switch; + CamPara->timerStartHour = puiPara->WorkTime[0].StartTime.Hour; + CamPara->timerStartMinute = puiPara->WorkTime[0].StartTime.Min; + CamPara->timerEndHour = puiPara->WorkTime[0].StopTime.Hour; + CamPara->timerEndMinute = puiPara->WorkTime[0].StopTime.Min; + MLOGI("timer:%d\n", puiPara->WorkTime1Switch); + MLOGI("TimerHstart[0]:%d\n", puiPara->WorkTime[0].StartTime.Hour); + MLOGI("TimerMstart[0]:%d\n", puiPara->WorkTime[0].StartTime.Min); + MLOGI("TimerHstop[0]:%d\n", puiPara->WorkTime[0].StopTime.Hour); + MLOGI("TimerMstop[0]:%d\n", puiPara->WorkTime[0].StopTime.Min); - CamPara->maxNum = puiPara->SendMaxNum; - CamPara->delay = puiPara->DelayFlag; - CamPara->delayHour = puiPara->DelayHour; - CamPara->delayMinute = puiPara->DelayMinute; - CamPara->delaySecond = puiPara->DelaySecond; + CamPara->maxNum = puiPara->SendMaxNum;//MaxNumber + CamPara->delay = puiPara->PirDelaySwitch;//DelayFlag + CamPara->delayHour = puiPara->PirDelayTime.Day; + CamPara->delayMinute = puiPara->PirDelayTime.Min; + CamPara->delaySecond = puiPara->PirDelayTime.Sec; - CamPara->SDLoop = puiPara->SdLoop; + CamPara->SDLoop = puiPara->SdLoopSwitch;//SDLoop CamPara->flashPower = puiPara->FlashLed; - CamPara->nightMode = puiPara->ExposureTime; + CamPara->nightMode = puiPara->NightMode;//ExposureTime - CamPara->sendType = puiPara->SendMode; - CamPara->sendFirstTimeH = puiPara->BatchTimeHour[0]; - CamPara->sendFirstTimeM = puiPara->BatchTimeMinute[0]; - CamPara->sendSecondTimeH = puiPara->BatchTimeHour[1]; - CamPara->sendSecondTimeM = puiPara->BatchTimeMinute[1]; + CamPara->sendType = puiPara->SendType;// + CamPara->sendFirstTimeH = puiPara->TimeSend1.Hour;// + CamPara->sendFirstTimeM = puiPara->TimeSend1.Min;// + CamPara->sendSecondTimeH = puiPara->TimeSend2.Hour;// + CamPara->sendSecondTimeM = puiPara->TimeSend2.Min;// CamPara->SMSCtrl = puiPara->GprsMode; - CamPara->videoSize = puiPara->VideoSize; - CamPara->videoTime = puiPara->VideoLenth-5; + if(MOVIE_SIZE_FRONT_1920x1080P30 == puiPara->VideoSize){ + CamPara->videoSize = 0; + } + else if(MOVIE_SIZE_FRONT_1280x720P30 == puiPara->VideoSize){ + CamPara->videoSize = 1; + } + else if(MOVIE_SIZE_FRONT_848x480P30 == puiPara->VideoSize){ + CamPara->videoSize = 2; + } + else{ + CamPara->videoSize = 1; + } + if(15 == puiPara->VideoLenth) + { + CamPara->videoTime = 10; + } + else if (10 == puiPara->VideoLenth) + { + CamPara->videoTime = 5; + } + CamPara->batType = puiPara->BatteryType; - CamPara->cameraID = puiPara->CameraNameFlag == 0 ? 1:0; - strcpy((char *)CamPara->cameraIDstr, (char *)puiPara->CameraNameStr); + CamPara->cameraID = puiPara->CamNameSwitch == SF_CAMID_OFF ? 0:1; + strcpy((char *)CamPara->cameraIDstr, (char *)puiPara->CamNameStr); CamPara->dateTimeAuto = puiPara->DateAuto; - CamPara->timeZone = puiPara->TimeZone; + CamPara->timeZone = 0; CamPara->gpsSwitch = puiPara->GpsSwitch; - CamPara->gpsSendType = puiPara->GpsSendType; + CamPara->gpsSendType = puiPara->GpsNumber; - CamPara->timelapse = puiPara->TimelapseFlag; - CamPara->timelapseHour = puiPara->TimelapseHour; - CamPara->timelapseMin = puiPara->TimelapseMinute; - CamPara->timelapseSec = puiPara->TimelapseSecond; + CamPara->timelapse = puiPara->TimelapseSwitch;//TimelapseFlag + CamPara->timelapseHour = puiPara->TimelapseTime.Hour;//TimelapseHour + CamPara->timelapseMin = puiPara->TimelapseTime.Min;//TimelapseMinute + CamPara->timelapseSec = puiPara->TimelapseTime.Sec;//TimelapseSecond - CamPara->picUponDailyReport = puiPara->PicUponDailyReport; + CamPara->picUponDailyReport = puiPara->PicUpDailyReport; //!< 蓝牙部分新增内容 - CamPara->SSIDlength = strlen(puiPara->WifiApSSID); - strcpy(CamPara->SSID, puiPara->WifiApSSID); - printf("[sf_blue_get_wifi_info],len:%d, SSID:%s\n", CamPara->SSIDlength, puiPara->WifiApSSID); + CamPara->SSIDlength = strlen((const char*)puiPara->strSSID); + snprintf((char *)CamPara->SSID, sizeof(CamPara->SSID), "%s", (char *)puiPara->strSSID); + SLOGI("len:%d, SSID:%s\n", CamPara->SSIDlength, CamPara->SSID); + + CamPara->PWDlength = strlen((const char*)puiPara->WifiApPWD); + snprintf((char *)CamPara->PWD, sizeof(CamPara->PWD), "%s", (char *)puiPara->WifiApPWD); + SLOGI("len:%d, PWD:%s\n", CamPara->PWDlength, puiPara->WifiApPWD); - CamPara->PWDlength = strlen(puiPara->WifiApPWD); - strcpy(CamPara->PWD, puiPara->WifiApPWD); - printf("[sf_blue_get_wifi_info],len:%d, PWD:%s\n", CamPara->PWDlength, puiPara->WifiApPWD); strcpy((char *)CamPara->hwType, SF_HW_TYPE); CamPara->suffix = htons(MSG_BLE_END_FIX); } -static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U32 *out_len) +static signed int sf_blue_command_request_process(U8 *val, unsigned int nval, U8 **out_data, unsigned int *out_len) { SINT8 respFlag = -1; /*0:no response 1:prive response 2:global response 3:reboot*/ UINT8 paramSaveFlag = 0; @@ -185,10 +279,10 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 UINT8 SendingFile = 0; UINT16 tmp = 0; - SF_PDT_PARAM_CFG_S* puiPara = sf_get_sifar_param(); + UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); BLE_APP_PACKET_T msgParse; BLE_APP_PACKET_T *pMsgStruct = NULL; - + SF_PARA_TIME_S time; UINT8 *bufAddr = val; UINT32 offset; UINT16 PreFind=0; @@ -238,7 +332,7 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 { sf_clear_poweroff_time();/*reset power off count time*/ - LOGI("BLE Req cmd=%x.\n", msgParse.cmd); + SLOGI("BLE Req cmd=%x.\n", msgParse.cmd); switch(msgParse.cmd) { case BLE_GET_CAMERA_CONNECT: //OK @@ -258,7 +352,7 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 break; case BLE_GET_CAMERA_WIFI_INFO: //o { - LOGI("[BLE_GET_CAMERA_WIFI_INFO],msgParse.msgBuf.rgetWifiInfo:%x\n",msgParse.msgBuf.rgetWifiInfo.cmdRet); + SLOGI("[BLE_GET_CAMERA_WIFI_INFO],msgParse.msgBuf.rgetWifiInfo:%x\n",msgParse.msgBuf.rgetWifiInfo.cmdRet); sf_blue_command_get_wifi_info(&msgParse.msgBuf.rgetWifiInfo); msgParse.msglen = htons(sizeof(MSG_DEV_BLE_WIFI_Get_Rsp_T) + 2*sizeof(UINT16) ); respFlag = 1; @@ -267,7 +361,7 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_GET_CAMERA_PARAM: //o { - LOGI("[BLE_GET_CAMERA_PARAM]\n"); + SLOGI("[BLE_GET_CAMERA_PARAM]\n"); sf_blue_command_get_camera_para(&msgParse.msgBuf.rgetDevParam); /* add the cmd + resp total 2*2 bytes */ msgParse.msglen = htons(sizeof(MSG_DEV_BLE_Param_Get_Rsp_T) + 2*sizeof(UINT16) ); @@ -277,13 +371,13 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_WIFI_PWD: // { - LOGI("[BLE_SET_WIFI_PWD],newpwd:%s\n",pMsgStruct->msgBuf.wifiPwdSet.PWD); + SLOGI("[BLE_SET_WIFI_PWD],newpwd:%s\n",pMsgStruct->msgBuf.wifiPwdSet.PWD); int len = pMsgStruct->msgBuf.wifiPwdSet.PWDlength; if (len >= SF_WIFI_AP_PWD_LEN) { len = SF_WIFI_AP_PWD_LEN - 1; } - strcpy(puiPara->WifiApPWD, pMsgStruct->msgBuf.wifiPwdSet.PWD); + snprintf((char *)puiPara->WifiApPWD, sizeof(puiPara->WifiApPWD), "%s", (char *)pMsgStruct->msgBuf.wifiPwdSet.PWD); //snprintf(puiPara->WifiApPWD, len, "%s", pMsgStruct->msgBuf.wifiPwdSet.PWD); respFlag = 2; paramSaveFlag = 1; @@ -291,14 +385,14 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 break; case BLE_SET_CAMERA_WIFI_SSID: // { - LOGI("[BLE_SET_WIFI_SSID],newssid:%s\n",pMsgStruct->msgBuf.wifiSSIDSet.SSID); + SLOGI("[BLE_SET_WIFI_SSID],newssid:%s\n",pMsgStruct->msgBuf.wifiSSIDSet.SSID); int len = pMsgStruct->msgBuf.wifiSSIDSet.SSIDlength; if (len >= SF_WIFI_AP_SSID_LEN) { len = SF_WIFI_AP_SSID_LEN - 1; } - strcpy(puiPara->WifiApSSID, pMsgStruct->msgBuf.wifiSSIDSet.SSID); + snprintf((char *)puiPara->strSSID, sizeof(puiPara->strSSID), "%s", (char *)pMsgStruct->msgBuf.wifiSSIDSet.SSID); //snprintf(puiPara->WifiApSSID, len, "%s", pMsgStruct->msgBuf.wifiSSIDSet.SSID); respFlag = 2; paramSaveFlag = 1; @@ -307,7 +401,7 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_Zoom: // { - LOGI("[BLE_SET_CAMERA_Zoom],Zoom:%d\n",puiPara->Zoom); + SLOGI("[BLE_SET_CAMERA_Zoom],Zoom:%d\n",puiPara->Zoom); puiPara->Zoom = pMsgStruct->msgBuf.deviceZoomSet.zoom; puiPara->Zoom = (puiPara->Zoom > 4 ? 1 : puiPara->Zoom); @@ -316,7 +410,8 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 //printf("mode = 0x%x, zoom = %d,\n", curMode, puiPara->Zoom); //printf(" factor = %d\n", zmFactor[puiPara->Zoom]); //forbuild sp5kZoomFactorSet(curMode, zmFactor[puiPara.zoom]); - sf_set_zoom(puiPara->Zoom); + + //sf_set_zoom(puiPara->Zoom); respFlag = 2; paramSaveFlag = 0; } @@ -326,7 +421,7 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 { U8 saveMode, tmpMode; - saveMode = sf_get_camera_mode(); + saveMode = puiPara->CamMode; if(saveMode == 0) { saveMode = 0; @@ -340,7 +435,7 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 saveMode = 1; } - LOGI("[BLE_SET_CAMERA_CameraMode],cameraMode:%d,savemode:%d\n",pMsgStruct->msgBuf.setCameraMode.cameraMode,saveMode); + SLOGI("[BLE_SET_CAMERA_CameraMode],cameraMode:%d,savemode:%d\n",pMsgStruct->msgBuf.setCameraMode.cameraMode,saveMode); if(saveMode != pMsgStruct->msgBuf.setCameraMode.cameraMode) { @@ -348,22 +443,22 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 if(tmpMode == 0) { - puiPara->CameraMode = SF_CAMMODE_PIC; + puiPara->CamMode = SF_CAM_MODE_PHOTO; } else if (tmpMode == 1) { - puiPara->CameraMode = SF_CAMMODE_PV; + puiPara->CamMode = SF_CAM_MODE_PHOTO_VIDEO; } else if (tmpMode == 2) { - puiPara->CameraMode = SF_CAMMODE_VIDEO; + puiPara->CamMode = SF_CAM_MODE_VIDEO; } else { - puiPara->CameraMode = SF_CAMMODE_PIC; + puiPara->CamMode = SF_CAM_MODE_PHOTO; } - sf_set_cam_mode(puiPara->CameraMode); + sf_set_cam_mode(puiPara->CamMode); respFlag = 2; paramSaveFlag = 1; } @@ -377,34 +472,36 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_ImageSize: //O { U8 tmpValue; - LOGI("[BLE_SET_CAMERA_ImageSize],ImgSize:%d\n",puiPara->ImgSize); + SLOGI("[BLE_SET_CAMERA_ImageSize],ImgSize:%d\n",puiPara->ImgSize); tmpValue = pMsgStruct->msgBuf.setImageSize.imageSize; if(tmpValue == 0) { - puiPara->ImgSize = SF_IMG_SIZE_24M; + puiPara->ImgSize = PHOTO_SIZE_16M; } else if(tmpValue == 1) { - puiPara->ImgSize = SF_IMG_SIZE_12M; + puiPara->ImgSize = PHOTO_SIZE_12M; } else if(tmpValue == 2) { - puiPara->ImgSize = SF_IMG_SIZE_8M; + puiPara->ImgSize = PHOTO_SIZE_8M; } + /* else if(tmpValue == 3) { - puiPara->ImgSize = SF_IMG_SIZE_16M; + puiPara->ImgSize = PHOTO_SIZE_16M; } else if(tmpValue == 2) { - puiPara->ImgSize = SF_IMG_SIZE_32M; - } + puiPara->ImgSize = PHOTO_SIZE_32M; + }*/ else { - puiPara->ImgSize = SF_IMG_SIZE_8M; + puiPara->ImgSize = PHOTO_SIZE_8M; } - sf_set_img_size(puiPara->ImgSize); + sf_sys_set_flag(FL_PHOTO_SIZE, puiPara->ImgSize); + //sf_set_img_size(puiPara->ImgSize); respFlag = 2; paramSaveFlag = 1; @@ -413,13 +510,39 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_MultiShot: //O { - LOGI("Multishot:%d\nMultishotInterval:%d\n,SendMultishot:%d\n", pMsgStruct->msgBuf.setMultiShot.multiShot, + SLOGI("Multishot:%d\nMultishotInterval:%d\n,SendMultishot:%d\n", pMsgStruct->msgBuf.setMultiShot.multiShot, pMsgStruct->msgBuf.setMultiShot.multiInterval, pMsgStruct->msgBuf.setMultiShot.sendMulti); puiPara->Multishot = pMsgStruct->msgBuf.setMultiShot.multiShot % 3+1; - puiPara->MultishotInterval = pMsgStruct->msgBuf.setMultiShot.multiInterval % 3; - puiPara->SendMultishot = pMsgStruct->msgBuf.setMultiShot.sendMulti % 2; - sf_set_cam_mode(puiPara->CameraMode); + puiPara->MultiShotIntevel = pMsgStruct->msgBuf.setMultiShot.multiInterval % 3; + puiPara->SendMulti = pMsgStruct->msgBuf.setMultiShot.sendMulti % 2; + if(puiPara->SendMulti == 0) + { + puiPara->SendMultishotIndex2 = 0; + puiPara->SendMultishotIndex3 = 0; + }else + { + if(puiPara->Multishot == 0) + { + puiPara->SendMultishotIndex2 = 0; + puiPara->SendMultishotIndex3 = 0; + } + else if(puiPara->Multishot == 1) + { + puiPara->SendMultishotIndex2 = 1; + puiPara->SendMultishotIndex3 = 0; + } + else + { + puiPara->SendMultishotIndex2 = 1; + puiPara->SendMultishotIndex3 = 1; + } + } + if(puiPara->Multishot != sf_sys_get_flag(FL_CONTINUE_SHOT)) + { + sf_sys_set_flag(FL_CONTINUE_SHOT, puiPara->Multishot); + } + sf_set_cam_mode(puiPara->CamMode); respFlag = 2; paramSaveFlag = 1; } @@ -427,18 +550,8 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_PirSensitivity: //O { - LOGI("[BLE_SET_CAMERA_PirSensitivity],DigitPirSensitivity:%d\n",pMsgStruct->msgBuf.setPirSensitivity.PirSensitivity); - - puiPara->PirSensitivity = pMsgStruct->msgBuf.setPirSensitivity.PirSensitivity % 10; - if(puiPara->PirSensitivity) - { - puiPara->TimelapseFlag = 0; - puiPara->PirSwitch = 1; - } - else - { - puiPara->PirSwitch = 0; - } + SLOGI("[BLE_SET_CAMERA_PirSensitivity],DigitPirSensitivity:%d\n",pMsgStruct->msgBuf.setPirSensitivity.PirSensitivity); + sf_set_pir_sensitivity(pMsgStruct->msgBuf.setPirSensitivity.PirSensitivity % 10); respFlag = 2; paramSaveFlag = 1; } @@ -446,17 +559,17 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_Timer: //O { - LOGI("[BLE_SET_CAMERA_Timer],timer:%d\n",pMsgStruct->msgBuf.setTimer.timer); - puiPara->TimerFlag[0] = !!pMsgStruct->msgBuf.setTimer.timer; - puiPara->TimerStartH[0] = pMsgStruct->msgBuf.setTimer.timerStartHour % 24; - puiPara->TimerStartM[0] = pMsgStruct->msgBuf.setTimer.timerStartMinute % 60; - puiPara->TimerStopH[0] = pMsgStruct->msgBuf.setTimer.timerEndHour % 24; - puiPara->TimerStopM[0] = pMsgStruct->msgBuf.setTimer.timerEndMinute % 60; - printf("timer:%d\n", puiPara->TimerFlag[0]); - printf("TimerHstart[0]:%d\n", puiPara->TimerStartH[0]); - printf("TimerMstart[0]:%d\n", puiPara->TimerStartM[0]); - printf("TimerHstop[0]:%d\n", puiPara->TimerStopH[0]); - printf("TimerMstop[0]:%d\n", puiPara->TimerStopM[0]); + SLOGI("[BLE_SET_CAMERA_Timer],timer:%d\n",pMsgStruct->msgBuf.setTimer.timer); + puiPara->WorkTime1Switch = !!pMsgStruct->msgBuf.setTimer.timer; + puiPara->WorkTime[0].StartTime.Hour = pMsgStruct->msgBuf.setTimer.timerStartHour % 24; + puiPara->WorkTime[0].StartTime.Min = pMsgStruct->msgBuf.setTimer.timerStartMinute % 60; + puiPara->WorkTime[0].StopTime.Hour = pMsgStruct->msgBuf.setTimer.timerEndHour % 24; + puiPara->WorkTime[0].StopTime.Min = pMsgStruct->msgBuf.setTimer.timerEndMinute % 60; + printf("timer:%d\n", puiPara->WorkTime1Switch); + printf("TimerHstart[0]:%d\n", puiPara->WorkTime[0].StartTime.Hour); + printf("TimerMstart[0]:%d\n", puiPara->WorkTime[0].StartTime.Min); + printf("TimerHstop[0]:%d\n", puiPara->WorkTime[0].StopTime.Hour); + printf("TimerMstop[0]:%d\n", puiPara->WorkTime[0].StopTime.Min); respFlag = 2; paramSaveFlag = 1; } @@ -464,7 +577,7 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_MaxNum: //O { - LOGI("[BLE_SET_CAMERA_MaxNum],SendMaxNum:%d\n",pMsgStruct->msgBuf.setMaxNum.maxNum); + SLOGI("[BLE_SET_CAMERA_MaxNum],SendMaxNum:%d\n",pMsgStruct->msgBuf.setMaxNum.maxNum); puiPara->SendMaxNum = pMsgStruct->msgBuf.setMaxNum.maxNum % 100; respFlag = 2; paramSaveFlag = 1; @@ -473,11 +586,11 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_Delay: //O { - LOGI("[BLE_SET_CAMERA_Delay],delay:%d\n",pMsgStruct->msgBuf.setDelay.delay); - puiPara->DelayFlag = !!pMsgStruct->msgBuf.setDelay.delay; - puiPara->DelayHour = pMsgStruct->msgBuf.setDelay.delayHour % 24; - puiPara->DelayMinute = pMsgStruct->msgBuf.setDelay.delayMinute % 60; - puiPara->DelaySecond = pMsgStruct->msgBuf.setDelay.delaySecond % 60; + SLOGI("[BLE_SET_CAMERA_Delay],delay:%d\n",pMsgStruct->msgBuf.setDelay.delay); + puiPara->PirDelaySwitch = !!pMsgStruct->msgBuf.setDelay.delay; + puiPara->PirDelayTime.Hour = pMsgStruct->msgBuf.setDelay.delayHour % 24; + puiPara->PirDelayTime.Min = pMsgStruct->msgBuf.setDelay.delayMinute % 60; + puiPara->PirDelayTime.Sec = pMsgStruct->msgBuf.setDelay.delaySecond % 60; respFlag = 2; paramSaveFlag = 1; } @@ -485,8 +598,8 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_SDLoop: //O { - LOGI("[BLE_SET_CAMERA_SDLoop],SDLoop:%d\n",pMsgStruct->msgBuf.setSDLoop.SDLoop); - puiPara->SdLoop = !!pMsgStruct->msgBuf.setSDLoop.SDLoop; + SLOGI("[BLE_SET_CAMERA_SDLoop],SDLoop:%d\n",pMsgStruct->msgBuf.setSDLoop.SDLoop); + puiPara->SdLoopSwitch = !!pMsgStruct->msgBuf.setSDLoop.SDLoop; respFlag = 2; paramSaveFlag = 1; } @@ -494,7 +607,7 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_FlashPower: //O { - LOGI("[BLE_SET_CAMERA_FlashPower],flashPower:%d\n",pMsgStruct->msgBuf.setFlashPower.flashPower); + SLOGI("[BLE_SET_CAMERA_FlashPower],flashPower:%d\n",pMsgStruct->msgBuf.setFlashPower.flashPower); puiPara->FlashLed = !!pMsgStruct->msgBuf.setFlashPower.flashPower; respFlag = 2; paramSaveFlag = 1; @@ -503,9 +616,8 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_NightMode: //O { - LOGI("[BLE_SET_CAMERA_NightMode],nightMode:%d\n",pMsgStruct->msgBuf.setNightMode.nightMode); - puiPara->ExposureTime = pMsgStruct->msgBuf.setNightMode.nightMode % 3; - sf_set_img_size(puiPara->ImgSize); + SLOGI("[BLE_SET_CAMERA_NightMode],nightMode:%d\n",pMsgStruct->msgBuf.setNightMode.nightMode); + puiPara->NightMode = pMsgStruct->msgBuf.setNightMode.nightMode % 3; respFlag = 2; paramSaveFlag = 1; } @@ -513,12 +625,37 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_SendType: //O { - LOGI("[BLE_SET_CAMERA_SendType],sendType:%d\n",pMsgStruct->msgBuf.setSendType.sendType); - puiPara->SendMode = pMsgStruct->msgBuf.setSendType.sendType; - puiPara->BatchTimeHour[0] = pMsgStruct->msgBuf.setSendType.sendFirstTimeH; - puiPara->BatchTimeMinute[0] = pMsgStruct->msgBuf.setSendType.sendFirstTimeM; - puiPara->BatchTimeHour[1] = pMsgStruct->msgBuf.setSendType.sendSecondTimeH; - puiPara->BatchTimeMinute[1] = pMsgStruct->msgBuf.setSendType.sendSecondTimeM; + SLOGI("[BLE_SET_CAMERA_SendType],sendType:%d\n",pMsgStruct->msgBuf.setSendType.sendType); + if(puiPara->GprsMode == 0) + { + puiPara->SendType = pMsgStruct->msgBuf.setSendType.sendType % 3; + puiPara->TimeSend1.Hour = pMsgStruct->msgBuf.setSendType.sendFirstTimeH % 24; + puiPara->TimeSend1.Min = pMsgStruct->msgBuf.setSendType.sendFirstTimeM % 60; + puiPara->TimeSend2.Hour = pMsgStruct->msgBuf.setSendType.sendSecondTimeH % 24; + puiPara->TimeSend2.Min = pMsgStruct->msgBuf.setSendType.sendSecondTimeM % 60; + + if(puiPara->SendType == 0) + { + puiPara->TimeSend1Switch = 0; + puiPara->TimeSend2Switch = 0; + //puiPara->TimeSend3 = 0; + //puiPara->TimeSend4 = 0; + } + else if(puiPara->SendType == 1) + { + puiPara->TimeSend1Switch = 1; + puiPara->TimeSend2Switch = 0; + //puiPara->TimeSend3 = 0; + //puiPara->TimeSend4 = 0; + } + else // if(puiPara->SendType == 2) + { + puiPara->TimeSend1Switch = 1; + puiPara->TimeSend2Switch = 1; + } + MLOGI("SendType:%d TimeSend1Switch:%d %02d:%02d TimeSend2Switch:%d %02d:%02d\n",puiPara->SendType,puiPara->TimeSend1Switch,puiPara->TimeSend1.Hour,puiPara->TimeSend1.Min,puiPara->TimeSend2Switch, puiPara->TimeSend2.Hour,puiPara->TimeSend2.Min); + + } respFlag = 2; paramSaveFlag = 1; } @@ -526,12 +663,21 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_SMSCtrl: //O { + SLOGI("[BLE_SET_CAMERA_SMSCtrl],SMSCtrl:%d\n",pMsgStruct->msgBuf.setSMSCtrl.SMSCtrl); puiPara->GprsMode = pMsgStruct->msgBuf.setSMSCtrl.SMSCtrl; - LOGI("[BLE_SET_CAMERA_SMSCtrl],SMSCtrl:%d\n",pMsgStruct->msgBuf.setSMSCtrl.SMSCtrl); - if(puiPara->GprsMode == 1) + + if((puiPara->GprsMode == 1) || (puiPara->GprsMode == 2)) { - puiPara->SendMode = 0; - LOGD("Modify the Send mode to 0\n"); + puiPara->SendType = 0; + puiPara->TimeSend1Switch = 0; + puiPara->TimeSend2Switch = 0; + if((puiPara->GprsMode == 1) && (puiPara->PirDelaySwitch == SF_OFF)) + { + puiPara->PirDelaySwitch = SF_ON; + puiPara->PirDelayTime.Hour = 0; + puiPara->PirDelayTime.Min = 0; + puiPara->PirDelayTime.Sec = 15; + } } respFlag = 2; paramSaveFlag = 1; @@ -540,11 +686,22 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_VideoSize://err { - LOGI("[BLE_SET_CAMERA_VideoSize],videoSize:%d\n",pMsgStruct->msgBuf.setVideoSize.videoSize); - puiPara->VideoSize = pMsgStruct->msgBuf.setVideoSize.videoSize; - puiPara->VideoSize = (puiPara->VideoSize > 2 ? 0 : puiPara->VideoSize); - //forbuild appMediaAttrUpdate(puiPara.VideoSize); - sf_set_video_size(puiPara->VideoSize); + SLOGI("[BLE_SET_CAMERA_VideoSize],videoSize:%d\n",pMsgStruct->msgBuf.setVideoSize.videoSize); + puiPara->VideoSize = pMsgStruct->msgBuf.setVideoSize.videoSize % 3; + if(0 == pMsgStruct->msgBuf.setVideoSize.videoSize % 3){ + puiPara->VideoSize = MOVIE_SIZE_FRONT_1920x1080P30; + }else if(1 == pMsgStruct->msgBuf.setVideoSize.videoSize % 3){ + puiPara->VideoSize = MOVIE_SIZE_FRONT_1280x720P30; + }else if(2 == pMsgStruct->msgBuf.setVideoSize.videoSize % 3){ + puiPara->VideoSize = MOVIE_SIZE_FRONT_848x480P30; + }else{ + puiPara->VideoSize = MOVIE_SIZE_FRONT_1280x720P30; + } + if(puiPara->VideoSize != sf_sys_get_flag(FL_MOVIE_SIZE)) + { + sf_sys_set_flag(FL_MOVIE_SIZE, puiPara->VideoSize); + sf_sys_set_flag(FL_MOVIE_SIZE_MENU, puiPara->VideoSize); + } respFlag = 2; paramSaveFlag = 1; } @@ -552,8 +709,15 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_VideoTime: //O { - LOGI("[BLE_SET_CAMERA_VideoTime],videoTime:%d\n",pMsgStruct->msgBuf.setVideoTime.videoTime); - puiPara->VideoLenth = pMsgStruct->msgBuf.setVideoTime.videoTime+5; + SLOGI("[BLE_SET_CAMERA_VideoTime],videoTime:%d\n",pMsgStruct->msgBuf.setVideoTime.videoTime); + if(10 == pMsgStruct->msgBuf.setVideoTime.videoTime) + { + puiPara->VideoLenth = 15; + } + else if (5 == pMsgStruct->msgBuf.setVideoTime.videoTime) + { + puiPara->VideoLenth = 10; + } //puiPara->VideoLenth = (puiPara->VideoLenth > 55 ? 0 : puiPara->VideoLenth); respFlag = 2; paramSaveFlag = 1; @@ -562,7 +726,7 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_BatteryType: //O { - LOGI("[BLE_SET_CAMERA_BatteryType],batType:%d\n",pMsgStruct->msgBuf.setBatType.batType); + SLOGI("[BLE_SET_CAMERA_BatteryType],batType:%d\n",pMsgStruct->msgBuf.setBatType.batType); puiPara->BatteryType = pMsgStruct->msgBuf.setBatType.batType; puiPara->BatteryType = (puiPara->BatteryType > 3 ? 0 : puiPara->BatteryType); respFlag = 2; @@ -572,17 +736,12 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_CameraID: //O { - LOGI("[BLE_SET_CAMERA_CameraID],cameraID:%d\n",pMsgStruct->msgBuf.setCameraID.cameraID); - puiPara->CameraNameFlag = !pMsgStruct->msgBuf.setCameraID.cameraID; - strncpy((char *)puiPara->CameraNameStr, (char *)pMsgStruct->msgBuf.setCameraID.cameraIDstr, 4); - sf_camera_name_check(puiPara->CameraNameStr); - puiPara->CameraNameStr[4] = '\0'; - - // update the memory for other process. - SF_SM_S sf_sm_t; - sf_sm_t.CameraNameFlag = puiPara->CameraNameFlag; - strcpy(sf_sm_t.CameraNameStr, puiPara->CameraNameStr); - sf_sm_wirte(&sf_sm_t); + 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; + 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); + puiPara->CamNameStr[4] = '\0'; + MLOGI("Camid:%d,str:%s\n", puiPara->CamNameSwitch, puiPara->CamNameStr); respFlag = 2; paramSaveFlag = 1; } @@ -590,28 +749,30 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_DateTime: //O { - LOGI("[BLE_SET_CAMERA_DateTime],DateAuto:%d\n",pMsgStruct->msgBuf.setDateTime.dateTimeAuto); - puiPara->DateAuto = pMsgStruct->msgBuf.setDateTime.dateTimeAuto; - puiPara->TimeZone = pMsgStruct->msgBuf.setDateTime.timeZone; - SF_RTC_t time; - time.year = htons(pMsgStruct->msgBuf.setDateTime.year); - time.mon = pMsgStruct->msgBuf.setDateTime.month; - time.day = pMsgStruct->msgBuf.setDateTime.day; - time.hour = pMsgStruct->msgBuf.setDateTime.hour; - time.min = pMsgStruct->msgBuf.setDateTime.minute; - time.sec = pMsgStruct->msgBuf.setDateTime.second; - //sf_set_rtc_time(&time); - sf_set_systime(&time); - sf_set_sync_mcutime_flag(1); + SLOGI("[BLE_SET_CAMERA_DateTime],DateAuto:%d\n",pMsgStruct->msgBuf.setDateTime.dateTimeAuto); + puiPara->DateAuto = !pMsgStruct->msgBuf.setDateTime.dateTimeAuto; //NTPAuto 0: Auto , 1: Manual + //puiPara->NTPZone = pMsgStruct->msgBuf.setDateTime.timeZone % 7; + time.Year = htons(pMsgStruct->msgBuf.setDateTime.year); + time.Mon = pMsgStruct->msgBuf.setDateTime.month % 13; + time.Day = pMsgStruct->msgBuf.setDateTime.day % 32; + time.Hour = pMsgStruct->msgBuf.setDateTime.hour % 24; + time.Min = pMsgStruct->msgBuf.setDateTime.minute % 60; + time.Sec = pMsgStruct->msgBuf.setDateTime.second % 60; + if(puiPara->DateAuto == 1) //1: Manual + { + MLOGI("Set RTC %d %d %d %d:%d%d\n", time.Year, time.Mon, time.Day, time.Hour, time.Min, time.Sec); + sf_sys_rtc_time_set(&time); + sf_set_mcu_rtc_flag(1); + } respFlag = 2; } break; case BLE_SET_CAMERA_GPS: //o { - LOGI("[BLE_SET_CAMERA_GPS],gpsSendType:%d\n",pMsgStruct->msgBuf.setGPS.gpsSendType); + SLOGI("[BLE_SET_CAMERA_GPS],gpsSendType:%d\n",pMsgStruct->msgBuf.setGPS.gpsSendType); puiPara->GpsSwitch = pMsgStruct->msgBuf.setGPS.gpsSwitch; - puiPara->GpsSendType = pMsgStruct->msgBuf.setGPS.gpsSendType; + //puiPara->GpsSendType = pMsgStruct->msgBuf.setGPS.gpsSendType; respFlag = 2; paramSaveFlag = 1; } @@ -619,11 +780,15 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_timeLapse: //O { - LOGI("[BLE_SET_CAMERA_timeLapse],timelapse:%d\n",pMsgStruct->msgBuf.setTimeLapseTime.timelapse); - puiPara->TimelapseFlag = pMsgStruct->msgBuf.setTimeLapseTime.timelapse; - puiPara->TimelapseHour = pMsgStruct->msgBuf.setTimeLapseTime.timelapseHour; - puiPara->TimelapseMinute = pMsgStruct->msgBuf.setTimeLapseTime.timelapseMin; - puiPara->TimelapseSecond = pMsgStruct->msgBuf.setTimeLapseTime.timelapseSec; + SLOGI("[BLE_SET_CAMERA_timeLapse],timelapse:%d\n",pMsgStruct->msgBuf.setTimeLapseTime.timelapse); + puiPara->TimelapseSwitch = pMsgStruct->msgBuf.setTimeLapseTime.timelapse % 2; + puiPara->TimelapseTime.Hour = pMsgStruct->msgBuf.setTimeLapseTime.timelapseHour % 24; + puiPara->TimelapseTime.Min = pMsgStruct->msgBuf.setTimeLapseTime.timelapseMin % 60; + puiPara->TimelapseTime.Sec = pMsgStruct->msgBuf.setTimeLapseTime.timelapseSec % 60; + if(puiPara->TimelapseSwitch) + { + sf_set_pir_sensitivity(0); + } respFlag = 2; paramSaveFlag = 1; } @@ -631,8 +796,8 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 case BLE_SET_CAMERA_PicUponDailyReport: //O { - LOGI("[BLE_SET_CAMERA_PicUponDailyReport],picUponDailyReport:%d\n",pMsgStruct->msgBuf.setDailyReport.picUponDailyReport); - puiPara->PicUponDailyReport = pMsgStruct->msgBuf.setDailyReport.picUponDailyReport; + SLOGI("[BLE_SET_CAMERA_PicUponDailyReport],picUponDailyReport:%d\n",pMsgStruct->msgBuf.setDailyReport.picUponDailyReport); + puiPara->PicUpDailyReport = pMsgStruct->msgBuf.setDailyReport.picUponDailyReport; respFlag = 2; paramSaveFlag = 1; } @@ -658,8 +823,8 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 { if(paramSaveFlag) { - sf_set_param_save_flag(); - sf_param_save_flash(); + //sf_set_param_save_flag(); + //sf_param_save_flash(); } if(respFlag == 2) @@ -705,6 +870,7 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 pthread_detach(task_pid); } } + return 0; } /************************************************* @@ -718,15 +884,15 @@ static void sf_blue_command_request_process(U8 *val, U32 nval, U8 **out_data, U3 -1, failure Others: N/A *************************************************/ -static int sf_blue_read_callback(U8 **val, S32 *nval) +static int sf_blue_read_callback(U8 **val, unsigned int *nval) { if (NULL == val) { - return; + return -1; } U8 *p = NULL; - S32 len = gmsgResultLen; + unsigned int len = gmsgResultLen; if (len > 0) { p = (U8 *)malloc(len); @@ -751,7 +917,7 @@ static int sf_blue_read_callback(U8 **val, S32 *nval) *nval = len; printf("blue read len:%d.\n", len); - for (S32 i = 0; i < len; i++) + for (unsigned int i = 0; i < len; i++) { printf("0x%02x ", p[i]); if ((i+1)%16 == 0) @@ -759,6 +925,7 @@ static int sf_blue_read_callback(U8 **val, S32 *nval) } printf("\n"); } + return 0; } /************************************************* @@ -773,10 +940,10 @@ static int sf_blue_read_callback(U8 **val, S32 *nval) -1, failure Others: N/A *************************************************/ -static int sf_blue_write_callback(U8 *val, S32 nval, U8 **rval, S32 *rnval) +static int sf_blue_write_callback(U8 *val, unsigned int nval, U8 **rval, unsigned int *rnval) { U8 *out = NULL; - S32 out_len = 0; + unsigned int out_len = 0; if (NULL == val) { @@ -784,13 +951,13 @@ static int sf_blue_write_callback(U8 *val, S32 nval, U8 **rval, S32 *rnval) } printf("write, nval:%d.\n", nval); - for (S32 i = 0; i < nval; i++) + for (unsigned int i = 0; i < nval; i++) printf("%02x ", val[i]); printf("\n"); if (nval < 11) { - SF_BLUE_LOGE("len err.\n"); + SLOGE("len err.\n"); return -1; } @@ -818,7 +985,7 @@ static int sf_blue_write_callback(U8 *val, S32 nval, U8 **rval, S32 *rnval) Return: SF_SUCCESS or SF_FAILURE Others: N/A *************************************************/ -S32 sf_blue_app_start(void) + unsigned int sf_blue_app_start(void) { sf_blue_hal_init(sf_blue_read_callback, sf_blue_write_callback); return SF_SUCCESS; @@ -832,7 +999,7 @@ S32 sf_blue_app_start(void) Return: SF_SUCCESS or SF_FAILURE Others: N/A *************************************************/ -S32 sf_blue_app_stop(void) + unsigned int sf_blue_app_stop(void) { return SF_SUCCESS; } diff --git a/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_app.h b/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_app.h index 578af6fd8..092d968c5 100755 --- a/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_app.h +++ b/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_app.h @@ -474,9 +474,9 @@ typedef struct BLE_APP_MSG_T msgBuf; } __attribute__((packed)) BLE_APP_PACKET_T; -S32 sf_blue_app_start(void); -S32 sf_blue_app_stop(void); - + unsigned int sf_blue_app_start(void); + unsigned int sf_blue_app_stop(void); +int sf_set_ble_name(char *name); #ifdef __cplusplus } #endif diff --git a/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_hal.c b/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_hal.c index f09501774..6523d43d2 100755 --- a/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_hal.c +++ b/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_hal.c @@ -20,9 +20,18 @@ #include #include #include -#include "sf_syslib.h" #include "sf_blue_hal.h" +#include "UIInfo/UIInfo.h" +#include +#include "sf_system.h" +#include "sf_log.h" +#include "sf_commu_mcu_reg.h" +#include "sf_systemMng.h" +#include +#include +#include "sf_blue_app.h" +extern int hciconfig_get_address(char *ssid); extern int hciconfig_set_name(char *name); extern int hciconfig_open_piscan(void); extern int gatt_service_register(BLE_RD rcb, BLE_WR wcb); @@ -33,6 +42,8 @@ static pthread_t gblue_disconnect_pid; static BLE_RD gst_ble_rcb = NULL; static BLE_WR gst_ble_wcb = NULL; +static char g_ble_ssid[14] = {0}; + /************************************************* Function: sf_bluetooth_disconnect_task Description: Bluetooth disconnection detection thread @@ -48,12 +59,13 @@ static void *sf_bluetooth_disconnect_task(void *arg) if (access("/tmp/blue_disconnect", F_OK) == 0) { remove("/tmp/blue_disconnect"); - SF_BLUE_LOGI("reset piscan.\n"); + SLOGI("reset piscan.\n"); hciconfig_open_piscan(); } usleep(500*1000); } + return NULL; } /************************************************* @@ -66,9 +78,39 @@ static void *sf_bluetooth_disconnect_task(void *arg) *************************************************/ static void sf_bluetooth_power_enable(void) { - system("echo 44 > /sys/class/gpio/export"); - system("echo out > /sys/class/gpio/gpio44/direction"); - system("echo 1 > /sys/class/gpio/gpio44/value"); + // system("echo 44 > /sys/class/gpio/export"); + // system("echo out > /sys/class/gpio/gpio44/direction"); + // system("echo 1 > /sys/class/gpio/gpio44/value"); +} + +int sf_getb_mac(char *ifName, UINT8 *pbMacAddr) +{ + struct ifreq ifreq; + int sock = 0; + int i = 0; + + sock = socket(AF_BLUETOOTH, SOCK_STREAM, 0); + if(sock < 0) + { + MLOGE("error sock"); + return 2; + } + + strcpy(ifreq.ifr_name, ifName); + if(ioctl(sock,SIOCGIFHWADDR,&ifreq) < 0) + { + MLOGE("error ioctl"); + return 3; + } + + for(i = 0; i < 6; i++) + { + pbMacAddr[i]=(unsigned char)ifreq.ifr_hwaddr.sa_data[i]; + } + + MLOGI("MAC: %02X-%02X-%02X-%02X-%02X-%02X\n", pbMacAddr[0],pbMacAddr[1],pbMacAddr[2],pbMacAddr[3],pbMacAddr[4],pbMacAddr[5]); + + return 0; } /************************************************* @@ -89,22 +131,39 @@ static void sf_bluetooth_power_enable(void) *************************************************/ static void *sf_bluetooth_piscan_task(void *arg) { + UINT8 i = 0; sf_bluetooth_power_enable(); - system("export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/misc:/customer/rocus/lib"); - system("adduser messagebus"); + //system("export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/misc:/customer/rocus/lib"); + //system("adduser messagebus"); - system("/customer/blue/bin/rtk_hciattach -n -s 115200 ttyS2 rtk_h5 &"); - sleep(3); //wait to init ok + system("rtk_hciattach -n -s 115200 ttyS1 rtk_h5 &"); - char sSSID[128]= {0}; - UINT8 smac[12]= {0}; - sf_getb_mac("wlan0", smac); - sprintf(sSSID,"X_%02X%02X%02X",smac[3],smac[4],smac[5]); - hciconfig_set_name(sSSID); - system("/customer/blue/bin/dbus-daemon --system"); - system("/customer/blue/bin/bluetoothd -d -n -C &"); + for (i = 0; i < 40; i++) { + if (access("/tmp/blue_setup_complete", F_OK) == 0) { + printf("blue setup complete\r\n"); + remove("/tmp/blue_setup_complete"); + + break; + } else { + usleep(500 * 1000); + if(39 == i) + { + MLOGE("blue setup fall!!\n"); + return NULL; + } + } + } + + char ssid[6]= {0}; + hciconfig_get_address(ssid); + snprintf(g_ble_ssid, sizeof(g_ble_ssid), "X-PRO_%s",ssid); + hciconfig_set_name(g_ble_ssid); + sf_set_ble_name(g_ble_ssid); + + system("dbus-daemon --system"); + system("bluetoothd -d -n -C &"); hciconfig_open_piscan(); gatt_service_register(gst_ble_rcb, gst_ble_wcb); @@ -120,7 +179,7 @@ static void *sf_bluetooth_piscan_task(void *arg) Return: SF_SUCCESS or SF_FAILURE Others: N/A *************************************************/ -S32 sf_blue_hal_init(BLE_RD rcb, BLE_WR wcb) +unsigned int sf_blue_hal_init(BLE_RD rcb, BLE_WR wcb) { gst_ble_rcb = rcb; gst_ble_wcb = wcb; @@ -130,6 +189,6 @@ S32 sf_blue_hal_init(BLE_RD rcb, BLE_WR wcb) pthread_create(&gblue_disconnect_pid, NULL, sf_bluetooth_disconnect_task, NULL); pthread_detach(gblue_disconnect_pid); - return SF_SUCCESS; + return 0; } diff --git a/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_hal.h b/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_hal.h index c8d835cee..2d56f0915 100755 --- a/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_hal.h +++ b/code/application/source/sf_app/code/source/sf_blue/src/sf_blue_hal.h @@ -31,7 +31,7 @@ extern "C" { typedef int (*BLE_RD)(unsigned char **, unsigned int *); typedef int (*BLE_WR)(unsigned char *, unsigned int, unsigned char **, unsigned int *); -S32 sf_blue_hal_init(BLE_RD rcb, BLE_WR wcb); +unsigned int sf_blue_hal_init(BLE_RD rcb, BLE_WR wcb); #ifdef __cplusplus } diff --git a/code/application/source/sf_app/tools/blue/include/dbus-1.0/dbus/dbus-arch-deps.h b/code/application/source/sf_app/tools/blue/include/dbus-1.0/dbus/dbus-arch-deps.h new file mode 100755 index 000000000..d6cb8268a --- /dev/null +++ b/code/application/source/sf_app/tools/blue/include/dbus-1.0/dbus/dbus-arch-deps.h @@ -0,0 +1,65 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-arch-deps.h Header with architecture/compiler specific information, installed to libdir + * + * Copyright (C) 2003 Red Hat, Inc. + * SPDX-License-Identifier: AFL-2.0 OR GPL-2.0-or-later + * + * Licensed under the Academic Free License version 2.0 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#if !defined (DBUS_INSIDE_DBUS_H) && !defined (DBUS_COMPILATION) +#error "Only can be included directly, this file may disappear or change contents." +#endif + +#ifndef DBUS_ARCH_DEPS_H +#define DBUS_ARCH_DEPS_H + +#include + +DBUS_BEGIN_DECLS + +/* D-Bus no longer supports platforms with no 64-bit integer type. */ +#define DBUS_HAVE_INT64 1 +_DBUS_GNUC_EXTENSION typedef long long dbus_int64_t; +_DBUS_GNUC_EXTENSION typedef unsigned long long dbus_uint64_t; +#define DBUS_INT64_MODIFIER "ll" + +#define DBUS_INT64_CONSTANT(val) (_DBUS_GNUC_EXTENSION (val##LL)) +#define DBUS_UINT64_CONSTANT(val) (_DBUS_GNUC_EXTENSION (val##ULL)) + +typedef int dbus_int32_t; +typedef unsigned int dbus_uint32_t; + +typedef short dbus_int16_t; +typedef unsigned short dbus_uint16_t; + +#define DBUS_SIZEOF_VOID_P 4 + +/* This is not really arch-dependent, but it's not worth + * creating an additional generated header just for this + */ +#define DBUS_MAJOR_VERSION 1 +#define DBUS_MINOR_VERSION 15 +#define DBUS_MICRO_VERSION 6 + +#define DBUS_VERSION_STRING "1.15.6" + +#define DBUS_VERSION ((1 << 16) | (15 << 8) | (6)) + +DBUS_END_DECLS + +#endif /* DBUS_ARCH_DEPS_H */ diff --git a/code/application/source/sf_app/tools/blue/libexec/bluetooth/bluetoothd b/code/application/source/sf_app/tools/blue/libexec/bluetooth/bluetoothd index de0516a84..69e124190 100755 Binary files a/code/application/source/sf_app/tools/blue/libexec/bluetooth/bluetoothd and b/code/application/source/sf_app/tools/blue/libexec/bluetooth/bluetoothd differ diff --git a/code/lib/external/Makefile b/code/lib/external/Makefile index cb9bdbfff..0ced0a06a 100755 --- a/code/lib/external/Makefile +++ b/code/lib/external/Makefile @@ -176,6 +176,7 @@ install: @if [ -x ${INSTALL_DIR}/usr/lib ]; then \ cp -arvf ${INSTALL_DIR}/usr/lib/*.* ${LIBRARY_DIR}/output/usr/lib; \ fi + @cp -darvf $(APP_DIR)/source/sf_app/tools/blue/lib/*.* $(LIBRARY_DIR)/output clean: @echo ">>>>>>>>>>>>>>>>>>> Remove >>>>>>>>>>>>>>>>>>>"