From 64bf9bbad3d5693c9a15d3ba8ec3e06b73de9318 Mon Sep 17 00:00:00 2001 From: payton Date: Wed, 8 Nov 2023 16:41:10 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E8=93=9D=E7=89=99=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../code/source/sf_blue/src/sf_blue_app.c | 47 ++++++++++++++++-- .../code/source/sf_blue/src/sf_blue_app.h | 49 ++++++++++++++++++- .../sf_app/code/source/wifi/sf_wifi_svr.c | 15 ++++-- 3 files changed, 102 insertions(+), 9 deletions(-) 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 08a4fb569..faf1adcde 100644 --- 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 @@ -549,9 +549,9 @@ static signed int sf_blue_command_request_process(U8 *val, unsigned int nval, U8 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->Multishot = pMsgStruct->msgBuf.setMultiShot.multiShot % 3; puiPara->MultiShotIntevel = pMsgStruct->msgBuf.setMultiShot.multiInterval % 3; - puiPara->SendMulti = pMsgStruct->msgBuf.setMultiShot.sendMulti % 2; + puiPara->SendMulti = !!pMsgStruct->msgBuf.setMultiShot.sendMulti; if(puiPara->SendMulti == 0) { puiPara->SendMultishotIndex2 = 0; @@ -855,7 +855,20 @@ static signed int sf_blue_command_request_process(U8 *val, unsigned int nval, U8 paramSaveFlag = 1; } break; - + case BLE_SET_CAMERA_WifiPWD: // + snprintf((char *)puiPara->WifiApPWD, sizeof(puiPara->WifiApPWD), "%s", (char *)pMsgStruct->msgBuf.setWifiPWD.newPWD); + SLOGI("new AP PWD: %s\n", puiPara->WifiApPWD); + paraNeedReboot = 1; + respFlag = 2; + paramSaveFlag = 1; + break; + case BLE_SET_CAMERA_WifiName: // + snprintf((char *)puiPara->strSSID, sizeof(puiPara->strSSID), "%s", (char *)pMsgStruct->msgBuf.setWifiSSID.newSSID); + SLOGI("new AP SSID: %s\n", puiPara->strSSID); + paraNeedReboot = 1; + respFlag = 2; + paramSaveFlag = 1; + break; case BLE_CONTROL_CAMERA_FormatSDCard: { SLOGI("[BLE_CONTROL_CAMERA_FormatSDCard],format:%d\n",pMsgStruct->msgBuf.ctrlFormat.format); @@ -888,6 +901,12 @@ static signed int sf_blue_command_request_process(U8 *val, unsigned int nval, U8 respFlag = 1; } break; + case BLE_CONTROL_CAMERA_Reboot: + SLOGI("[WIFI_CONTROL_CAMERA_Reboot],reboot:%d\n",pMsgStruct->msgBuf.ctrlReboot.reboot); + tmp = pMsgStruct->msgBuf.ctrlReboot.reboot; + paraNeedReboot = 1; + respFlag = 2; + break; case BLE_CONTROL_CAMERA_Recovery: { SLOGI("[BLE_CONTROL_CAMERA_Recovery]\n"); @@ -900,6 +919,28 @@ static signed int sf_blue_command_request_process(U8 *val, unsigned int nval, U8 respFlag = 2; } break; + case BLE_CONTROL_CAMERA_Network_Scan: + SLOGI("[WIFI_CONTROL_CAMERA_Network_Scan] \n"); + //SF_MESSAGE_BUF_S stMessageBuf = {0}; + stMessageBuf.arg1 = SF_DEV_CMD_ESIM_OPERATION_SCAN; + stMessageBuf.arg2 = SF_CONTROL_TYPE_WIFI; + stMessageBuf.arg3 = pMsgStruct->msgBuf.ctrlNetworkScan.networkCtrl; + stMessageBuf.cmdId = CMD_DEV; + sf_com_message_send_to_app(&stMessageBuf); + respFlag = 0; + break; + + case BLE_CONTROL_CAMERA_Network_Select: + //SF_MESSAGE_BUF_S stMessageBuf = {0}; + SLOGI("[WIFI_CONTROL_CAMERA_Network_Select] , pID:%d\n", \ + pMsgStruct->msgBuf.ctrlNetworkSelect.profileId); + stMessageBuf.arg1 = SF_DEV_CMD_ESIM_OPERATION_SELECT; + stMessageBuf.arg2 = SF_CONTROL_TYPE_WIFI; + stMessageBuf.arg3 = pMsgStruct->msgBuf.ctrlNetworkSelect.profileId; + stMessageBuf.cmdId = CMD_DEV; + sf_com_message_send_to_app(&stMessageBuf); + respFlag = 0; + break; default: { msgParse.msgBuf.camreaSetRsp.cmdRet = -1; 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 5addf8d20..b642d05c0 100644 --- 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 @@ -57,11 +57,24 @@ typedef enum BLE_SET_CAMERA_GPS = 0x22, //设置相机GPS BLE_SET_CAMERA_timeLapse = 0x23, //设置相机缩时摄影 BLE_SET_CAMERA_PicUponDailyReport = 0x24, //设置DailyReport时是否发送照片. - + BLE_SET_CAMERA_WifiPWD = 0x25, //设置相机的wifi密码 + BLE_SET_CAMERA_WifiName = 0x26, //设置相机的wifi name + //*APP待增加项 BLE_CONTROL_CAMERA_FormatSDCard = 0x30,//格式化SD卡 + BLE_CONTROL_CAMERA_Reboot = 0x31, //重启相机 BLE_CONTROL_CAMERA_Recovery = 0x32, //恢复出厂设置 - + BLE_CONTROL_CAMERA_CloseAPMode = 0x33, //关闭AP模式 + BLE_CONTROL_CAMERA_FileTransfer = 0x34,//文件收/发 + BLE_CONTROL_CAMERA_StopTransfer = 0x35,//中断数据发送(用于停止发送文件) + BLE_CONTROL_CAMERA_DeleteFile = 0x36, //删除相机SD卡上的某个文件 + BLE_CONTROL_CAMERA_CheckThumb = 0x37, //核对缩略图 + BLE_CONTROL_CAMERA_SHOOT = 0x38, //相机拍摄 + BLE_CONTROL_CAMERA_Update = 0x39, //相机软件升级 + BLE_CONTROL_CAMERA_Debug = 0x3a, //debug模式 + BLE_CONTROL_CAMERA_Network_Scan = 0x3b, //Network scan + BLE_CONTROL_CAMERA_Network_Select = 0x3c,//Network select + BLE_CMD_MAX = 0x40, } BLE_CMD_E; @@ -418,6 +431,30 @@ typedef struct UINT16 suffix; /* 0xFFEE */ } __attribute__((packed)) MSG_DEV_BLE_Reset_Ctrl_RSP_T; +typedef struct +{ + UINT8 networkCtrl; /* 0:scan and get 1: get only*/ + UINT16 suffix; /* 0xFFEE */ +}__attribute__((packed)) MSG_DEV_NetworkScan_Ctrl_T; + +typedef struct +{ + UINT8 cmdRet; /* 0: mean cmd OK other:mean cmd error */ + UINT8 buff[4]; /*Variable length, only as a mark*/ + UINT16 suffix; /* 0xFFEE */ +} __attribute__((packed)) MSG_DEV_NetworkScan_Ctrl_Rsp_T; + +typedef struct +{ + UINT8 profileId; /*profile ID */ + UINT16 suffix; /* 0xFFEE */ +}__attribute__((packed)) MSG_DEV_NetworkSelect_Ctrl_T; + +typedef struct +{ + UINT8 cmdRet; /* 0: mean cmd OK other:mean cmd error */ + UINT16 suffix; /* 0xFFEE */ +} __attribute__((packed)) MSG_DEV_NetworkSelect_Ctrl_Rsp_T; /************* APP_MSG_T 数据结构 **************/ typedef struct @@ -530,6 +567,14 @@ typedef struct /*恢复出厂设置*/ MSG_DEV_BLE_Reset_Ctrl_T ctrlReset; MSG_DEV_BLE_Reset_Ctrl_RSP_T rctrlReset; + + /*Network Scan*/ + MSG_DEV_NetworkScan_Ctrl_T ctrlNetworkScan; + MSG_DEV_NetworkScan_Ctrl_Rsp_T rctrlNetworkScan; + + /*Network select*/ + MSG_DEV_NetworkSelect_Ctrl_T ctrlNetworkSelect; + MSG_DEV_NetworkSelect_Ctrl_Rsp_T rctrlNetworkSelect; }; } __attribute__((packed)) BLE_APP_MSG_T; typedef struct diff --git a/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c b/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c index af4348c4e..aa4b96a2c 100755 --- a/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c +++ b/code/application/source/sf_app/code/source/wifi/sf_wifi_svr.c @@ -2042,7 +2042,7 @@ SINT32 sf_svr_packet_proc(SINT32 fd, UINT8 *pAppData, UINT16 dataLen) case WIFI_CONTROL_CAMERA_Debug: //O puiPara->DebugMode = pMsgStruct->msgBuf.setDebugMode.debugMode % 2; - MLOGI("[WIFI_CONTROL_CAMERA_Debug]DebugMode:%d\n", puiPara->DebugMode); + SLOGI("[WIFI_CONTROL_CAMERA_Debug]DebugMode:%d\n", puiPara->DebugMode); if(puiPara->DebugMode) { //sf_led_flash_start(SF_LED_FAST_FLAH, Sf_LED_SD_G); @@ -2673,10 +2673,17 @@ void sf_wifi_hw_init(void) sf_getb_mac(SF_WIFI_NETDEV_8189_NAME, smac); // ret = system("ifconfig ap0 192.168.1.1 netmask 255.255.255.0 up"); // ret = system("hostapd -ddd /etc/hostapd/hostapd.conf &"); - sprintf(sSSID,"REVEAL_%02X%02X%02X",smac[3],smac[4],smac[5]); + if (puiPara->strSSID[0] == 0) + { + sprintf(sSSID,"REVEAL_%02X%02X%02X",smac[3],smac[4],smac[5]); + strcpy(SSID_STR, sSSID); + snprintf((char *)puiPara->strSSID, sizeof(puiPara->strSSID), "%s", (char *)SSID_STR); + } + else { + snprintf((char *)sSSID, sizeof(sSSID), "%s", (char *)puiPara->strSSID); + strcpy(SSID_STR, sSSID); + } - strcpy(SSID_STR, sSSID); - snprintf((char *)puiPara->strSSID, sizeof(puiPara->strSSID), "%s", (char *)SSID_STR); ret = system("ifconfig wlan0 192.168.1.1 netmask 255.255.255.0 up"); //ret = system("hostapd -ddd /appfs/etc/hostapd/hostapd-8189.conf &"); //ret = system("udhcpd /appfs/etc/udhcpd-8189.conf");