Showing
10 changed files
with
4569 additions
and
0 deletions
Too many changes to show.
To preserve performance only 10 of 192 files are displayed.
.gitignore
0 → 100644
Common/Common.cpp
0 → 100644
| 1 | +#include "StdAfx.h" | |
| 2 | +#include "Common.h" | |
| 3 | +#include "SNFstream.h" | |
| 4 | +#include "meta.h" | |
| 5 | +#include "C2kAgent_api.h" | |
| 6 | + | |
| 7 | +#include "xboot_debug.h" | |
| 8 | +#include "Mdebug.h" | |
| 9 | +#include "USBSwitchDLLibrary.h" | |
| 10 | +#include "des.h" | |
| 11 | +#include "AutoGen.h" | |
| 12 | +#include "SNbase.h" | |
| 13 | + | |
| 14 | +namespace SPMETA_DLL | |
| 15 | +{ | |
| 16 | + #include "Spmeta.h" | |
| 17 | +}; | |
| 18 | + | |
| 19 | + | |
| 20 | +void *g_hSwitchTool = NULL; | |
| 21 | +//DWORD g_MainDlgHandle; | |
| 22 | +META_Common_struct g_sMetaComm; | |
| 23 | +int g_iMetaStopFlag; | |
| 24 | +char g_pSetupFilepath[MAX_PATH]; | |
| 25 | +char g_pPasswdFilepath[MAX_PATH]; | |
| 26 | +Login_Identify_e g_LoginIdentify; | |
| 27 | + | |
| 28 | +#ifdef _AUTO_GEN_FEATURE_ | |
| 29 | +char g_pAutoGenSetupFilepath[MAX_PATH]; | |
| 30 | +AutoGenData_struct g_AutoGenData; | |
| 31 | +IniData_struct g_AutoGenSetup[] = | |
| 32 | +{ | |
| 33 | + {"Enable AutoGen", (bool*)&g_AutoGenData.bEnableAutoGen, INI_BOOLEAN}, | |
| 34 | + {"Barcode Increase Radix", (int*)&g_AutoGenData.eIncreaseRadix, INI_INTEGER}, | |
| 35 | + {"AutoGen Barcode", (bool*)&g_AutoGenData.bAutoGenBarcode, INI_BOOLEAN}, | |
| 36 | + {"AutoGen IMEI", (bool*)&g_AutoGenData.bAutoGenIMEI, INI_BOOLEAN}, | |
| 37 | + {"AutoGen BT", (bool*)&g_AutoGenData.bAutoGenBT, INI_BOOLEAN}, | |
| 38 | + {"AutoGen Wifi", (bool*)&g_AutoGenData.bAutoGenWifi, INI_BOOLEAN}, | |
| 39 | + {"AutoGen Ethernet", (bool*)&g_AutoGenData.bAutoGenEthernet, INI_BOOLEAN}, | |
| 40 | + {"AutoGen DRMKey MCID", (bool*)&g_AutoGenData.bAutoGenDRMKeyMCID, INI_BOOLEAN}, | |
| 41 | + | |
| 42 | + {"Barcode Step", (int*)&g_AutoGenData.sBarcode.iStep, INI_INTEGER}, | |
| 43 | + {"Barcode Start", (char*)&g_AutoGenData.sBarcode.Start, INI_STRING}, | |
| 44 | + {"Barcode End", (char*)&g_AutoGenData.sBarcode.End, INI_STRING}, | |
| 45 | + {"Barcode Next", (char*)&g_AutoGenData.sBarcode.Next, INI_STRING}, | |
| 46 | + | |
| 47 | + {"IMEI Step", (int*)&g_AutoGenData.sIMEI.iStep, INI_INTEGER}, | |
| 48 | + {"IMEI Start", (char*)&g_AutoGenData.sIMEI.Start, INI_STRING}, | |
| 49 | + {"IMEI End", (char*)&g_AutoGenData.sIMEI.End, INI_STRING}, | |
| 50 | + {"IMEI Next", (char*)&g_AutoGenData.sIMEI.Next, INI_STRING}, | |
| 51 | + | |
| 52 | + {"BT Step", (int*)&g_AutoGenData.sBtAddress.iStep, INI_INTEGER}, | |
| 53 | + {"BT Start", (char*)&g_AutoGenData.sBtAddress.Start, INI_STRING}, | |
| 54 | + {"BT End", (char*)&g_AutoGenData.sBtAddress.End, INI_STRING}, | |
| 55 | + {"BT Next", (char*)&g_AutoGenData.sBtAddress.Next, INI_STRING}, | |
| 56 | + | |
| 57 | + {"Wifi Step", (int*)&g_AutoGenData.sWifiAddress.iStep, INI_INTEGER}, | |
| 58 | + {"Wifi Start", (char*)&g_AutoGenData.sWifiAddress.Start, INI_STRING}, | |
| 59 | + {"Wifi End", (char*)&g_AutoGenData.sWifiAddress.End, INI_STRING}, | |
| 60 | + {"Wifi Next", (char*)&g_AutoGenData.sWifiAddress.Next, INI_STRING}, | |
| 61 | + | |
| 62 | + {"Ethernet Step", (int*)&g_AutoGenData.sEthernetAddress.iStep, INI_INTEGER}, | |
| 63 | + {"Ethernet Start", (char*)&g_AutoGenData.sEthernetAddress.Start, INI_STRING}, | |
| 64 | + {"Ethernet End", (char*)&g_AutoGenData.sEthernetAddress.End, INI_STRING}, | |
| 65 | + {"Ethernet Next", (char*)&g_AutoGenData.sEthernetAddress.Next, INI_STRING}, | |
| 66 | + | |
| 67 | + {"DRMKey MCID Step", (int*)&g_AutoGenData.sDRMKeyMCID.iStep, INI_INTEGER}, | |
| 68 | + {"DRMKey MCID Start", (char*)&g_AutoGenData.sDRMKeyMCID.Start, INI_STRING}, | |
| 69 | + {"DRMKey MCID End", (char*)&g_AutoGenData.sDRMKeyMCID.End, INI_STRING}, | |
| 70 | + {"DRMKey MCID Next", (char*)&g_AutoGenData.sDRMKeyMCID.Next, INI_STRING}, | |
| 71 | +}; | |
| 72 | + | |
| 73 | +#endif //#ifdef _AUTO_GEN_FEATURE_ | |
| 74 | + | |
| 75 | +IniData_struct g_IniData[] = | |
| 76 | +{ | |
| 77 | + {"Stress Test", &g_sMetaComm.iStressTest, INI_INTEGER}, | |
| 78 | + {"Already in Meta", &g_sMetaComm.bAlreadyInMeata, INI_BOOLEAN}, | |
| 79 | + {"Keep in Meta", &g_sMetaComm.bKeepInMeta, INI_BOOLEAN}, | |
| 80 | + {"Clear Meta Boot Flag", &g_sMetaComm.bClearMetaBootFlag, INI_BOOLEAN}, | |
| 81 | + {"Operator Mode", (int*)&g_sMetaComm.eOperatorMode, INI_INTEGER}, | |
| 82 | + {"Preloader Connect Timeout", (int*)&g_sMetaComm.iPre_Connect_Timeout, INI_INTEGER}, | |
| 83 | + {"Kernel Connect Timeout", (int*)&g_sMetaComm.iKernel_Connect_Timeout, INI_INTEGER}, | |
| 84 | + {"Target type", (int*)&g_sMetaComm.eTargetType, INI_INTEGER}, | |
| 85 | + {"Brom Port Filter", (char*)g_sMetaComm.sPortFilter.strBromFilter, INI_STRING}, | |
| 86 | + {"Preloader Port Filter", (char*)g_sMetaComm.sPortFilter.strPreloaderFilter, INI_STRING}, | |
| 87 | + {"Kernel Port Filter", (char*)g_sMetaComm.sPortFilter.strKernelFilter, INI_STRING}, | |
| 88 | + {"Composite Device Enable", (bool*)&g_sMetaComm.bCompositeDeviceEnable, INI_BOOLEAN}, | |
| 89 | + {"Usb Enable", (bool*)&g_sMetaComm.bUsbEnable, INI_BOOLEAN}, | |
| 90 | + {"USBSwitchTool Enable", (bool*)&g_sMetaComm.bSwithTool, INI_BOOLEAN}, | |
| 91 | + {"DualTalk Enable", (bool*)&g_sMetaComm.bDualTalk, INI_BOOLEAN}, | |
| 92 | + {"Security USB Enable", (bool*)&g_sMetaComm.bSecurityUSB, INI_BOOLEAN}, | |
| 93 | + {"USB Without Battery Enable", (bool*)&g_sMetaComm.bWithoutBattery, INI_BOOLEAN}, | |
| 94 | + {"Skip Write Prod_Info Enable", (bool*)&g_sMetaComm.bSkipWriteProdInfo, INI_BOOLEAN}, | |
| 95 | + {"Check BackupNv to PC Enable", (bool*)&g_sMetaComm.bCheckBackNVtoPC, INI_BOOLEAN}, | |
| 96 | + {"Check Fastboot OEM Lock Enable", (bool*)&g_sMetaComm.bCheckFastbootLock, INI_BOOLEAN}, | |
| 97 | + {"Check Calibration flag Enable", (bool*)&g_sMetaComm.bCheckCalFlag, INI_BOOLEAN}, | |
| 98 | + {"Check FinalTest flag Enable", (bool*)&g_sMetaComm.bCheckFtFlag, INI_BOOLEAN}, | |
| 99 | + // C2K Modem | |
| 100 | + {"Write Meid", (bool*)&g_sMetaComm.sWriteOption.bWriteMeid, INI_BOOLEAN}, | |
| 101 | + {"Write Esn", (bool*)&g_sMetaComm.sWriteOption.bWriteEsn, INI_BOOLEAN}, | |
| 102 | + {"Write Barcode", (bool*)&g_sMetaComm.sWriteOption.bWriteBarcode, INI_BOOLEAN}, | |
| 103 | + {"Write IMEI", (bool*)&g_sMetaComm.sWriteOption.bWriteIMEI, INI_BOOLEAN}, | |
| 104 | + {"Write Serial No.", (bool*)&g_sMetaComm.sWriteOption.bWriteSerialNo, INI_BOOLEAN}, | |
| 105 | + {"Write BT", (bool*)&g_sMetaComm.sWriteOption.bWriteBT, INI_BOOLEAN}, | |
| 106 | + {"Write Wifi", (bool*)&g_sMetaComm.sWriteOption.bWriteWifi, INI_BOOLEAN}, | |
| 107 | + {"Write Hdcp", (bool*)&g_sMetaComm.sWriteOption.bWriteHdcp, INI_BOOLEAN}, | |
| 108 | + {"Write DRMKey", (bool*)&g_sMetaComm.sWriteOption.bWriteDrm, INI_BOOLEAN}, | |
| 109 | + {"Install Hdcp Data", (bool*)&g_sMetaComm.sWriteOption.bInstallHdcpData, INI_BOOLEAN}, | |
| 110 | + {"Write Ethernet Mac Address", (bool*)&g_sMetaComm.sWriteOption.bWriteEthernetMac, INI_BOOLEAN}, | |
| 111 | + {"Write DRMkey MCID", (bool*)&g_sMetaComm.sWriteOption.bWriteDrmkeyMCID, INI_BOOLEAN}, | |
| 112 | + {"IMEI Nums", (int*)&g_sMetaComm.sIMEIOption.iImeiNums, INI_INTEGER}, | |
| 113 | + {"IMEI CheckSum", (bool*)&g_sMetaComm.sIMEIOption.bCheckSum, INI_BOOLEAN}, | |
| 114 | + {"IMEI Lock", (bool*)&g_sMetaComm.sIMEIOption.bLockIMEI, INI_BOOLEAN}, | |
| 115 | + {"Lock OTP", (bool*)&g_sMetaComm.sIMEIOption.bLockOtp, INI_BOOLEAN}, | |
| 116 | + {"DualIMEI same", (bool*)&g_sMetaComm.sIMEIOption.bDualIMEISame, INI_BOOLEAN}, | |
| 117 | + {"IMEI_1 Check header", (bool*)&g_sMetaComm.sIMEIHeader_Option[0].bCheckHeader, INI_BOOLEAN}, | |
| 118 | + {"IMEI_2 Check header", (bool*)&g_sMetaComm.sIMEIHeader_Option[1].bCheckHeader, INI_BOOLEAN}, | |
| 119 | + {"IMEI_3 Check header", (bool*)&g_sMetaComm.sIMEIHeader_Option[2].bCheckHeader, INI_BOOLEAN}, | |
| 120 | + {"IMEI_4 Check header", (bool*)&g_sMetaComm.sIMEIHeader_Option[3].bCheckHeader, INI_BOOLEAN}, | |
| 121 | + //C2K modem | |
| 122 | + {"Meid Check header", (bool*)&g_sMetaComm.sMeidHeader_Option.bCheckHeader, INI_BOOLEAN}, | |
| 123 | + {"Esn Check header", (bool*)&g_sMetaComm.sEsnHeader_Option.bCheckHeader, INI_BOOLEAN}, | |
| 124 | + {"Serial No. Check header", (bool*)&g_sMetaComm.sSerialNoHeader_Option.bCheckHeader, INI_BOOLEAN}, | |
| 125 | + {"Barcode Check header", (bool*)&g_sMetaComm.sBarcHeader_Option.bCheckHeader, INI_BOOLEAN}, | |
| 126 | + {"BT Check header", (bool*)&g_sMetaComm.sBTHeader_Option.bCheckHeader, INI_BOOLEAN}, | |
| 127 | + {"Wifi Check header", (bool*)&g_sMetaComm.sWifiHeader_Option.bCheckHeader, INI_BOOLEAN}, | |
| 128 | + {"Ethernet Check header", (bool*)&g_sMetaComm.sEthernetMacHeader_Option.bCheckHeader, INI_BOOLEAN}, | |
| 129 | + {"DRMKey MCID Check header", (bool*)&g_sMetaComm.sDrmkeyMCIDHeader_Option.bCheckHeader, INI_BOOLEAN}, | |
| 130 | + {"Enable Check BTWifi", (bool*)&g_sMetaComm.bCheckBTWifi, INI_BOOLEAN}, | |
| 131 | + {"IMEI_1 header string", (char*)g_sMetaComm.sIMEIHeader_Option[0].strHeader, INI_STRING}, | |
| 132 | + {"IMEI_2 header string", (char*)g_sMetaComm.sIMEIHeader_Option[1].strHeader, INI_STRING}, | |
| 133 | + {"IMEI_3 header string", (char*)g_sMetaComm.sIMEIHeader_Option[2].strHeader, INI_STRING}, | |
| 134 | + {"IMEI_4 header string", (char*)g_sMetaComm.sIMEIHeader_Option[3].strHeader, INI_STRING}, | |
| 135 | + //C2K Modem | |
| 136 | + {"Meid header string", (char*)g_sMetaComm.sMeidHeader_Option.strHeader, INI_STRING}, | |
| 137 | + {"Esn header string", (char*)g_sMetaComm.sEsnHeader_Option.strHeader, INI_STRING}, | |
| 138 | + {"Serial No. header string", (char*)g_sMetaComm.sSerialNoHeader_Option.strHeader, INI_STRING}, | |
| 139 | + {"Barcode header string", (char*)g_sMetaComm.sBarcHeader_Option.strHeader, INI_STRING}, | |
| 140 | + {"BT header string", (char*)g_sMetaComm.sBTHeader_Option.strHeader, INI_STRING}, | |
| 141 | + {"Wifi header string", (char*)g_sMetaComm.sWifiHeader_Option.strHeader, INI_STRING}, | |
| 142 | + {"Ethernet header string", (char*)g_sMetaComm.sEthernetMacHeader_Option.strHeader, INI_STRING}, | |
| 143 | + {"DRMKey MCID header string", (char*)g_sMetaComm.sDrmkeyMCIDHeader_Option.strHeader, INI_STRING}, | |
| 144 | + {"AP DB from DUT", (bool*)&g_sMetaComm.sDBFileOption.bAPDBFromDUT, INI_BOOLEAN}, | |
| 145 | + {"MD DB from DUT", (bool*)&g_sMetaComm.sDBFileOption.bMDDBFromDUT, INI_BOOLEAN}, | |
| 146 | + {"Modem_1 database path", (char*)g_sMetaComm.sDBFileOption.strMD1Dbpath, INI_STRING}, | |
| 147 | + {"Modem_2 database path", (char*)g_sMetaComm.sDBFileOption.strMD2Dbpath, INI_STRING}, | |
| 148 | + {"AP database path", (char*)g_sMetaComm.sDBFileOption.strAPDbpath, INI_STRING}, | |
| 149 | + {"FP Auth path", (char*)g_sMetaComm.sLoadFile.strFPAuthPath, INI_STRING}, | |
| 150 | + {"SP Auth path", (char*)g_sMetaComm.sLoadFile.strSPAuthPath, INI_STRING}, | |
| 151 | + {"Hdcp Bin path", (char*)g_sMetaComm.sLoadFile.strHdcpBinPath, INI_STRING}, | |
| 152 | + {"DrmKey path", (char*)g_sMetaComm.sLoadFile.strDrmKeyPath, INI_STRING}, | |
| 153 | + {"Hdcp data path", (char*)g_sMetaComm.sLoadFile.strHdcpDataPath, INI_STRING}, | |
| 154 | + {"Hdcp cek path", (char*)g_sMetaComm.sLoadFile.strHdcpCekPath, INI_STRING}, | |
| 155 | + //{"Trigger extern modem download", (bool*)&g_sMetaComm.sBarcodeOption.bExtMdDl, INI_BOOLEAN}, | |
| 156 | + | |
| 157 | + {"Enable Write Temperature", (bool*)&g_sMetaComm.sIMEIOption.Temp_Option.bWriteTemperature,INI_BOOLEAN}, | |
| 158 | + {"The Current Temperature", (char*)&g_sMetaComm.sIMEIOption.Temp_Option.strTemperatureData,INI_STRING}, | |
| 159 | + | |
| 160 | + {"Log Dir", (char*)g_sMetaComm.strLogDir, INI_STRING}, | |
| 161 | + {"ModemLog", (bool *)&g_sMetaComm.bMDLog, INI_BOOLEAN}, | |
| 162 | + | |
| 163 | + //for C2K | |
| 164 | + {"Enable Serial No", (bool*)&g_sMetaComm.EnableSerialNo, INI_BOOLEAN}, | |
| 165 | + {"Ignore Database Inconsistent", (bool*)&g_sMetaComm.IgnoreDBInconsistent, INI_BOOLEAN}, | |
| 166 | + {"Serial Num From IMEI", (bool*)&g_sMetaComm.SerialNumFromIMEI, INI_BOOLEAN}, | |
| 167 | + {"IMEI Lock Hidden", (bool*)&g_sMetaComm.ImeiLockHidden, INI_BOOLEAN}, | |
| 168 | + {"Enable Lock OTP", (bool*)&g_sMetaComm.bEnableLockOtp, INI_BOOLEAN}, | |
| 169 | +}; | |
| 170 | + | |
| 171 | +bool ResultToString_Win(DWORD ED, char* lpBuffer, DWORD nSize) | |
| 172 | +{ | |
| 173 | + DWORD ret_dw = 0u; | |
| 174 | + DWORD i_dw = 0u, j_dw = 0u; | |
| 175 | + | |
| 176 | + if (lpBuffer == NULL || nSize < 64u) | |
| 177 | + return false; | |
| 178 | + | |
| 179 | + ret_dw = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, | |
| 180 | + NULL, | |
| 181 | + ED, | |
| 182 | + MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), | |
| 183 | + lpBuffer, | |
| 184 | + nSize, | |
| 185 | + NULL); | |
| 186 | + if (ret_dw == 0u) | |
| 187 | + return false; | |
| 188 | + | |
| 189 | + // remove '\r' '\n' | |
| 190 | + j_dw = 0u; | |
| 191 | + for (i_dw = 0u; i_dw < ret_dw && lpBuffer[i_dw] != '\0'; i_dw++) | |
| 192 | + { | |
| 193 | + if (lpBuffer[i_dw] != '\r' && lpBuffer[i_dw] != '\n') | |
| 194 | + { | |
| 195 | + if (j_dw == i_dw) | |
| 196 | + j_dw++; | |
| 197 | + else | |
| 198 | + lpBuffer[j_dw++] = lpBuffer[i_dw]; | |
| 199 | + } | |
| 200 | + } | |
| 201 | + lpBuffer[j_dw] = '\0'; | |
| 202 | + | |
| 203 | + return true; | |
| 204 | +} | |
| 205 | + | |
| 206 | +char* ResultToString_SP(int MR) | |
| 207 | +{ | |
| 208 | + switch((META_RESULT)MR) | |
| 209 | + { | |
| 210 | + case SPMETA_DLL::META_SUCCESS: | |
| 211 | + return M2S(SPMETA_DLL::META_SUCCESS); | |
| 212 | + | |
| 213 | + case SPMETA_DLL::META_FAILED: | |
| 214 | + return M2S(SPMETA_DLL::META_FAILED); | |
| 215 | + | |
| 216 | + case SPMETA_DLL::META_COMM_FAIL: | |
| 217 | + return M2S(SPMETA_DLL::META_COMM_FAIL); | |
| 218 | + | |
| 219 | + case SPMETA_DLL::META_NORESPONSE: | |
| 220 | + return M2S(SPMETA_DLL::META_NORESPONSE); | |
| 221 | + | |
| 222 | + case SPMETA_DLL::META_BUFFER_LEN: | |
| 223 | + return M2S(SPMETA_DLL::META_BUFFER_LEN); | |
| 224 | + | |
| 225 | + case SPMETA_DLL::META_FILE_BAD: | |
| 226 | + return M2S(SPMETA_DLL::META_FILE_BAD); | |
| 227 | + | |
| 228 | + case SPMETA_DLL::META_LID_INVALID: | |
| 229 | + return M2S(SPMETA_DLL::META_LID_INVALID); | |
| 230 | + | |
| 231 | + case SPMETA_DLL::META_INTERNAL_DB_ERR: | |
| 232 | + return M2S(SPMETA_DLL::META_INTERNAL_DB_ERR); | |
| 233 | + | |
| 234 | + case SPMETA_DLL::META_NO_MEMORY: | |
| 235 | + return M2S(SPMETA_DLL::META_NO_MEMORY); | |
| 236 | + | |
| 237 | + case SPMETA_DLL::META_INVALID_ARGUMENTS: | |
| 238 | + return M2S(SPMETA_DLL::META_INVALID_ARGUMENTS); | |
| 239 | + | |
| 240 | + case SPMETA_DLL::META_TIMEOUT: | |
| 241 | + return M2S(SPMETA_DLL::META_TIMEOUT); | |
| 242 | + | |
| 243 | + case SPMETA_DLL::META_BUSY: | |
| 244 | + return M2S(SPMETA_DLL::META_BUSY); | |
| 245 | + | |
| 246 | + case SPMETA_DLL::META_INVALID_HANDLE: | |
| 247 | + return M2S(SPMETA_DLL::META_INVALID_HANDLE); | |
| 248 | + | |
| 249 | + case SPMETA_DLL::META_FAT_ERROR: | |
| 250 | + return M2S(SPMETA_DLL::META_FAT_ERROR); | |
| 251 | + | |
| 252 | + case SPMETA_DLL::META_FAT_DISK_FULL: | |
| 253 | + return M2S(SPMETA_DLL::META_FAT_DISK_FULL); | |
| 254 | + | |
| 255 | + case SPMETA_DLL::META_FAT_ROOT_DIR_FULL: | |
| 256 | + return M2S(SPMETA_DLL::META_FAT_ROOT_DIR_FULL); | |
| 257 | + | |
| 258 | + case SPMETA_DLL::META_FAT_INVALID_FILENAME: | |
| 259 | + return M2S(SPMETA_DLL::META_FAT_INVALID_FILENAME); | |
| 260 | + | |
| 261 | + case SPMETA_DLL::META_FAT_INVALID_FILE_HANDLE: | |
| 262 | + return M2S(SPMETA_DLL::META_FAT_INVALID_FILE_HANDLE); | |
| 263 | + | |
| 264 | + case SPMETA_DLL::META_FAT_FILE_NOT_FOUND: | |
| 265 | + return M2S(SPMETA_DLL::META_FAT_FILE_NOT_FOUND); | |
| 266 | + | |
| 267 | + case SPMETA_DLL::META_FAT_DRIVE_NOT_FOUND: | |
| 268 | + return M2S(SPMETA_DLL::META_FAT_DRIVE_NOT_FOUND); | |
| 269 | + | |
| 270 | + case SPMETA_DLL::META_FAT_PATH_NOT_FOUND: | |
| 271 | + return M2S(SPMETA_DLL::META_FAT_PATH_NOT_FOUND); | |
| 272 | + | |
| 273 | + case SPMETA_DLL::META_FAT_ACCESS_DENIED: | |
| 274 | + return M2S(SPMETA_DLL::META_FAT_ACCESS_DENIED); | |
| 275 | + | |
| 276 | + case SPMETA_DLL::META_FAT_TOO_MANY_FILES: | |
| 277 | + return M2S(SPMETA_DLL::META_FAT_TOO_MANY_FILES); | |
| 278 | + | |
| 279 | + case SPMETA_DLL::META_INCORRECT_TARGET_VER: | |
| 280 | + return M2S(SPMETA_DLL::META_INCORRECT_TARGET_VER); | |
| 281 | + | |
| 282 | + case SPMETA_DLL::META_COM_ERROR: | |
| 283 | + return M2S(SPMETA_DLL::META_COM_ERROR); | |
| 284 | + | |
| 285 | + case SPMETA_DLL::META_BROM_CMD_ERROR: | |
| 286 | + return M2S(SPMETA_DLL::META_BROM_CMD_ERROR); | |
| 287 | + | |
| 288 | + case SPMETA_DLL::META_INCORRECT_BBCHIP_TYPE: | |
| 289 | + return M2S(SPMETA_DLL::META_INCORRECT_BBCHIP_TYPE); | |
| 290 | + | |
| 291 | + case SPMETA_DLL::META_BROM_ERROR: | |
| 292 | + return M2S(SPMETA_DLL::META_BROM_ERROR); | |
| 293 | + | |
| 294 | + case SPMETA_DLL::META_STOP_BOOTUP_PROCEDURE: | |
| 295 | + return M2S(SPMETA_DLL::META_STOP_BOOTUP_PROCEDURE); | |
| 296 | + | |
| 297 | + case SPMETA_DLL::META_CANCEL: | |
| 298 | + return M2S(SPMETA_DLL::META_CANCEL); | |
| 299 | + | |
| 300 | + case SPMETA_DLL::META_CCT_NOT_IMPORT_PROFILE: | |
| 301 | + return M2S(SPMETA_DLL::META_CCT_NOT_IMPORT_PROFILE); | |
| 302 | + | |
| 303 | + case SPMETA_DLL::META_CCT_INVALID_SENSOR_ID: | |
| 304 | + return M2S(SPMETA_DLL::META_CCT_INVALID_SENSOR_ID); | |
| 305 | + | |
| 306 | + case SPMETA_DLL::META_CCT_TGT_NO_MEM_FOR_SINGLE_SHOT: | |
| 307 | + return M2S(SPMETA_DLL::META_CCT_TGT_NO_MEM_FOR_SINGLE_SHOT); | |
| 308 | + | |
| 309 | + case SPMETA_DLL::META_CCT_TGT_NO_MEM_FOR_MULTI_SHOT: | |
| 310 | + return M2S(SPMETA_DLL::META_CCT_TGT_NO_MEM_FOR_MULTI_SHOT); | |
| 311 | + | |
| 312 | + case SPMETA_DLL::META_FUNC_NOT_IMPLEMENT_YET: | |
| 313 | + return M2S(SPMETA_DLL::META_FUNC_NOT_IMPLEMENT_YET); | |
| 314 | + | |
| 315 | + //case SPMETA_DLL::META_CCT_NOT_IMPLEMENT_YET: | |
| 316 | + // return M2S(SPMETA_DLL::META_CCT_NOT_IMPLEMENT_YET); | |
| 317 | + | |
| 318 | + case SPMETA_DLL::META_CCT_PREVIEW_ALREADY_STARTED: | |
| 319 | + return M2S(SPMETA_DLL::META_CCT_PREVIEW_ALREADY_STARTED); | |
| 320 | + | |
| 321 | + case SPMETA_DLL::META_CCT_PREVIEW_ALREADY_STOPPED: | |
| 322 | + return M2S(SPMETA_DLL::META_CCT_PREVIEW_ALREADY_STOPPED); | |
| 323 | + | |
| 324 | + case SPMETA_DLL::META_CCT_READ_REG_NO_CNF: | |
| 325 | + return M2S(SPMETA_DLL::META_CCT_READ_REG_NO_CNF); | |
| 326 | + | |
| 327 | + case SPMETA_DLL::META_CCT_WRITE_REG_NO_CNF: | |
| 328 | + return M2S(SPMETA_DLL::META_CCT_WRITE_REG_NO_CNF); | |
| 329 | + | |
| 330 | + case SPMETA_DLL::META_CCT_TGT_ABORT_IMAGE_SENDING: | |
| 331 | + return M2S(SPMETA_DLL::META_CCT_TGT_ABORT_IMAGE_SENDING); | |
| 332 | + | |
| 333 | + case SPMETA_DLL::META_CCT_READ_ONLY_REGISTER: | |
| 334 | + return M2S(SPMETA_DLL::META_CCT_READ_ONLY_REGISTER); | |
| 335 | + | |
| 336 | + case SPMETA_DLL::META_CCT_LOAD_FROM_NVRAM_FAIL: | |
| 337 | + return M2S(SPMETA_DLL::META_CCT_LOAD_FROM_NVRAM_FAIL); | |
| 338 | + | |
| 339 | + case SPMETA_DLL::META_CCT_SAVE_TO_NVRAM_FAIL: | |
| 340 | + return M2S(SPMETA_DLL::META_CCT_SAVE_TO_NVRAM_FAIL); | |
| 341 | + | |
| 342 | + case SPMETA_DLL::META_CCT_AE_INVALID_EC_LEVEL: | |
| 343 | + return M2S(SPMETA_DLL::META_CCT_AE_INVALID_EC_LEVEL); | |
| 344 | + | |
| 345 | + case SPMETA_DLL::META_CCT_AE_INVALID_EC_STEP: | |
| 346 | + return M2S(SPMETA_DLL::META_CCT_AE_INVALID_EC_STEP); | |
| 347 | + | |
| 348 | + case SPMETA_DLL::META_CCT_AE_ALREADY_ENABLED: | |
| 349 | + return M2S(SPMETA_DLL::META_CCT_AE_ALREADY_ENABLED); | |
| 350 | + | |
| 351 | + case SPMETA_DLL::META_CCT_AE_ALREADY_DISABLED: | |
| 352 | + return M2S(SPMETA_DLL::META_CCT_AE_ALREADY_DISABLED); | |
| 353 | + | |
| 354 | + case SPMETA_DLL::META_CCT_WB_INVALID_INDEX: | |
| 355 | + return M2S(SPMETA_DLL::META_CCT_WB_INVALID_INDEX); | |
| 356 | + | |
| 357 | + case SPMETA_DLL::META_CCT_NO_TGT_SENSOR_MATCH_IN_PROFILE: | |
| 358 | + return M2S(SPMETA_DLL::META_CCT_NO_TGT_SENSOR_MATCH_IN_PROFILE); | |
| 359 | + | |
| 360 | + case SPMETA_DLL::META_CCT_IMAGE_SENDING_FAME_NUM_ERROR: | |
| 361 | + return M2S(SPMETA_DLL::META_CCT_IMAGE_SENDING_FAME_NUM_ERROR); | |
| 362 | + | |
| 363 | + case SPMETA_DLL::META_CCT_AE_IS_NOT_DISABLED: | |
| 364 | + return M2S(SPMETA_DLL::META_CCT_AE_IS_NOT_DISABLED); | |
| 365 | + | |
| 366 | + case SPMETA_DLL::META_FAT_APP_QUOTA_FULL: | |
| 367 | + return M2S(SPMETA_DLL::META_FAT_APP_QUOTA_FULL); | |
| 368 | + | |
| 369 | + case SPMETA_DLL::META_IMEI_CD_ERROR: | |
| 370 | + return M2S(SPMETA_DLL::META_IMEI_CD_ERROR); | |
| 371 | + | |
| 372 | + case SPMETA_DLL::META_RFID_MISMATCH: | |
| 373 | + return M2S(SPMETA_DLL::META_RFID_MISMATCH); | |
| 374 | + | |
| 375 | + case SPMETA_DLL::META_NVRAM_DB_IS_NOT_LOADED_YET: | |
| 376 | + return M2S(SPMETA_DLL::META_NVRAM_DB_IS_NOT_LOADED_YET); | |
| 377 | + | |
| 378 | + case SPMETA_DLL::META_CCT_ERR_CAPTURE_WIDTH_HEIGHT_TOO_SMALL: | |
| 379 | + return M2S(SPMETA_DLL::META_CCT_ERR_CAPTURE_WIDTH_HEIGHT_TOO_SMALL); | |
| 380 | + | |
| 381 | + case SPMETA_DLL::META_WAIT_FOR_TARGET_READY_TIMEOUT: | |
| 382 | + return M2S(SPMETA_DLL::META_WAIT_FOR_TARGET_READY_TIMEOUT); | |
| 383 | + | |
| 384 | + case SPMETA_DLL::META_CCT_ERR_SENSOR_ENG_SET_INVALID_VALUE: | |
| 385 | + return M2S(SPMETA_DLL::META_CCT_ERR_SENSOR_ENG_SET_INVALID_VALUE); | |
| 386 | + | |
| 387 | + case SPMETA_DLL::META_CCT_ERR_SENSOR_ENG_GROUP_NOT_EXIST: | |
| 388 | + return M2S(SPMETA_DLL::META_CCT_ERR_SENSOR_ENG_GROUP_NOT_EXIST); | |
| 389 | + | |
| 390 | + case SPMETA_DLL::META_CCT_NO_TGT_ISP_MATCH_IN_PROFILE: | |
| 391 | + return M2S(SPMETA_DLL::META_CCT_NO_TGT_ISP_MATCH_IN_PROFILE); | |
| 392 | + | |
| 393 | + case SPMETA_DLL::META_CCT_TGT_ISP_SUPPORT_NOT_DEFINED: | |
| 394 | + return M2S(SPMETA_DLL::META_CCT_TGT_ISP_SUPPORT_NOT_DEFINED); | |
| 395 | + | |
| 396 | + case SPMETA_DLL::META_CCT_ERR_SENSOR_ENG_ITEM_NOT_EXIST: | |
| 397 | + return M2S(SPMETA_DLL::META_CCT_ERR_SENSOR_ENG_ITEM_NOT_EXIST); | |
| 398 | + | |
| 399 | + case SPMETA_DLL::META_CCT_ERR_INVALID_COMPENSATION_MODE: | |
| 400 | + return M2S(SPMETA_DLL::META_CCT_ERR_INVALID_COMPENSATION_MODE); | |
| 401 | + | |
| 402 | + case SPMETA_DLL::META_CCT_ERR_USB_COM_NOT_READY: | |
| 403 | + return M2S(SPMETA_DLL::META_CCT_ERR_USB_COM_NOT_READY); | |
| 404 | + | |
| 405 | + case SPMETA_DLL::META_CCT_DEFECTPIXEL_CAL_UNDER_PROCESSING: | |
| 406 | + return M2S(SPMETA_DLL::META_CCT_DEFECTPIXEL_CAL_UNDER_PROCESSING); | |
| 407 | + | |
| 408 | + case SPMETA_DLL::META_CCT_ERR_DEFECTPIXEL_CAL_NO_MEM: | |
| 409 | + return M2S(SPMETA_DLL::META_CCT_ERR_DEFECTPIXEL_CAL_NO_MEM); | |
| 410 | + | |
| 411 | + case SPMETA_DLL::META_CCT_ERR_TOO_MANY_DEFECT_PIXEL: | |
| 412 | + return M2S(SPMETA_DLL::META_CCT_ERR_TOO_MANY_DEFECT_PIXEL); | |
| 413 | + | |
| 414 | + case SPMETA_DLL::META_CCT_ERR_CAPTURE_JPEG_FAIL: | |
| 415 | + return M2S(SPMETA_DLL::META_CCT_ERR_CAPTURE_JPEG_FAIL); | |
| 416 | + | |
| 417 | + case SPMETA_DLL::META_CCT_ERR_CAPTURE_JPEG_TIMEOUT: | |
| 418 | + return M2S(SPMETA_DLL::META_CCT_ERR_CAPTURE_JPEG_TIMEOUT); | |
| 419 | + | |
| 420 | + case SPMETA_DLL::META_CCT_ERR_AF_FAIL: | |
| 421 | + return M2S(SPMETA_DLL::META_CCT_ERR_AF_FAIL); | |
| 422 | + | |
| 423 | + case SPMETA_DLL::META_CCT_ERR_AF_TIMEOUT: | |
| 424 | + return M2S(SPMETA_DLL::META_CCT_ERR_AF_TIMEOUT); | |
| 425 | + | |
| 426 | + case SPMETA_DLL::META_CCT_ERR_AF_LENS_OFFSET_CAL_FAIL: | |
| 427 | + return M2S(SPMETA_DLL::META_CCT_ERR_AF_LENS_OFFSET_CAL_FAIL); | |
| 428 | + | |
| 429 | + case SPMETA_DLL::META_CCT_ERR_PREVIEW_MUST_ENABLE: | |
| 430 | + return M2S(SPMETA_DLL::META_CCT_ERR_PREVIEW_MUST_ENABLE); | |
| 431 | + | |
| 432 | + case SPMETA_DLL::META_CCT_ERR_UNSUPPORT_CAPTURE_FORMAT: | |
| 433 | + return M2S(SPMETA_DLL::META_CCT_ERR_UNSUPPORT_CAPTURE_FORMAT); | |
| 434 | + | |
| 435 | + case SPMETA_DLL::META_CCT_ERR_EXCEED_MAX_DEFECT_PIXEL: | |
| 436 | + return M2S(SPMETA_DLL::META_CCT_ERR_EXCEED_MAX_DEFECT_PIXEL); | |
| 437 | + | |
| 438 | + case SPMETA_DLL::META_ERR_EXCEED_MAX_PEER_BUF_SIZE: | |
| 439 | + return M2S(SPMETA_DLL::META_ERR_EXCEED_MAX_PEER_BUF_SIZE); | |
| 440 | + | |
| 441 | + case SPMETA_DLL::META_CCT_ERR_INVALID_WIDTH_FACTOR: | |
| 442 | + return M2S(SPMETA_DLL::META_CCT_ERR_INVALID_WIDTH_FACTOR); | |
| 443 | + | |
| 444 | + case SPMETA_DLL::META_BROM_SECURITY_CHECK_FAIL: | |
| 445 | + return M2S(SPMETA_DLL::META_BROM_SECURITY_CHECK_FAIL); | |
| 446 | + | |
| 447 | + case SPMETA_DLL::META_CCT_ERR_PREVIEW_MUST_DISABLE: | |
| 448 | + return M2S(SPMETA_DLL::META_CCT_ERR_PREVIEW_MUST_DISABLE); | |
| 449 | + | |
| 450 | + case SPMETA_DLL::META_MAUI_DB_INCONSISTENT: | |
| 451 | + return M2S(SPMETA_DLL::META_MAUI_DB_INCONSISTENT); | |
| 452 | + | |
| 453 | + case SPMETA_DLL::META_FAT_FILEPATH_TOO_LONG: | |
| 454 | + return M2S(SPMETA_DLL::META_FAT_FILEPATH_TOO_LONG); | |
| 455 | + | |
| 456 | + case SPMETA_DLL::META_FAT_RESTRICTED_FILEPATH: | |
| 457 | + return M2S(SPMETA_DLL::META_FAT_RESTRICTED_FILEPATH); | |
| 458 | + | |
| 459 | + case SPMETA_DLL::META_FAT_DIR_NOT_EXIST: | |
| 460 | + return M2S(SPMETA_DLL::META_FAT_DIR_NOT_EXIST); | |
| 461 | + | |
| 462 | + case SPMETA_DLL::META_FAT_DISK_SPACE_IS_NOT_ENOUGH: | |
| 463 | + return M2S(SPMETA_DLL::META_FAT_DISK_SPACE_IS_NOT_ENOUGH); | |
| 464 | + | |
| 465 | + case SPMETA_DLL::META_TDMB_ERR_BAND_NOT_EXIST: | |
| 466 | + return M2S(SPMETA_DLL::META_TDMB_ERR_BAND_NOT_EXIST); | |
| 467 | + | |
| 468 | + case SPMETA_DLL::META_TDMB_ERR_FREQ_NOT_EXIST: | |
| 469 | + return M2S(SPMETA_DLL::META_TDMB_ERR_FREQ_NOT_EXIST); | |
| 470 | + | |
| 471 | + case SPMETA_DLL::META_TDMB_ERR_ENSM_NOT_EXIST: | |
| 472 | + return M2S(SPMETA_DLL::META_TDMB_ERR_ENSM_NOT_EXIST); | |
| 473 | + | |
| 474 | + case SPMETA_DLL::META_TDMB_ERR_SERV_NOT_EXIST: | |
| 475 | + return M2S(SPMETA_DLL::META_TDMB_ERR_SERV_NOT_EXIST); | |
| 476 | + | |
| 477 | + case SPMETA_DLL::META_TDMB_ERR_SUB_CHAN_NOT_EXIST: | |
| 478 | + return M2S(SPMETA_DLL::META_TDMB_ERR_SUB_CHAN_NOT_EXIST); | |
| 479 | + | |
| 480 | + case SPMETA_DLL::META_TDMB_ERR_DEMOD_STATE: | |
| 481 | + return M2S(SPMETA_DLL::META_TDMB_ERR_DEMOD_STATE); | |
| 482 | + | |
| 483 | + case SPMETA_DLL::META_PERMISSION_DENIED: | |
| 484 | + return M2S(SPMETA_DLL::META_PERMISSION_DENIED); | |
| 485 | + | |
| 486 | + case SPMETA_DLL::META_ENUMERATE_USB_FAIL: | |
| 487 | + return M2S(SPMETA_DLL::META_ENUMERATE_USB_FAIL); | |
| 488 | + | |
| 489 | + case SPMETA_DLL::META_STOP_ENUM_USB_PROCEDURE: | |
| 490 | + return M2S(SPMETA_DLL::META_STOP_ENUM_USB_PROCEDURE); | |
| 491 | + | |
| 492 | + case SPMETA_DLL::META_CCT_6238_AE_ALREADY_ENABLED: | |
| 493 | + return M2S(SPMETA_DLL::META_CCT_6238_AE_ALREADY_ENABLED); | |
| 494 | + | |
| 495 | + case SPMETA_DLL::META_CCT_6238_AE_ALREADY_DISABLED: | |
| 496 | + return M2S(SPMETA_DLL::META_CCT_6238_AE_ALREADY_DISABLED); | |
| 497 | + | |
| 498 | + case SPMETA_DLL::META_CCT_6238_AE_IS_NOT_DISABLED: | |
| 499 | + return M2S(SPMETA_DLL::META_CCT_6238_AE_IS_NOT_DISABLED); | |
| 500 | + | |
| 501 | + case SPMETA_DLL::META_CCT_6238_ISP_FLASHLIGHT_LINEARITY_PRESTROBE_FAIL: | |
| 502 | + return M2S(SPMETA_DLL::META_CCT_6238_ISP_FLASHLIGHT_LINEARITY_PRESTROBE_FAIL); | |
| 503 | + | |
| 504 | + case SPMETA_DLL::META_NOT_SUPPORT: | |
| 505 | + return M2S(SPMETA_DLL::META_NOT_SUPPORT); | |
| 506 | + | |
| 507 | + case SPMETA_DLL::META_LAST_RESULT: | |
| 508 | + return M2S(SPMETA_DLL::META_LAST_RESULT); | |
| 509 | + default: | |
| 510 | + return M2S(DEFAULT_FAIL); | |
| 511 | + } | |
| 512 | +} | |
| 513 | + | |
| 514 | +char* ResultToString(int MR) | |
| 515 | +{ | |
| 516 | + switch((META_RESULT)MR) | |
| 517 | + { | |
| 518 | + | |
| 519 | + case META_SUCCESS: | |
| 520 | + return M2S(META_SUCCESS); | |
| 521 | + | |
| 522 | + case META_FAILED: | |
| 523 | + return M2S(META_FAILED); | |
| 524 | + | |
| 525 | + case META_COMM_FAIL: | |
| 526 | + return M2S(META_COMM_FAIL); | |
| 527 | + | |
| 528 | + case META_NORESPONSE: | |
| 529 | + return M2S(META_NORESPONSE); | |
| 530 | + | |
| 531 | + case META_EBOOT_FAILED: | |
| 532 | + return M2S(META_EBOOT_FAILED); | |
| 533 | + | |
| 534 | + case META_BUFFER_LEN: | |
| 535 | + return M2S(META_BUFFER_LEN); | |
| 536 | + | |
| 537 | + case META_FILE_BAD: | |
| 538 | + return M2S(META_FILE_BAD); | |
| 539 | + | |
| 540 | + case META_LID_INVALID: | |
| 541 | + return M2S(META_LID_INVALID); | |
| 542 | + | |
| 543 | + case META_INTERNAL_DB_ERR: | |
| 544 | + return M2S(META_INTERNAL_DB_ERR); | |
| 545 | + | |
| 546 | + case META_NO_MEMORY: | |
| 547 | + return M2S(META_NO_MEMORY); | |
| 548 | + | |
| 549 | + case META_INVALID_ARGUMENTS: | |
| 550 | + return M2S(META_INVALID_ARGUMENTS); | |
| 551 | + | |
| 552 | + case META_TIMEOUT: | |
| 553 | + return M2S(META_TIMEOUT); | |
| 554 | + | |
| 555 | + case META_BUSY: | |
| 556 | + return M2S(META_BUSY); | |
| 557 | + | |
| 558 | + case META_INVALID_HANDLE: | |
| 559 | + return M2S(META_INVALID_HANDLE); | |
| 560 | + | |
| 561 | + case META_FAT_ERROR: | |
| 562 | + return M2S(META_FAT_ERROR); | |
| 563 | + | |
| 564 | + case META_FAT_DISK_FULL: | |
| 565 | + return M2S(META_FAT_DISK_FULL); | |
| 566 | + | |
| 567 | + case META_FAT_ROOT_DIR_FULL: | |
| 568 | + return M2S(META_FAT_ROOT_DIR_FULL); | |
| 569 | + | |
| 570 | + case META_FAT_INVALID_FILENAME: | |
| 571 | + return M2S(META_FAT_INVALID_FILENAME); | |
| 572 | + | |
| 573 | + case META_FAT_INVALID_FILE_HANDLE: | |
| 574 | + return M2S(META_FAT_INVALID_FILE_HANDLE); | |
| 575 | + | |
| 576 | + case META_FAT_FILE_NOT_FOUND: | |
| 577 | + return M2S(META_FAT_FILE_NOT_FOUND); | |
| 578 | + | |
| 579 | + case META_FAT_DRIVE_NOT_FOUND: | |
| 580 | + return M2S(META_FAT_DRIVE_NOT_FOUND); | |
| 581 | + | |
| 582 | + case META_FAT_PATH_NOT_FOUND: | |
| 583 | + return M2S(META_FAT_PATH_NOT_FOUND); | |
| 584 | + | |
| 585 | + case META_FAT_ACCESS_DENIED: | |
| 586 | + return M2S(META_FAT_ACCESS_DENIED); | |
| 587 | + | |
| 588 | + case META_FAT_TOO_MANY_FILES: | |
| 589 | + return M2S(META_FAT_TOO_MANY_FILES); | |
| 590 | + | |
| 591 | + case META_INCORRECT_TARGET_VER: | |
| 592 | + return M2S(META_INCORRECT_TARGET_VER); | |
| 593 | + | |
| 594 | + case META_COM_ERROR: | |
| 595 | + return M2S(META_COM_ERROR); | |
| 596 | + | |
| 597 | + case META_BROM_CMD_ERROR: | |
| 598 | + return M2S(META_BROM_CMD_ERROR); | |
| 599 | + | |
| 600 | + case META_INCORRECT_BBCHIP_TYPE: | |
| 601 | + return M2S(META_INCORRECT_BBCHIP_TYPE); | |
| 602 | + | |
| 603 | + case META_BROM_ERROR: | |
| 604 | + return M2S(META_BROM_ERROR); | |
| 605 | + | |
| 606 | + case META_STOP_BOOTUP_PROCEDURE: | |
| 607 | + return M2S(META_STOP_BOOTUP_PROCEDURE); | |
| 608 | + | |
| 609 | + case META_CANCEL: | |
| 610 | + return M2S(META_CANCEL); | |
| 611 | + | |
| 612 | + case META_FUNC_NOT_IMPLEMENT_YET: | |
| 613 | + return M2S(META_FUNC_NOT_IMPLEMENT_YET); | |
| 614 | + | |
| 615 | + case META_FAT_APP_QUOTA_FULL: | |
| 616 | + return M2S(META_FAT_APP_QUOTA_FULL); | |
| 617 | + | |
| 618 | + case META_IMEI_CD_ERROR: | |
| 619 | + return M2S(META_IMEI_CD_ERROR); | |
| 620 | + | |
| 621 | + case META_RFID_MISMATCH: | |
| 622 | + return M2S(META_RFID_MISMATCH); | |
| 623 | + | |
| 624 | + case META_NVRAM_DB_IS_NOT_LOADED_YET: | |
| 625 | + return M2S(META_NVRAM_DB_IS_NOT_LOADED_YET); | |
| 626 | + | |
| 627 | + case META_WAIT_FOR_TARGET_READY_TIMEOUT: | |
| 628 | + return M2S(META_WAIT_FOR_TARGET_READY_TIMEOUT); | |
| 629 | + | |
| 630 | + case META_ERR_EXCEED_MAX_PEER_BUF_SIZE: | |
| 631 | + return M2S(META_ERR_EXCEED_MAX_PEER_BUF_SIZE); | |
| 632 | + | |
| 633 | + case META_BROM_SECURITY_CHECK_FAIL: | |
| 634 | + return M2S(META_BROM_SECURITY_CHECK_FAIL); | |
| 635 | + | |
| 636 | + case META_MAUI_DB_INCONSISTENT: | |
| 637 | + return M2S(META_MAUI_DB_INCONSISTENT); | |
| 638 | + | |
| 639 | + case META_FAT_FILEPATH_TOO_LONG: | |
| 640 | + return M2S(META_FAT_FILEPATH_TOO_LONG); | |
| 641 | + | |
| 642 | + case META_FAT_RESTRICTED_FILEPATH: | |
| 643 | + return M2S(META_FAT_RESTRICTED_FILEPATH); | |
| 644 | + | |
| 645 | + case META_FAT_DIR_NOT_EXIST: | |
| 646 | + return M2S(META_FAT_DIR_NOT_EXIST); | |
| 647 | + | |
| 648 | + case META_FAT_DISK_SPACE_IS_NOT_ENOUGH: | |
| 649 | + return M2S(META_FAT_DISK_SPACE_IS_NOT_ENOUGH); | |
| 650 | + | |
| 651 | + case META_TDMB_ERR_BAND_NOT_EXIST: | |
| 652 | + return M2S(META_TDMB_ERR_BAND_NOT_EXIST); | |
| 653 | + | |
| 654 | + case META_TDMB_ERR_FREQ_NOT_EXIST: | |
| 655 | + return M2S(META_TDMB_ERR_FREQ_NOT_EXIST); | |
| 656 | + | |
| 657 | + case META_TDMB_ERR_ENSM_NOT_EXIST: | |
| 658 | + return M2S(META_TDMB_ERR_ENSM_NOT_EXIST); | |
| 659 | + | |
| 660 | + case META_TDMB_ERR_SERV_NOT_EXIST: | |
| 661 | + return M2S(META_TDMB_ERR_SERV_NOT_EXIST); | |
| 662 | + | |
| 663 | + case META_TDMB_ERR_SUB_CHAN_NOT_EXIST: | |
| 664 | + return M2S(META_TDMB_ERR_SUB_CHAN_NOT_EXIST); | |
| 665 | + | |
| 666 | + case META_TDMB_ERR_DEMOD_STATE: | |
| 667 | + return M2S(META_TDMB_ERR_DEMOD_STATE); | |
| 668 | + | |
| 669 | + case META_ENUMERATE_USB_FAIL: | |
| 670 | + return M2S(META_ENUMERATE_USB_FAIL); | |
| 671 | + | |
| 672 | + case META_STOP_ENUM_USB_PROCEDURE: | |
| 673 | + return M2S(META_STOP_ENUM_USB_PROCEDURE); | |
| 674 | + | |
| 675 | + case META_MISC_TARGET_LOAD_NEED_TO_BE_PATCHED: | |
| 676 | + return M2S(META_MISC_TARGET_LOAD_NEED_TO_BE_PATCHED); | |
| 677 | + | |
| 678 | + case META_MISC_INI_FILE_SETTINGS_WRONG: | |
| 679 | + return M2S(META_MISC_INI_FILE_SETTINGS_WRONG); | |
| 680 | + | |
| 681 | + case META_MISC_FAIL_TO_READ_IMEI: | |
| 682 | + return M2S(META_MISC_FAIL_TO_READ_IMEI); | |
| 683 | + | |
| 684 | + case META_MISC_FAIL_TO_BACKUP_FILE: | |
| 685 | + return M2S(META_MISC_FAIL_TO_BACKUP_FILE); | |
| 686 | + | |
| 687 | + case META_MISC_FAIL_TO_WRITE_BACKUP_RESULT: | |
| 688 | + return M2S(META_MISC_FAIL_TO_WRITE_BACKUP_RESULT); | |
| 689 | + | |
| 690 | + case META_MISC_FAIL_TO_GET_NVRAM_FOLDER_PATH: | |
| 691 | + return M2S(META_MISC_FAIL_TO_GET_NVRAM_FOLDER_PATH); | |
| 692 | + | |
| 693 | + case META_MISC_FAIL_TO_GET_NVRAM_MUST_LIST: | |
| 694 | + return M2S(META_MISC_FAIL_TO_GET_NVRAM_MUST_LIST); | |
| 695 | + | |
| 696 | + case META_STOP_CURRENT_PROCEDURE: | |
| 697 | + return M2S(META_STOP_CURRENT_PROCEDURE); | |
| 698 | + | |
| 699 | + case META_MISC_CUSTOMIZED_NVRAM_ERROR: | |
| 700 | + return M2S(META_MISC_CUSTOMIZED_NVRAM_ERROR); | |
| 701 | + | |
| 702 | + case META_MISC_FOLDER_EMPTY_CHECKING_FAIL: | |
| 703 | + return M2S(META_MISC_FOLDER_EMPTY_CHECKING_FAIL); | |
| 704 | + | |
| 705 | + case META_MISC_TOO_MANY_BACKUP_RESULT_FILE: | |
| 706 | + return M2S(META_MISC_TOO_MANY_BACKUP_RESULT_FILE); | |
| 707 | + | |
| 708 | + case META_MISC_TOO_MANY_RESTORE_RESULT_FILE: | |
| 709 | + return M2S(META_MISC_TOO_MANY_RESTORE_RESULT_FILE); | |
| 710 | + | |
| 711 | + case META_MISC_RESTORE_RESULT_FILE_NOT_EXIST: | |
| 712 | + return M2S(META_MISC_RESTORE_RESULT_FILE_NOT_EXIST); | |
| 713 | + | |
| 714 | + case META_MISC_RESTORE_RESULT_FILE_INCOMPLETE: | |
| 715 | + return M2S(META_MISC_RESTORE_RESULT_FILE_INCOMPLETE); | |
| 716 | + | |
| 717 | + case META_FAIL_TO_CELAR_ALL_IN_BACUP_FOLDER: | |
| 718 | + return M2S(META_FAIL_TO_CELAR_ALL_IN_BACUP_FOLDER); | |
| 719 | + | |
| 720 | + case META_MISC_BACKUP_RESULT_FILE_NOT_EXIST: | |
| 721 | + return M2S(META_MISC_BACKUP_RESULT_FILE_NOT_EXIST); | |
| 722 | + | |
| 723 | + case META_MISC_BACKUP_RESULT_FILE_INCOMPLETE: | |
| 724 | + return M2S(META_MISC_BACKUP_RESULT_FILE_INCOMPLETE); | |
| 725 | + | |
| 726 | + case META_MISC_IMEI_MISMATCH: | |
| 727 | + return M2S(META_MISC_IMEI_MISMATCH); | |
| 728 | + | |
| 729 | + case META_MISC_SML_FILE_VERIFY_FAIL: | |
| 730 | + return M2S(META_MISC_SML_FILE_VERIFY_FAIL); | |
| 731 | + | |
| 732 | + case META_MISC_BACKUP_RESULT_NOT_ENOUGH_FOR_NEW_LOAD: | |
| 733 | + return M2S(META_MISC_BACKUP_RESULT_NOT_ENOUGH_FOR_NEW_LOAD); | |
| 734 | + | |
| 735 | + case META_MISC_FAIL_TO_RESTORE_FILE: | |
| 736 | + return M2S(META_MISC_FAIL_TO_RESTORE_FILE); | |
| 737 | + | |
| 738 | + case META_MISC_FAIL_TO_WRITE_RESTORE_RESULT: | |
| 739 | + return M2S(META_MISC_FAIL_TO_WRITE_RESTORE_RESULT); | |
| 740 | + | |
| 741 | + case META_MISC_USE_WRONG_API_FOR_NEW_LOAD: | |
| 742 | + return M2S(META_MISC_USE_WRONG_API_FOR_NEW_LOAD); | |
| 743 | + | |
| 744 | + case META_MISC_QUERY_TARGET_CAPABILITY_FAIL: | |
| 745 | + return M2S(META_MISC_QUERY_TARGET_CAPABILITY_FAIL); | |
| 746 | + | |
| 747 | + case META_MISC_INI_SETTINGS_ERR_IN_NVRAM_SEC: | |
| 748 | + return M2S(META_MISC_INI_SETTINGS_ERR_IN_NVRAM_SEC); | |
| 749 | + | |
| 750 | + case META_MISC_INI_SETTINGS_ERR_IN_TARGET_SEC: | |
| 751 | + return M2S(META_MISC_INI_SETTINGS_ERR_IN_TARGET_SEC); | |
| 752 | + | |
| 753 | + case META_MISC_INI_SETTINGS_ERR_IN_PC_SEC: | |
| 754 | + return M2S(META_MISC_INI_SETTINGS_ERR_IN_PC_SEC); | |
| 755 | + | |
| 756 | + case META_MISC_NO_FILES_NEED_TO_BE_UPLOAD: | |
| 757 | + return M2S(META_MISC_NO_FILES_NEED_TO_BE_UPLOAD); | |
| 758 | + | |
| 759 | + case META_FAT_ACTION_NOT_SUPPORT: | |
| 760 | + return M2S(META_FAT_ACTION_NOT_SUPPORT); | |
| 761 | + | |
| 762 | + case META_MISC_EMPTY_UPLOADFILES_AND_IMEI_SEC: | |
| 763 | + return M2S(META_MISC_EMPTY_UPLOADFILES_AND_IMEI_SEC); | |
| 764 | + | |
| 765 | + case META_MISC_INI_SETTINGS_ERR_IN_MORE_SEC: | |
| 766 | + return M2S(META_MISC_INI_SETTINGS_ERR_IN_MORE_SEC); | |
| 767 | + | |
| 768 | + case META_MISC_INI_SETTINGS_ERR_IN_DELETE_SEC: | |
| 769 | + return M2S(META_MISC_INI_SETTINGS_ERR_IN_DELETE_SEC); | |
| 770 | + | |
| 771 | + case META_MISC_CHECK_TARGET_NVRAM_FILES_FAIL: | |
| 772 | + return M2S(META_MISC_CHECK_TARGET_NVRAM_FILES_FAIL); | |
| 773 | + | |
| 774 | + case META_MISC_FAIL_TO_GET_NVRAM_FOLDER_AMOUNT: | |
| 775 | + return M2S(META_MISC_FAIL_TO_GET_NVRAM_FOLDER_AMOUNT); | |
| 776 | + | |
| 777 | + case META_AUDIO_CHECK_WAVE_FILE_FAIL: | |
| 778 | + return M2S(META_AUDIO_CHECK_WAVE_FILE_FAIL); | |
| 779 | + | |
| 780 | + case META_MISC_COLLECT_NVRAM_FOLDER_FILES_FAILED: | |
| 781 | + return M2S(META_MISC_COLLECT_NVRAM_FOLDER_FILES_FAILED); | |
| 782 | + | |
| 783 | + case META_MISC_COLLECT_NVRAM_FOLDER_FILES_FIRST: | |
| 784 | + return M2S(META_MISC_COLLECT_NVRAM_FOLDER_FILES_FIRST); | |
| 785 | + | |
| 786 | + case META_MISC_BACKUP_FILE_NOT_FOUND_IN_NVRAM: | |
| 787 | + return M2S(META_MISC_BACKUP_FILE_NOT_FOUND_IN_NVRAM); | |
| 788 | + | |
| 789 | + case META_MISC_BACKUP_MORE_FILE_NOT_FOUND_IN_NVRAM: | |
| 790 | + return M2S(META_MISC_BACKUP_MORE_FILE_NOT_FOUND_IN_NVRAM); | |
| 791 | + | |
| 792 | + case META_MISC_LOCAL_FS_UNKNOWN_ERROR: | |
| 793 | + return M2S(META_MISC_LOCAL_FS_UNKNOWN_ERROR); | |
| 794 | + | |
| 795 | + case META_MISC_RETORE_FILE_NOT_FOUND_IN_BACKUP_RESULT: | |
| 796 | + return M2S(META_MISC_RETORE_FILE_NOT_FOUND_IN_BACKUP_RESULT); | |
| 797 | + | |
| 798 | + case META_MISC_LEGACY_ADC_FILE_NOT_FOUND: | |
| 799 | + return M2S(META_MISC_LEGACY_ADC_FILE_NOT_FOUND); | |
| 800 | + | |
| 801 | + case META_MISC_LEGACY_BARCODE_FILE_NOT_FOUND: | |
| 802 | + return M2S(META_MISC_LEGACY_BARCODE_FILE_NOT_FOUND); | |
| 803 | + | |
| 804 | + case META_MISC_FILE_SIZE_MISMATCH: | |
| 805 | + return M2S(META_MISC_FILE_SIZE_MISMATCH); | |
| 806 | + | |
| 807 | + case META_MISC_RESTORE_TARGET_NOT_FOUND_IN_NVRAM: | |
| 808 | + return M2S(META_MISC_RESTORE_TARGET_NOT_FOUND_IN_NVRAM); | |
| 809 | + | |
| 810 | + case META_UTIL_CONVERT_MULTIBYTE_TO_WCHAR_FAILED: | |
| 811 | + return M2S(META_UTIL_CONVERT_MULTIBYTE_TO_WCHAR_FAILED); | |
| 812 | + | |
| 813 | + case META_FAT_RECURSIVE_CREATE_FOLDER_FAILED: | |
| 814 | + return M2S(META_FAT_RECURSIVE_CREATE_FOLDER_FAILED); | |
| 815 | + | |
| 816 | + case META_FAT_COPY_INVALID_SOURCE_FOLDER: | |
| 817 | + return M2S(META_FAT_COPY_INVALID_SOURCE_FOLDER); | |
| 818 | + | |
| 819 | + case META_FAT_COPY_EMPTY_SOURCE_FOLDER: | |
| 820 | + return M2S(META_FAT_COPY_EMPTY_SOURCE_FOLDER); | |
| 821 | + | |
| 822 | + case META_MISC_MULTIPLE_ENTRY_NOT_SUPPORTED: | |
| 823 | + return M2S(META_MISC_MULTIPLE_ENTRY_NOT_SUPPORTED); | |
| 824 | + | |
| 825 | + case META_MISC_INVALID_FORMAT: | |
| 826 | + return M2S(META_MISC_INVALID_FORMAT); | |
| 827 | + | |
| 828 | + case META_FAT_FILE_LENGTH_ZERO: | |
| 829 | + return M2S(META_FAT_FILE_LENGTH_ZERO); | |
| 830 | + | |
| 831 | + case META_MISC_INI_SETTINGS_ERR_IN_PC_FOLDER_SEC: | |
| 832 | + return M2S(META_MISC_INI_SETTINGS_ERR_IN_PC_FOLDER_SEC); | |
| 833 | + | |
| 834 | + case META_PC_FILE_NOT_FOUND: | |
| 835 | + return M2S(META_PC_FILE_NOT_FOUND); | |
| 836 | + | |
| 837 | + case META_MEMBER_FIELD_TYPE_NOT_FOUND: | |
| 838 | + return M2S(META_MEMBER_FIELD_TYPE_NOT_FOUND); | |
| 839 | + | |
| 840 | + case META_MEMBER_FIELD_OFFSET_NOT_FOUND: | |
| 841 | + return M2S(META_MEMBER_FIELD_OFFSET_NOT_FOUND); | |
| 842 | + | |
| 843 | + case META_NVRAM_GET_KEY_LENGTH_CALLBACK_ERROR: | |
| 844 | + return M2S(META_NVRAM_GET_KEY_LENGTH_CALLBACK_ERROR); | |
| 845 | + | |
| 846 | + case META_NVRAM_ALLOCATE_KEY_BUFFER_ERROR: | |
| 847 | + return M2S(META_NVRAM_ALLOCATE_KEY_BUFFER_ERROR); | |
| 848 | + | |
| 849 | + case META_NVRAM_GET_KEY_BUFFER_CALLBACK_ERROR: | |
| 850 | + return M2S(META_NVRAM_GET_KEY_BUFFER_CALLBACK_ERROR); | |
| 851 | + | |
| 852 | + case META_NVRAM_KEY_ENTRY_MISSING: | |
| 853 | + return M2S(META_NVRAM_KEY_ENTRY_MISSING); | |
| 854 | + | |
| 855 | + case META_NVRAM_KEY_ENTRY_ERROR: | |
| 856 | + return M2S(META_NVRAM_KEY_ENTRY_ERROR); | |
| 857 | + | |
| 858 | + case META_NVRAM_KEY_LENGTH_EXCEEDS_INTERNAL_BUFFER: | |
| 859 | + return M2S(META_NVRAM_KEY_LENGTH_EXCEEDS_INTERNAL_BUFFER); | |
| 860 | + | |
| 861 | + case META_FAT_SPACE_SIZE_OVERFLOW: | |
| 862 | + return M2S(META_FAT_SPACE_SIZE_OVERFLOW); | |
| 863 | + | |
| 864 | + case META_LIB_INCONSISTENT: | |
| 865 | + return M2S(META_LIB_INCONSISTENT); | |
| 866 | + | |
| 867 | + case META_INTERNAL_DB_ERROR: | |
| 868 | + return M2S(META_INTERNAL_DB_ERROR); | |
| 869 | + | |
| 870 | + case META_REQUIRED_TOOL_VERSION_CHECK_FAILD: | |
| 871 | + return M2S(META_REQUIRED_TOOL_VERSION_CHECK_FAILD); | |
| 872 | + | |
| 873 | + case META_CROSS_BRANCH_BACKUP_OPEN_FAILED: | |
| 874 | + return M2S(META_CROSS_BRANCH_BACKUP_OPEN_FAILED); | |
| 875 | + | |
| 876 | + case META_CROSS_BRANCH_BACKUP_PARSE_FAILED: | |
| 877 | + return M2S(META_CROSS_BRANCH_BACKUP_PARSE_FAILED); | |
| 878 | + | |
| 879 | + case META_CROSS_BRANCH_BACKUP_FILE_ATT_NOT_MATCH: | |
| 880 | + return M2S(META_CROSS_BRANCH_BACKUP_FILE_ATT_NOT_MATCH); | |
| 881 | + | |
| 882 | + case META_NVRAM_VALUE_NOT_LEGAL: | |
| 883 | + return M2S(META_NVRAM_VALUE_NOT_LEGAL); | |
| 884 | + | |
| 885 | + case META_INIT_CONNECTION_STARTED: | |
| 886 | + return M2S(META_INIT_CONNECTION_STARTED); | |
| 887 | + | |
| 888 | + case META_QUERY_NO_MODEM_SUPPORT: | |
| 889 | + return M2S(META_QUERY_NO_MODEM_SUPPORT); | |
| 890 | + | |
| 891 | + case META_MEMBER_FIELD_SIZE_NOT_FOUND: | |
| 892 | + return M2S(META_MEMBER_FIELD_SIZE_NOT_FOUND); | |
| 893 | + | |
| 894 | + case META_LAST_RESULT: | |
| 895 | + return M2S(META_LAST_RESULT); | |
| 896 | + | |
| 897 | + default: | |
| 898 | + return M2S(DEFAULT_FAIL); | |
| 899 | + } | |
| 900 | +} | |
| 901 | + | |
| 902 | +int InitSNIni() | |
| 903 | +{ | |
| 904 | + int initStatus = 0; | |
| 905 | + | |
| 906 | + InitGlobalValue(); | |
| 907 | + | |
| 908 | + RW_SetupFile_Status status = INI_RW_SUCCESS; | |
| 909 | + status = GetParaFromSetupFile(); | |
| 910 | + if (status == INI_RW_SUCCESS) | |
| 911 | + { | |
| 912 | + initStatus = 1; | |
| 913 | + } | |
| 914 | + else | |
| 915 | + { | |
| 916 | + initStatus = 0; | |
| 917 | + } | |
| 918 | + | |
| 919 | + AuthHandle_Init(); | |
| 920 | + | |
| 921 | + return initStatus; | |
| 922 | + | |
| 923 | +} | |
| 924 | + | |
| 925 | +bool AuthHandle_Init() | |
| 926 | +{ | |
| 927 | + bool bAuthHandleInitDone = true; | |
| 928 | + | |
| 929 | + if(REQ_AUTH_Create() == -1) | |
| 930 | + { | |
| 931 | + bAuthHandleInitDone = false; | |
| 932 | + } | |
| 933 | + | |
| 934 | + if(SPATE_AUTH_Create() == false) | |
| 935 | + { | |
| 936 | + bAuthHandleInitDone = false; | |
| 937 | + } | |
| 938 | + | |
| 939 | + if (SPATE_SCERT_Create() == false) | |
| 940 | + { | |
| 941 | + bAuthHandleInitDone = false; | |
| 942 | + } | |
| 943 | + | |
| 944 | + return bAuthHandleInitDone; | |
| 945 | +} | |
| 946 | + | |
| 947 | +void AuthHandle_DeInit() | |
| 948 | +{ | |
| 949 | + REQ_AUTH_Unload (); | |
| 950 | + REQ_AUTH_Destroy (); | |
| 951 | + SPATE_SCERT_Destroy(); | |
| 952 | +} | |
| 953 | + | |
| 954 | +bool AuthInit(const char *strAuthFilePath) | |
| 955 | +{ | |
| 956 | + if (!strAuthFilePath || strlen(strAuthFilePath) == 0) | |
| 957 | + { | |
| 958 | + MTRACE_ERR(g_hEBOOT_DEBUG, "Invalid auth file path!!"); | |
| 959 | + return false; | |
| 960 | + } | |
| 961 | + | |
| 962 | + if(REQ_AUTH_Load(strAuthFilePath) == -1) | |
| 963 | + return false; | |
| 964 | + else | |
| 965 | + return true; | |
| 966 | +} | |
| 967 | + | |
| 968 | +bool SPAuthInit(const char *strSPAuthFilePath) | |
| 969 | +{ | |
| 970 | + if (!strSPAuthFilePath || strlen(strSPAuthFilePath) == 0) | |
| 971 | + { | |
| 972 | + MTRACE_ERR(g_hEBOOT_DEBUG, "Invalid SP auth file path!!"); | |
| 973 | + return false; | |
| 974 | + } | |
| 975 | + | |
| 976 | + return SPATE_AUTH_Load(strSPAuthFilePath); | |
| 977 | + | |
| 978 | +} | |
| 979 | + | |
| 980 | +bool SPScertInit(const char *strSPScertFilePath) | |
| 981 | +{ | |
| 982 | + if (!strSPScertFilePath || strlen(strSPScertFilePath) == 0) | |
| 983 | + { | |
| 984 | + MTRACE_ERR(g_hEBOOT_DEBUG, "Invalid SP Scert file path!!"); | |
| 985 | + return false; | |
| 986 | + } | |
| 987 | + | |
| 988 | + return SPATE_SCERT_Load(strSPScertFilePath); | |
| 989 | +} | |
| 990 | + | |
| 991 | +E_TARGET_TYPE GetTargetType() | |
| 992 | +{ | |
| 993 | + return g_sMetaComm.eTargetType; | |
| 994 | +} | |
| 995 | + | |
| 996 | +bool CheckFileSize( const char *strFilePath, const long fileSize ) | |
| 997 | +{ | |
| 998 | + long size = 0; | |
| 999 | + | |
| 1000 | + FILE *pFile = fopen(strFilePath, "rb"); | |
| 1001 | + if (NULL == pFile ) | |
| 1002 | + { | |
| 1003 | + MTRACE_ERR(g_hEBOOT_DEBUG, "Execution Failure: Open data file error!!"); | |
| 1004 | + return false; | |
| 1005 | + } | |
| 1006 | + | |
| 1007 | + size = GetFilesize(pFile); | |
| 1008 | + if (size != fileSize) | |
| 1009 | + { | |
| 1010 | + MTRACE_ERR(g_hEBOOT_DEBUG, "Execution Failure: data file size error!!"); | |
| 1011 | + return false; | |
| 1012 | + } | |
| 1013 | + | |
| 1014 | + return true; | |
| 1015 | +} | |
| 1016 | + | |
| 1017 | +long GetFilesize( FILE *fp ) | |
| 1018 | +{ | |
| 1019 | + long int save_pos = 0; | |
| 1020 | + long size_of_file = 0; | |
| 1021 | + | |
| 1022 | + if(fp == NULL) | |
| 1023 | + { | |
| 1024 | + return 0; | |
| 1025 | + } | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + /* Save the current position. */ | |
| 1029 | + save_pos = ftell( fp ); | |
| 1030 | + | |
| 1031 | + /* Jump to the end of the file. */ | |
| 1032 | + fseek( fp, 0L, SEEK_END ); | |
| 1033 | + | |
| 1034 | + /* Get the end position. */ | |
| 1035 | + size_of_file = ftell( fp ); | |
| 1036 | + | |
| 1037 | + /* Jump back to the original position. */ | |
| 1038 | + fseek( fp, save_pos, SEEK_SET ); | |
| 1039 | + | |
| 1040 | + return( size_of_file ); | |
| 1041 | +} | |
| 1042 | + | |
| 1043 | + | |
| 1044 | +Login_Identify_e GetLoginIdentify() | |
| 1045 | +{ | |
| 1046 | + BYTE key[10]="03055030"; | |
| 1047 | + BYTE strPassword[LOGIN_PASSWORD_MAX] = {0}; | |
| 1048 | + Login_Identify_e Identify = UNKNOW_IDENTIFY; | |
| 1049 | + | |
| 1050 | + if(ReadDataFromFile(strPassword, LOGIN_PASSWORD_MAX, key, g_pPasswdFilepath) == S_DES_SUCCESS) | |
| 1051 | + { | |
| 1052 | + if(strPassword[0] == '0' && strPassword[1] == '0') | |
| 1053 | + { | |
| 1054 | + Identify = OPERATOR; | |
| 1055 | + } | |
| 1056 | + else if(strPassword[0] == '0' && strPassword[1] == '1') | |
| 1057 | + { | |
| 1058 | + Identify = ENGINEER; | |
| 1059 | + } | |
| 1060 | + else | |
| 1061 | + { | |
| 1062 | + Identify = UNKNOW_IDENTIFY; | |
| 1063 | + } | |
| 1064 | + } | |
| 1065 | + | |
| 1066 | + return Identify; | |
| 1067 | +} | |
| 1068 | + | |
| 1069 | +UINT SaveLoginPasswd(const char *strPasswd) | |
| 1070 | +{ | |
| 1071 | + bool bRet = false; | |
| 1072 | + BYTE key[10]="03055030"; | |
| 1073 | + int iDatalen=0; | |
| 1074 | + char tmpStr[LOGIN_PASSWORD_MAX+2] = {0}; | |
| 1075 | + char *pTmpStr = tmpStr; | |
| 1076 | + | |
| 1077 | + pTmpStr[0] = '0'; | |
| 1078 | + pTmpStr[1] = '1'; | |
| 1079 | + strncat(pTmpStr, strPasswd, strlen(strPasswd)); | |
| 1080 | + if(WriteDataToFile((unsigned char*)pTmpStr, LOGIN_PASSWORD_MAX, key, g_pPasswdFilepath) == S_DES_SUCCESS) | |
| 1081 | + { | |
| 1082 | + return OK; | |
| 1083 | + } | |
| 1084 | + else | |
| 1085 | + { | |
| 1086 | + return ERROR; | |
| 1087 | + } | |
| 1088 | + | |
| 1089 | +} | |
| 1090 | + | |
| 1091 | +UINT SaveLoginIdentify(const Login_Identify_e identify) | |
| 1092 | +{ | |
| 1093 | + bool bRet = false; | |
| 1094 | + BYTE key[10]="03055030"; | |
| 1095 | + int iDatalen=0; | |
| 1096 | + BYTE tmpStr[LOGIN_PASSWORD_MAX+2] = {0}; | |
| 1097 | + | |
| 1098 | + if(ReadDataFromFile(tmpStr, LOGIN_PASSWORD_MAX, key, g_pPasswdFilepath) == S_DES_SUCCESS) | |
| 1099 | + { | |
| 1100 | + switch(identify) | |
| 1101 | + { | |
| 1102 | + case ENGINEER: | |
| 1103 | + tmpStr[0] = '0'; | |
| 1104 | + tmpStr[1] = '1'; | |
| 1105 | + break; | |
| 1106 | + | |
| 1107 | + case OPERATOR: | |
| 1108 | + tmpStr[0] = '0'; | |
| 1109 | + tmpStr[1] = '0'; | |
| 1110 | + break; | |
| 1111 | + | |
| 1112 | + default: | |
| 1113 | + break; | |
| 1114 | + } | |
| 1115 | + } | |
| 1116 | + else | |
| 1117 | + { | |
| 1118 | + return ERROR; | |
| 1119 | + } | |
| 1120 | + | |
| 1121 | + if(WriteDataToFile((unsigned char*)tmpStr, LOGIN_PASSWORD_MAX, key, g_pPasswdFilepath) == S_DES_SUCCESS) | |
| 1122 | + { | |
| 1123 | + return OK; | |
| 1124 | + } | |
| 1125 | + else | |
| 1126 | + { | |
| 1127 | + return ERROR; | |
| 1128 | + } | |
| 1129 | +} | |
| 1130 | + | |
| 1131 | +void DisableUSBSwitch() | |
| 1132 | +{ | |
| 1133 | + if (g_hSwitchTool != NULL) | |
| 1134 | + { | |
| 1135 | + MTRACE (g_hEBOOT_DEBUG, "SmartPhoneSN::DisableUSBSwitch(): Quit UsbSwitchtool start..."); | |
| 1136 | + DisableUSBSwitch(g_hSwitchTool); | |
| 1137 | + g_hSwitchTool = NULL; | |
| 1138 | + MTRACE (g_hEBOOT_DEBUG, "SmartPhoneSN::DisableUSBSwitch(): Quit UsbSwitchtool end..."); | |
| 1139 | + } | |
| 1140 | + else | |
| 1141 | + MTRACE (g_hEBOOT_DEBUG, "SmartPhoneSN::DisableUSBSwitch(): Had quit UsbSwitchtool."); | |
| 1142 | +} | |
| 1143 | + | |
| 1144 | +void EnableUSBSwitch() | |
| 1145 | +{ | |
| 1146 | + if(g_hSwitchTool == NULL) | |
| 1147 | + { | |
| 1148 | + MTRACE (g_hEBOOT_DEBUG, "SmartPhoneSN::EnableUSBSwitch(): Enable UsbSwitchtool for dongle project start..."); | |
| 1149 | + g_hSwitchTool = EnableUSBSwitch("-m"); | |
| 1150 | + MTRACE (g_hEBOOT_DEBUG, "SmartPhoneSN::EnableUSBSwitch(): Enable UsbSwitchtool for dongle project end..."); | |
| 1151 | + } | |
| 1152 | + else | |
| 1153 | + MTRACE (g_hEBOOT_DEBUG, "SmartPhoneSN::EnableUSBSwitch(): Had enabled UsbSwitchtool."); | |
| 1154 | +} | |
| 1155 | + | |
| 1156 | +void InitGlobalValue() | |
| 1157 | +{ | |
| 1158 | + memset(&g_sMetaComm, 0, sizeof(META_Common_struct)); | |
| 1159 | + g_sMetaComm.sAuthOption.bAuthenEnable = false; | |
| 1160 | +} | |
| 1161 | + | |
| 1162 | +int GetSNSetupFilePath() | |
| 1163 | +{ | |
| 1164 | + memset(&g_pSetupFilepath, 0, MAX_PATH); | |
| 1165 | + memset(&g_pPasswdFilepath, 0, MAX_PATH); | |
| 1166 | + | |
| 1167 | + char FolderPath[MAX_PATH]; | |
| 1168 | + char FileFullPath[MAX_PATH]; | |
| 1169 | + | |
| 1170 | + GetCurrentDirectory( MAX_PATH, FolderPath ); | |
| 1171 | + | |
| 1172 | + sprintf(FileFullPath, "%s\\%s", FolderPath, "SN_Setup.ini"); | |
| 1173 | + if (strlen(FileFullPath) == 0) | |
| 1174 | + { | |
| 1175 | + return ERROR; | |
| 1176 | + } | |
| 1177 | + memcpy(g_pSetupFilepath, FileFullPath, strlen(FileFullPath)+1); | |
| 1178 | + | |
| 1179 | +#ifdef _AUTO_GEN_FEATURE_ | |
| 1180 | + sprintf(FileFullPath, "%s\\%s", FolderPath, "SN_AutoGen.ini"); | |
| 1181 | + if (strlen(FileFullPath) == 0) | |
| 1182 | + { | |
| 1183 | + return ERROR; | |
| 1184 | + } | |
| 1185 | + memcpy(g_pAutoGenSetupFilepath, FileFullPath, strlen(FileFullPath)+1); | |
| 1186 | +#endif | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + sprintf(FileFullPath, "%s\\%s", FolderPath, "SNDATA"); | |
| 1190 | + if (strlen(FileFullPath) == 0) | |
| 1191 | + { | |
| 1192 | + return ERROR; | |
| 1193 | + } | |
| 1194 | + memcpy(g_pPasswdFilepath, FileFullPath, strlen(FileFullPath)+1); | |
| 1195 | + | |
| 1196 | + return OK; | |
| 1197 | +} | |
| 1198 | + | |
| 1199 | +RW_SetupFile_Status GetItemParaFromSetupFile(const char *strFilePath, LPCTSTR lpKeyName, void* lpValue, E_INI_DATA_TYPE dataType) | |
| 1200 | +{ | |
| 1201 | + RW_SetupFile_Status readIniStatus; | |
| 1202 | + IniData_struct iniData; | |
| 1203 | + iniData.dataType = dataType; | |
| 1204 | + iniData.pItemKeyWord = lpKeyName; | |
| 1205 | + iniData.pItemData = lpValue; | |
| 1206 | + | |
| 1207 | + readIniStatus = ReadIniItemData(strFilePath, iniData); | |
| 1208 | + return readIniStatus; | |
| 1209 | +} | |
| 1210 | + | |
| 1211 | +RW_SetupFile_Status SaveItemParaToSetupFile(const char *strFilePath, LPCTSTR lpKeyName, void* lpValue, E_INI_DATA_TYPE dataType) | |
| 1212 | +{ | |
| 1213 | + RW_SetupFile_Status writeIniStatus; | |
| 1214 | + IniData_struct iniData; | |
| 1215 | + iniData.dataType = dataType; | |
| 1216 | + iniData.pItemKeyWord = lpKeyName; | |
| 1217 | + iniData.pItemData = lpValue; | |
| 1218 | + | |
| 1219 | + writeIniStatus = WriteIniItemData(strFilePath, iniData); | |
| 1220 | + return writeIniStatus; | |
| 1221 | +} | |
| 1222 | + | |
| 1223 | +RW_SetupFile_Status GetParaFromSetupFile() | |
| 1224 | +{ | |
| 1225 | + RW_SetupFile_Status readIniStatus; | |
| 1226 | + | |
| 1227 | +#ifdef _AUTO_GEN_FEATURE_ | |
| 1228 | + readIniStatus = GetAutoGenParaFromSetupFile(); | |
| 1229 | + if (readIniStatus != INI_RW_SUCCESS) | |
| 1230 | + { | |
| 1231 | + return readIniStatus; | |
| 1232 | + } | |
| 1233 | +#endif | |
| 1234 | + | |
| 1235 | + int size = (sizeof(g_IniData) / sizeof(IniData_struct)); | |
| 1236 | + | |
| 1237 | + readIniStatus = ReadIniData(g_pSetupFilepath, g_IniData, size); | |
| 1238 | + if (readIniStatus != INI_RW_SUCCESS) | |
| 1239 | + { | |
| 1240 | + return readIniStatus; | |
| 1241 | + } | |
| 1242 | + | |
| 1243 | + switch (g_sMetaComm.sIMEIOption.iImeiNums) | |
| 1244 | + { | |
| 1245 | + case ONE_IMEI: | |
| 1246 | + g_sMetaComm.sIMEIOption.bDualIMEI = false; | |
| 1247 | + g_sMetaComm.sIMEIOption.bThreeIMEI = false; | |
| 1248 | + g_sMetaComm.sIMEIOption.bFourIMEI = false; | |
| 1249 | + break; | |
| 1250 | + | |
| 1251 | + case DUAL_IMEI: | |
| 1252 | + g_sMetaComm.sIMEIOption.bDualIMEI = true; | |
| 1253 | + g_sMetaComm.sIMEIOption.bThreeIMEI = false; | |
| 1254 | + g_sMetaComm.sIMEIOption.bFourIMEI = false; | |
| 1255 | + break; | |
| 1256 | + | |
| 1257 | + case THREE_IMEI: | |
| 1258 | + g_sMetaComm.sIMEIOption.bDualIMEI = false; | |
| 1259 | + g_sMetaComm.sIMEIOption.bThreeIMEI = true; | |
| 1260 | + g_sMetaComm.sIMEIOption.bFourIMEI = false; | |
| 1261 | + break; | |
| 1262 | + | |
| 1263 | + case FOUR_IMEI: | |
| 1264 | + g_sMetaComm.sIMEIOption.bDualIMEI = false; | |
| 1265 | + g_sMetaComm.sIMEIOption.bThreeIMEI = false; | |
| 1266 | + g_sMetaComm.sIMEIOption.bFourIMEI = true; | |
| 1267 | + break; | |
| 1268 | + | |
| 1269 | + default: | |
| 1270 | + g_sMetaComm.sIMEIOption.bDualIMEI = false; | |
| 1271 | + g_sMetaComm.sIMEIOption.bThreeIMEI = false; | |
| 1272 | + g_sMetaComm.sIMEIOption.bFourIMEI = false; | |
| 1273 | + break; | |
| 1274 | + } | |
| 1275 | + | |
| 1276 | + if (!g_sMetaComm.bEnableLockOtp) | |
| 1277 | + g_sMetaComm.sIMEIOption.bLockOtp = false; | |
| 1278 | + | |
| 1279 | + return INI_RW_SUCCESS; | |
| 1280 | +} | |
| 1281 | + | |
| 1282 | +RW_SetupFile_Status SaveParaToSetupFile() | |
| 1283 | +{ | |
| 1284 | + RW_SetupFile_Status writeIniStatus; | |
| 1285 | +#ifdef _AUTO_GEN_FEATURE_ | |
| 1286 | + writeIniStatus = SaveAutoGenParaToSetupFile(); | |
| 1287 | + if (writeIniStatus != INI_RW_SUCCESS) | |
| 1288 | + { | |
| 1289 | + return writeIniStatus; | |
| 1290 | + } | |
| 1291 | +#endif | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + int size = (sizeof(g_IniData) / sizeof(IniData_struct)); | |
| 1295 | + | |
| 1296 | + writeIniStatus = WriteIniData(g_pSetupFilepath, g_IniData, size); | |
| 1297 | + | |
| 1298 | + return writeIniStatus; | |
| 1299 | +} | |
| 1300 | + | |
| 1301 | +#ifdef _AUTO_GEN_FEATURE_ | |
| 1302 | +RW_SetupFile_Status GetAutoGenParaFromSetupFile() | |
| 1303 | +{ | |
| 1304 | + RW_SetupFile_Status readIniStatus; | |
| 1305 | + int genSize = (sizeof(g_AutoGenSetup) / sizeof(IniData_struct)); | |
| 1306 | + readIniStatus = ReadIniData(g_pAutoGenSetupFilepath, g_AutoGenSetup, genSize); | |
| 1307 | + return readIniStatus; | |
| 1308 | +} | |
| 1309 | + | |
| 1310 | +RW_SetupFile_Status SaveAutoGenParaToSetupFile() | |
| 1311 | +{ | |
| 1312 | + RW_SetupFile_Status writeIniStatus; | |
| 1313 | + int genSize = (sizeof(g_AutoGenSetup) / sizeof(IniData_struct)); | |
| 1314 | + writeIniStatus = WriteIniData(g_pAutoGenSetupFilepath, g_AutoGenSetup, genSize); | |
| 1315 | + return writeIniStatus; | |
| 1316 | +} | |
| 1317 | + | |
| 1318 | +RW_SetupFile_Status UpdateAutoGenParaToSetupFile() | |
| 1319 | +{ | |
| 1320 | + AutoGenResult_e genResult = AutoGen_Success; | |
| 1321 | + | |
| 1322 | + if (g_sMetaComm.sWriteOption.bWriteBarcode && g_AutoGenData.bAutoGenBarcode) | |
| 1323 | + { | |
| 1324 | + if (g_AutoGenData.eIncreaseRadix == HEX_RADIX) | |
| 1325 | + { | |
| 1326 | + genResult = AutoIncrease(AutoGen_Barcode, g_AutoGenData.sBarcode.iStep, g_AutoGenData.sBarcode.Next, BARCODE_ARRAY_LEN); | |
| 1327 | + } | |
| 1328 | + else if (g_AutoGenData.eIncreaseRadix == DENARY_RADIX) | |
| 1329 | + { | |
| 1330 | + genResult = AutoIncrease_Ex(AutoGen_Barcode, g_AutoGenData.sBarcode.iStep, g_AutoGenData.sBarcode.Next, BARCODE_ARRAY_LEN, AutoGen_BARC_DENARY_OPTION); | |
| 1331 | + } | |
| 1332 | + | |
| 1333 | + if (genResult == AutoGen_Success) | |
| 1334 | + { | |
| 1335 | + SaveItemParaToSetupFile(g_pAutoGenSetupFilepath, "Barcode Next", g_AutoGenData.sBarcode.Next, INI_STRING); | |
| 1336 | + } | |
| 1337 | + } | |
| 1338 | + | |
| 1339 | + if (g_sMetaComm.sWriteOption.bWriteIMEI && g_AutoGenData.bAutoGenIMEI) | |
| 1340 | + { | |
| 1341 | + if (g_sMetaComm.sIMEIOption.bCheckSum) | |
| 1342 | + { | |
| 1343 | + genResult = AutoIncrease_Ex(AutoGen_IMEI, g_AutoGenData.sIMEI.iStep, g_AutoGenData.sIMEI.Next, IMEI_ARRAY_LEN, AutoGen_IMEI_CHECKSUM_OPTION); | |
| 1344 | + } | |
| 1345 | + else | |
| 1346 | + { | |
| 1347 | + genResult = AutoIncrease(AutoGen_IMEI, g_AutoGenData.sIMEI.iStep, g_AutoGenData.sIMEI.Next, IMEI_ARRAY_LEN); | |
| 1348 | + } | |
| 1349 | + | |
| 1350 | + if (genResult == AutoGen_Success) | |
| 1351 | + { | |
| 1352 | + SaveItemParaToSetupFile(g_pAutoGenSetupFilepath, "IMEI Next", g_AutoGenData.sIMEI.Next, INI_STRING); | |
| 1353 | + } | |
| 1354 | + } | |
| 1355 | + | |
| 1356 | + if (g_sMetaComm.sWriteOption.bWriteBT && g_AutoGenData.bAutoGenBT) | |
| 1357 | + { | |
| 1358 | + genResult = AutoIncrease(AutoGen_BT, g_AutoGenData.sBtAddress.iStep, g_AutoGenData.sBtAddress.Next, BT_ARRAY_LEN); | |
| 1359 | + if (genResult == AutoGen_Success) | |
| 1360 | + { | |
| 1361 | + SaveItemParaToSetupFile(g_pAutoGenSetupFilepath, "BT Next", g_AutoGenData.sBtAddress.Next, INI_STRING); | |
| 1362 | + } | |
| 1363 | + } | |
| 1364 | + | |
| 1365 | + if (g_sMetaComm.sWriteOption.bWriteWifi && g_AutoGenData.bAutoGenWifi) | |
| 1366 | + { | |
| 1367 | + genResult = AutoIncrease(AutoGen_Wifi, g_AutoGenData.sWifiAddress.iStep, g_AutoGenData.sWifiAddress.Next, WIFI_ARRAY_LEN); | |
| 1368 | + if (genResult == AutoGen_Success) | |
| 1369 | + { | |
| 1370 | + SaveItemParaToSetupFile(g_pAutoGenSetupFilepath, "Wifi Next", g_AutoGenData.sWifiAddress.Next, INI_STRING); | |
| 1371 | + } | |
| 1372 | + } | |
| 1373 | + | |
| 1374 | + if (g_sMetaComm.sWriteOption.bWriteEthernetMac && g_AutoGenData.bAutoGenEthernet) | |
| 1375 | + { | |
| 1376 | + genResult = AutoIncrease(AutoGen_Ethernet, g_AutoGenData.sEthernetAddress.iStep, g_AutoGenData.sEthernetAddress.Next, ETHERNET_MAC_ARRAY_LEN); | |
| 1377 | + if (genResult == AutoGen_Success) | |
| 1378 | + { | |
| 1379 | + SaveItemParaToSetupFile(g_pAutoGenSetupFilepath, "Ethernet Next", g_AutoGenData.sEthernetAddress.Next, INI_STRING); | |
| 1380 | + } | |
| 1381 | + } | |
| 1382 | + | |
| 1383 | + if (g_sMetaComm.sWriteOption.bWriteDrmkeyMCID && g_AutoGenData.bAutoGenDRMKeyMCID) | |
| 1384 | + { | |
| 1385 | + genResult = AutoIncrease(AutoGen_DRMKeyMCID, g_AutoGenData.sDRMKeyMCID.iStep, g_AutoGenData.sDRMKeyMCID.Next, DRMKEY_MCID_ARRAY_LEN); | |
| 1386 | + if (genResult == AutoGen_Success) | |
| 1387 | + { | |
| 1388 | + SaveItemParaToSetupFile(g_pAutoGenSetupFilepath, "DRMKey MCID Next", g_AutoGenData.sDRMKeyMCID.Next, INI_STRING); | |
| 1389 | + } | |
| 1390 | + } | |
| 1391 | + | |
| 1392 | + return INI_RW_SUCCESS; | |
| 1393 | +} | |
| 1394 | +#endif | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | ... | ... |
Common/Common.h
0 → 100644
| 1 | +#ifndef _SN_COMMON_H_ | |
| 2 | +#define _SN_COMMON_H_ | |
| 3 | + | |
| 4 | +#include "flashtool_handle.h" | |
| 5 | +#include "SNFstream.h" | |
| 6 | +#include "SLA.h" | |
| 7 | +#include "AUTH.h" | |
| 8 | +#include "SCERT.h" | |
| 9 | +#include "meta.h" | |
| 10 | + | |
| 11 | + | |
| 12 | +#if defined(_WIN32) | |
| 13 | +#include <windows.h> | |
| 14 | +#elif defined(__GNUC__) | |
| 15 | +typedef int HANDLE; | |
| 16 | +#endif | |
| 17 | + | |
| 18 | +#define M2S(x) #x | |
| 19 | + | |
| 20 | +#define ERROR 0 | |
| 21 | +#define OK 1 | |
| 22 | +#define MAX_LOG_LENGTH 1024 | |
| 23 | + | |
| 24 | +#define INVALID_META_HANDLE -1 | |
| 25 | +#define MAX_SUPPORT_COMPORT_NUM 4 | |
| 26 | + | |
| 27 | +#define META_CONNECT_TIME_OUT 80000 //30000 | |
| 28 | +#define META_BOOT_TIMERS 3 | |
| 29 | +#define META_BOOT_STOP 9876 | |
| 30 | +#define SP_DEFAULT_BROM_START_CMD_RETRY_COUNT 1 | |
| 31 | + | |
| 32 | +#define HEADER_MAX_LENGTH 8 | |
| 33 | +#define MAX_IMEI_NUMS 4 | |
| 34 | +#define IMEI_MAX_LENGTH 15 | |
| 35 | +#define IMEI_ARRAY_LEN (IMEI_MAX_LENGTH + 1) | |
| 36 | +#define BARCODE_MAX_LENGTH 64 | |
| 37 | +#define BARCODE_ARRAY_LEN BARCODE_MAX_LENGTH+1 | |
| 38 | +#define BD_ADDR_LEN 6 | |
| 39 | +#define BT_ADDRESS_MAX_LENGTH ( BD_ADDR_LEN * 2 ) | |
| 40 | +#define BT_ARRAY_LEN ( BT_ADDRESS_MAX_LENGTH + 1 ) | |
| 41 | +#define SERIAL_NO_LEN 19 | |
| 42 | +#define SERIAL_NO_BUF_LEN (SERIAL_NO_LEN + 1) | |
| 43 | +/* | |
| 44 | +#define VENDOR_ID_LEN 6 | |
| 45 | +#define VENDOR_ID_MAX_LENGTH (VENDOR_ID_LEN *2) | |
| 46 | +#define VENDOR_ARRAY_LEN (VENDOR_ID_MAX_LENGTH + 1) | |
| 47 | +*/ | |
| 48 | +#define MAC_ADDR_LEN 6 | |
| 49 | +#define WIFI_MAC_MAX_LENGTH ( MAC_ADDR_LEN * 2 ) | |
| 50 | +#define WIFI_ARRAY_LEN ( WIFI_MAC_MAX_LENGTH + 1) | |
| 51 | +#define EEPROM_SIZE 512 | |
| 52 | +#define ETHERNET_MAC_ARRAY_LEN (WIFI_ARRAY_LEN) | |
| 53 | +#define DRMKEY_MCID_LENGTH 32 | |
| 54 | +#define DRMKEY_MCID_ARRAY_LEN (DRMKEY_MCID_LENGTH + 1) | |
| 55 | + | |
| 56 | +#define MEID_LENGTH 14 | |
| 57 | +#define MEID_ARRAY_LEN (MEID_LENGTH + 1) | |
| 58 | +#define ESN_LENGTH 8 | |
| 59 | +#define ESN_ARRAY_LEN (ESN_LENGTH + 1) | |
| 60 | + | |
| 61 | +//#define THREAD_SCAN_DATA | |
| 62 | +//#define WM_RESIZEPAGE WM_APP+1 | |
| 63 | +#define LOGIN_PASSWORD_MAX 64 | |
| 64 | + | |
| 65 | +typedef enum | |
| 66 | +{ | |
| 67 | + ENGINEER = 0, | |
| 68 | + OPERATOR = 1, | |
| 69 | + UNKNOW_IDENTIFY = 256 | |
| 70 | +}Login_Identify_e; | |
| 71 | + | |
| 72 | +typedef enum | |
| 73 | +{ | |
| 74 | + DENARY_RADIX = 0, //Denary notation | |
| 75 | + HEX_RADIX //Hexadecimal | |
| 76 | +}Radix_e; | |
| 77 | + | |
| 78 | +enum | |
| 79 | +{ | |
| 80 | + CDF_CENTER, | |
| 81 | + CDF_TOPLEFT, | |
| 82 | +}; | |
| 83 | + | |
| 84 | +typedef enum | |
| 85 | +{ | |
| 86 | + BUSY = 0, | |
| 87 | + FREE = 1 | |
| 88 | +}Thread_Resource_Status_e; | |
| 89 | + | |
| 90 | +typedef enum | |
| 91 | +{ | |
| 92 | + FAIL = 0, | |
| 93 | + PASS = 1, | |
| 94 | + CANCEL = 2, | |
| 95 | + NORMAL = 255 | |
| 96 | +}WriteNvram_Status_e; | |
| 97 | + | |
| 98 | +typedef enum | |
| 99 | +{ | |
| 100 | + WRITE_BARCODE = 0, | |
| 101 | + WRITE_IMEI, | |
| 102 | + WRITE_BT, | |
| 103 | + WRITE_WIFI, | |
| 104 | + WRITE_ETHERNET_MAC, | |
| 105 | + WRITE_PRODINFO, | |
| 106 | + WRITE_TEMPERATURE, | |
| 107 | + WRITE_MEID, | |
| 108 | + WRITE_ESN | |
| 109 | + // WRITE_VENDORID //20141021 BY MENGXU | |
| 110 | +}WriteData_Type_e; | |
| 111 | + | |
| 112 | +typedef enum | |
| 113 | +{ | |
| 114 | + CAL_FLAG_PASS = 0, | |
| 115 | + CAL_FLAG_FAILED = 1, | |
| 116 | + CAL_FLAG_NOT_EXIST = 2, | |
| 117 | +}CheckCalFlag_Status_e; | |
| 118 | + | |
| 119 | +typedef enum | |
| 120 | +{ | |
| 121 | + FT_FLAG_PASS = 0, | |
| 122 | + FT_FLAG_FAILED = 1, | |
| 123 | + FT_FLAG_NOT_EXIST = 2, | |
| 124 | +}CheckFinalTestFlag_Status_e; | |
| 125 | + | |
| 126 | + | |
| 127 | +typedef struct | |
| 128 | +{ | |
| 129 | + int iThreadIndex; | |
| 130 | + int iComPort; | |
| 131 | + int iKernelComPort; | |
| 132 | + bool bThreadStart; | |
| 133 | +}Thread_Info_s; | |
| 134 | + | |
| 135 | +typedef struct | |
| 136 | +{ | |
| 137 | + int iComPort; | |
| 138 | + int iKernelComPort; | |
| 139 | + bool bUse; | |
| 140 | +}SPComPort_Info_s; | |
| 141 | + | |
| 142 | +typedef struct | |
| 143 | +{ | |
| 144 | + bool bCheckHeader; | |
| 145 | + char strHeader[HEADER_MAX_LENGTH+1]; | |
| 146 | +}HeaderOption_struct; | |
| 147 | + | |
| 148 | +typedef enum { | |
| 149 | + NONE_IMEI = 0, | |
| 150 | + ONE_IMEI, | |
| 151 | + DUAL_IMEI, | |
| 152 | + THREE_IMEI, | |
| 153 | + FOUR_IMEI | |
| 154 | +} E_IMEI_NUM; | |
| 155 | + | |
| 156 | +typedef struct | |
| 157 | +{ | |
| 158 | + bool bWriteTemperature; | |
| 159 | + char strTemperatureData[10]; | |
| 160 | +}Temperature_Option; | |
| 161 | + | |
| 162 | +typedef struct | |
| 163 | +{ | |
| 164 | + int iImeiNums; | |
| 165 | + bool bDualIMEI; | |
| 166 | + bool bThreeIMEI; | |
| 167 | + bool bFourIMEI; | |
| 168 | + bool bLockIMEI; | |
| 169 | + bool bCheckSum; | |
| 170 | + bool bDualIMEISame; | |
| 171 | + Temperature_Option Temp_Option; | |
| 172 | + bool bLockOtp; | |
| 173 | +}IMEIOption_struct; | |
| 174 | +/* | |
| 175 | +typedef struct | |
| 176 | +{ | |
| 177 | +bool bExtMdDl; | |
| 178 | +}BarcodeOption_struct; | |
| 179 | +*/ | |
| 180 | +typedef struct | |
| 181 | +{ | |
| 182 | + bool bAPDBFromDUT; | |
| 183 | + bool bMDDBFromDUT; | |
| 184 | + bool bDBInitModem_1; | |
| 185 | + bool bDBInitModem_2; | |
| 186 | + bool bDBInitAP; | |
| 187 | + char strMD1Dbpath[MAX_PATH]; | |
| 188 | + char strMD1DbPath_DUT[MAX_PATH]; // the path on pc load from dut | |
| 189 | + char strMD2Dbpath[MAX_PATH]; | |
| 190 | + char strAPDbpath[MAX_PATH]; | |
| 191 | + char strAPDbPath_DUT[MAX_PATH]; | |
| 192 | +}DBFileOption_struct; | |
| 193 | + | |
| 194 | +typedef struct | |
| 195 | +{ | |
| 196 | + char strFPAuthPath[MAX_PATH]; | |
| 197 | + char strSPAuthPath[MAX_PATH]; | |
| 198 | + char strHdcpBinPath[MAX_PATH]; | |
| 199 | + char strDrmKeyPath[MAX_PATH]; | |
| 200 | + char strHdcpDataPath[MAX_PATH]; | |
| 201 | + char strHdcpCekPath[MAX_PATH]; | |
| 202 | +}LoadFile_struct; | |
| 203 | + | |
| 204 | +typedef struct | |
| 205 | +{ | |
| 206 | + char strBromFilter[MAX_PATH]; | |
| 207 | + char strPreloaderFilter[MAX_PATH]; | |
| 208 | + char strKernelFilter[MAX_PATH]; | |
| 209 | +}PortFilter_struct; | |
| 210 | + | |
| 211 | +typedef struct | |
| 212 | +{ | |
| 213 | + char strBarcode[BARCODE_ARRAY_LEN]; | |
| 214 | + char strBTAddr[BT_ARRAY_LEN]; | |
| 215 | + char strWifiAddr[WIFI_ARRAY_LEN]; | |
| 216 | + char strIMEI[MAX_IMEI_NUMS][IMEI_ARRAY_LEN]; | |
| 217 | + char strSerialNo[SERIAL_NO_BUF_LEN]; | |
| 218 | + char strEthernetMac[ETHERNET_MAC_ARRAY_LEN]; | |
| 219 | + char strDrmkeyMCID[DRMKEY_MCID_ARRAY_LEN]; | |
| 220 | + char strMeid[MEID_ARRAY_LEN]; | |
| 221 | + char strEsn[ESN_ARRAY_LEN]; | |
| 222 | +}ScanData_struct; | |
| 223 | + | |
| 224 | +typedef struct | |
| 225 | +{ | |
| 226 | + bool bWriteBarcode; | |
| 227 | + bool bWriteIMEI; | |
| 228 | + bool bWriteSerialNo; | |
| 229 | + bool bWriteBT; | |
| 230 | + bool bWriteWifi; | |
| 231 | + bool bWriteHdcp; | |
| 232 | + bool bWriteDrm; | |
| 233 | + bool bInstallHdcpData; | |
| 234 | + bool bWriteEthernetMac; | |
| 235 | + bool bWriteDrmkeyMCID; | |
| 236 | + bool bWriteMeid; | |
| 237 | + bool bWriteEsn; | |
| 238 | +}WriteOption_struct; | |
| 239 | + | |
| 240 | +typedef struct | |
| 241 | +{ | |
| 242 | + bool bAuthenEnable; | |
| 243 | + AUTH_HANDLE_T t_AuthHandle; | |
| 244 | + SP_AUTH_HANDLE_T t_SpAuthHandle; | |
| 245 | + SP_SCERT_HANDLE_T t_SpScertHandle; | |
| 246 | +}AuthOption_struct; | |
| 247 | + | |
| 248 | + | |
| 249 | +typedef enum | |
| 250 | +{ | |
| 251 | + FEATURE_PHONE = 0, | |
| 252 | + SMART_PHONE, | |
| 253 | + SMART_PHONE_DUALMODEM, | |
| 254 | + TABLET_WIFI_ONLY, | |
| 255 | + RNDIG_DONGLE | |
| 256 | +}E_TARGET_TYPE; | |
| 257 | + | |
| 258 | +typedef enum | |
| 259 | +{ | |
| 260 | + META_MODE = 0, | |
| 261 | + AT_MODE = 1, | |
| 262 | +}E_OPERATOR_MODE; | |
| 263 | + | |
| 264 | +typedef struct { | |
| 265 | + int iStressTest; | |
| 266 | + bool bAlreadyInMeata; | |
| 267 | + bool bKeepInMeta; | |
| 268 | + bool bClearMetaBootFlag; | |
| 269 | + bool bCompositeDeviceEnable; | |
| 270 | + bool bUsbEnable; | |
| 271 | + bool bSecurityUSB; | |
| 272 | + bool bWithoutBattery; | |
| 273 | + bool bSwithTool; | |
| 274 | + bool bDualTalk; | |
| 275 | + bool bSkipWriteProdInfo; | |
| 276 | + bool bCheckCalFlag; | |
| 277 | + bool bCheckFtFlag; | |
| 278 | + bool bCheckBTWifi; | |
| 279 | + bool bCheckBackNVtoPC; | |
| 280 | + bool bCheckFastbootLock; | |
| 281 | + UINT iCOMPort; | |
| 282 | + UINT iPre_Connect_Timeout; | |
| 283 | + UINT iKernel_Connect_Timeout; | |
| 284 | + E_OPERATOR_MODE eOperatorMode; | |
| 285 | + E_TARGET_TYPE eTargetType; | |
| 286 | + AuthOption_struct sAuthOption; | |
| 287 | + DBFileOption_struct sDBFileOption; | |
| 288 | + WriteOption_struct sWriteOption; | |
| 289 | + IMEIOption_struct sIMEIOption; | |
| 290 | + // BarcodeOption_struct sBarcodeOption; | |
| 291 | + HeaderOption_struct sBarcHeader_Option; | |
| 292 | + HeaderOption_struct sIMEIHeader_Option[MAX_IMEI_NUMS]; | |
| 293 | + HeaderOption_struct sSerialNoHeader_Option; | |
| 294 | + HeaderOption_struct sBTHeader_Option; | |
| 295 | + HeaderOption_struct sWifiHeader_Option; | |
| 296 | + HeaderOption_struct sEthernetMacHeader_Option; | |
| 297 | + HeaderOption_struct sDrmkeyMCIDHeader_Option; | |
| 298 | + HeaderOption_struct sMeidHeader_Option; | |
| 299 | + HeaderOption_struct sEsnHeader_Option; | |
| 300 | + ScanData_struct sScanData; | |
| 301 | + LoadFile_struct sLoadFile; | |
| 302 | + PortFilter_struct sPortFilter; | |
| 303 | + char strLogDir[MAX_PATH]; | |
| 304 | + bool bMDLog; | |
| 305 | + bool EnableSerialNo; | |
| 306 | + bool IgnoreDBInconsistent; | |
| 307 | + bool SerialNumFromIMEI; | |
| 308 | + bool ImeiLockHidden; | |
| 309 | + bool bEnableLockOtp; | |
| 310 | +} META_Common_struct; | |
| 311 | + | |
| 312 | +typedef struct | |
| 313 | +{ | |
| 314 | + bool bInitMD1Db_Done; | |
| 315 | + bool bInitMD2Db_Done; | |
| 316 | + bool bInitAPDb_Done; | |
| 317 | +}DBInitInfo_struct; | |
| 318 | + | |
| 319 | +typedef enum | |
| 320 | +{ | |
| 321 | + FP_START_STAGE = 0, | |
| 322 | + FP_BARCODE_STAGE, | |
| 323 | + FP_IMEI_STAGE, | |
| 324 | + FP_BT_ADDRESS_STAGE, | |
| 325 | + FP_WIFI_ADDRESS_STAGE, | |
| 326 | + FP_BACKUP_NVRAM_STAGE, | |
| 327 | + FP_END_STAGE = 256 | |
| 328 | +}FEATURE_PHONE_STAGE_e; | |
| 329 | + | |
| 330 | +typedef enum | |
| 331 | +{ | |
| 332 | + SP_START_STAGE = 0, | |
| 333 | + SP_CHECK_CAL_FT_FLAG_STAGE, | |
| 334 | + SP_BARCODE_MD_STAGE, | |
| 335 | + SP_IMEI_MD_STAGE, | |
| 336 | + SP_AP2MD_STAGE, | |
| 337 | + SP_C2K_STAGE, | |
| 338 | + SP_MD2AP_STAGE, | |
| 339 | + SP_WRITE_TEMP_STAGE, | |
| 340 | + SP_BT_ADDRESS_STAGE, | |
| 341 | + //SP_VENDOR_ID_STAGE, | |
| 342 | + SP_WIFI_ADDRESS_STAGE, | |
| 343 | + SP_ETHERNET_MAC_STAGE, | |
| 344 | + SP_HDCP_STAGE, | |
| 345 | + SP_DRMKEY_STAGE, | |
| 346 | + SP_HDCPDATA_INSTALL_STAGE, | |
| 347 | + SP_DRMKEY_MCID_STAGE, | |
| 348 | + //C2K Modem | |
| 349 | + //SP_MEID_STAGE, | |
| 350 | + //SP_ESN_STAGE, | |
| 351 | + SP_BACKUPNV_TO_PC_STAGE, | |
| 352 | + SP_BACKUP_NVRAM_STAGE, | |
| 353 | + SP_PRODINFO_STAGE, | |
| 354 | + SP_END_STAGE = 256 | |
| 355 | +}SMART_PHONE_STAGE_e; | |
| 356 | + | |
| 357 | +typedef enum | |
| 358 | +{ | |
| 359 | + SINGLE_MD_SINGLE_IMEI = 0, | |
| 360 | + SINGLE_MD_MULTI_IMEI = 1, | |
| 361 | + DUAL_MD_DUAL_IMEI, | |
| 362 | + MULTIIMEI_RESERVE =255 | |
| 363 | +}MULTIIMEI_OPTION_e; | |
| 364 | + | |
| 365 | +#define _AUTO_GEN_FEATURE_ | |
| 366 | +#ifdef _AUTO_GEN_FEATURE_ | |
| 367 | +typedef struct | |
| 368 | +{ | |
| 369 | + UINT iStep; | |
| 370 | + char Start[BARCODE_ARRAY_LEN]; | |
| 371 | + char End[BARCODE_ARRAY_LEN]; | |
| 372 | + char Next[BARCODE_ARRAY_LEN]; | |
| 373 | +}BarcodeData_struct; | |
| 374 | + | |
| 375 | +typedef struct | |
| 376 | +{ | |
| 377 | + UINT iStep; | |
| 378 | + char Start[IMEI_ARRAY_LEN]; | |
| 379 | + char End[IMEI_ARRAY_LEN]; | |
| 380 | + char Next[IMEI_ARRAY_LEN]; | |
| 381 | +}IMEIData_struct; | |
| 382 | + | |
| 383 | +typedef struct | |
| 384 | +{ | |
| 385 | + UINT iStep; | |
| 386 | + char Start[BT_ARRAY_LEN]; | |
| 387 | + char End[BT_ARRAY_LEN]; | |
| 388 | + char Next[BT_ARRAY_LEN]; | |
| 389 | +}BTAddressData_struct; | |
| 390 | + | |
| 391 | +typedef struct | |
| 392 | +{ | |
| 393 | + UINT iStep; | |
| 394 | + char Start[WIFI_ARRAY_LEN]; | |
| 395 | + char End[WIFI_ARRAY_LEN]; | |
| 396 | + char Next[WIFI_ARRAY_LEN]; | |
| 397 | +}WifiAddressData_struct; | |
| 398 | + | |
| 399 | +typedef struct | |
| 400 | +{ | |
| 401 | + UINT iStep; | |
| 402 | + char Start[ETHERNET_MAC_ARRAY_LEN]; | |
| 403 | + char End[ETHERNET_MAC_ARRAY_LEN]; | |
| 404 | + char Next[ETHERNET_MAC_ARRAY_LEN]; | |
| 405 | +}EthernetAddressData_struct; | |
| 406 | + | |
| 407 | +typedef struct | |
| 408 | +{ | |
| 409 | + UINT iStep; | |
| 410 | + char Start[DRMKEY_MCID_ARRAY_LEN]; | |
| 411 | + char End[DRMKEY_MCID_ARRAY_LEN]; | |
| 412 | + char Next[DRMKEY_MCID_ARRAY_LEN]; | |
| 413 | +}DRMKEYMCID_Data_struct; | |
| 414 | + | |
| 415 | +typedef struct | |
| 416 | +{ | |
| 417 | + bool bAllDataValid; | |
| 418 | + bool bBarcodeValid; | |
| 419 | + bool bIMEIValid; | |
| 420 | + bool bBTValid; | |
| 421 | + bool bWifiValid; | |
| 422 | + bool bEthernetValid; | |
| 423 | + bool bDRMKeyMCIDValid; | |
| 424 | +}AutoGenDataValid_struct; | |
| 425 | + | |
| 426 | +typedef struct | |
| 427 | +{ | |
| 428 | + BarcodeData_struct sBarcode; | |
| 429 | + IMEIData_struct sIMEI; | |
| 430 | + BTAddressData_struct sBtAddress; | |
| 431 | + WifiAddressData_struct sWifiAddress; | |
| 432 | + EthernetAddressData_struct sEthernetAddress; | |
| 433 | + DRMKEYMCID_Data_struct sDRMKeyMCID; | |
| 434 | + AutoGenDataValid_struct sDataValid; | |
| 435 | + Radix_e eIncreaseRadix; | |
| 436 | + | |
| 437 | + bool bEnableAutoGen; | |
| 438 | + bool bAutoGenBarcode; | |
| 439 | + bool bAutoGenIMEI; | |
| 440 | + bool bAutoGenBT; | |
| 441 | + bool bAutoGenWifi; | |
| 442 | + bool bAutoGenEthernet; | |
| 443 | + bool bAutoGenDRMKeyMCID; | |
| 444 | +}AutoGenData_struct; | |
| 445 | + | |
| 446 | +extern AutoGenData_struct g_AutoGenData; | |
| 447 | +extern char g_pAutoGenSetupFilepath[MAX_PATH]; | |
| 448 | +RW_SetupFile_Status GetAutoGenParaFromSetupFile(); | |
| 449 | +RW_SetupFile_Status SaveAutoGenParaToSetupFile(); | |
| 450 | +RW_SetupFile_Status UpdateAutoGenParaToSetupFile(); | |
| 451 | +#endif //#ifdef _AUTO_GEN_FEATURE_ | |
| 452 | +bool ResultToString_Win(DWORD ED, char* lpBuffer, DWORD nSize); | |
| 453 | +char* ResultToString_SP(int MR); | |
| 454 | +char* ResultToString(int MR); | |
| 455 | +int InitSNIni(); | |
| 456 | +void InitGlobalValue(); | |
| 457 | +int GetSNSetupFilePath(); | |
| 458 | +void EnableUSBSwitch(); | |
| 459 | +void DisableUSBSwitch(); | |
| 460 | +Login_Identify_e GetLoginIdentify(); | |
| 461 | +UINT SaveLoginIdentify(const Login_Identify_e identify); | |
| 462 | +UINT SaveLoginPasswd(const char *strPasswd); | |
| 463 | +E_TARGET_TYPE GetTargetType(); | |
| 464 | +long GetFilesize( FILE *fp ); | |
| 465 | +bool CheckFileSize( const char *strFilePath, const long fileSize ); | |
| 466 | + | |
| 467 | +bool AuthHandle_Init(); | |
| 468 | +void AuthHandle_DeInit(); | |
| 469 | +bool AuthInit(const char *strAuthFilePath); | |
| 470 | +bool SPAuthInit(const char *strSPAuthFilePath); | |
| 471 | +bool SPScertInit(const char *strSPScertFilePath); | |
| 472 | + | |
| 473 | +RW_SetupFile_Status GetParaFromSetupFile(); | |
| 474 | +RW_SetupFile_Status SaveParaToSetupFile(); | |
| 475 | + | |
| 476 | +RW_SetupFile_Status GetItemParaFromSetupFile(const char *strFilePath, LPCTSTR lpKeyName, void* lpValue, E_INI_DATA_TYPE dataType); | |
| 477 | +RW_SetupFile_Status SaveItemParaToSetupFile(const char *strFilePath, LPCTSTR lpKeyName, void* lpValue, E_INI_DATA_TYPE dataType); | |
| 478 | + | |
| 479 | +//Global parameters | |
| 480 | +//extern DWORD g_MainDlgHandle; | |
| 481 | +extern META_Common_struct g_sMetaComm; | |
| 482 | +extern char g_pSetupFilepath[MAX_PATH]; | |
| 483 | +extern char g_pPasswdFilepath[MAX_PATH]; | |
| 484 | +extern int g_iMetaStopFlag; | |
| 485 | +extern Login_Identify_e g_LoginIdentify; | |
| 486 | + | |
| 487 | +#endif | ... | ... |
Delete_temp.bat
0 → 100644
| 1 | + | |
| 2 | +:: delete all temp file, for release source code and check-in to code database | |
| 3 | + | |
| 4 | +@echo delete all temp file... | |
| 5 | + | |
| 6 | +del /f /s /q Debug\*.idb | |
| 7 | +del /f /s /q Debug\*.sbr | |
| 8 | +del /f /s /q Debug\*.bsc | |
| 9 | +del /f /s /q Debug\*.pdb | |
| 10 | +del /f /s /q Debug\*.pch | |
| 11 | +del /f /s /q Debug\*.obj | |
| 12 | +del /f /s /q Debug\*.lib | |
| 13 | +del /f /s /q Debug\*.ilk | |
| 14 | +del /f /s /q Debug\*.exp | |
| 15 | +del /f /s /q Debug\*.res | |
| 16 | + | |
| 17 | +del /f /s /q Release\*.idb | |
| 18 | +del /f /s /q Release\*.sbr | |
| 19 | +del /f /s /q Release\*.bsc | |
| 20 | +del /f /s /q Release\*.pdb | |
| 21 | +del /f /s /q Release\*.pch | |
| 22 | +del /f /s /q Release\*.obj | |
| 23 | +del /f /s /q Release\*.lib | |
| 24 | +del /f /s /q Release\*.ilk | |
| 25 | +del /f /s /q Release\*.exp | |
| 26 | +del /f /s /q Release\*.res | |
| 27 | + | |
| 28 | +del /f /s /q Output\*.idb | |
| 29 | +del /f /s /q Output\*.sbr | |
| 30 | +del /f /s /q Output\*.bsc | |
| 31 | +del /f /s /q Output\*.pdb | |
| 32 | +del /f /s /q Output\*.pch | |
| 33 | +del /f /s /q Output\*.obj | |
| 34 | +del /f /s /q Output\*.lib | |
| 35 | +del /f /s /q Output\*.ilk | |
| 36 | +del /f /s /q Output\*.exp | |
| 37 | +del /f /s /q Output\*.res | |
| 38 | +del /f /s /q Output\MtkCommIODLL.log | |
| 39 | + | |
| 40 | +del /f /s /q *.ncb | |
| 41 | + | |
| 42 | +copy /b Output\SN_Setup.ini.bak Output\SN_Setup.ini | ... | ... |
Encryption.cpp
0 → 100644
| 1 | +// Encryption.cpp : implementation file | |
| 2 | +// | |
| 3 | + | |
| 4 | +#include "stdafx.h" | |
| 5 | +#include "SN Writer.h" | |
| 6 | +#include "Encryption.h" | |
| 7 | + | |
| 8 | +#ifdef _DEBUG | |
| 9 | +#define new DEBUG_NEW | |
| 10 | +#undef THIS_FILE | |
| 11 | +static char THIS_FILE[] = __FILE__; | |
| 12 | +#endif | |
| 13 | + | |
| 14 | +///////////////////////////////////////////////////////////////////////////// | |
| 15 | +// Encryption dialog | |
| 16 | +char g_cPwd[52] = {0}; | |
| 17 | + | |
| 18 | + | |
| 19 | +Encryption::Encryption(CWnd* pParent /*=NULL*/) | |
| 20 | + : CDialog(Encryption::IDD, pParent) | |
| 21 | +{ | |
| 22 | + //{{AFX_DATA_INIT(Encryption) | |
| 23 | + m_strPwdData = _T(""); | |
| 24 | + // NOTE: the ClassWizard will add member initialization here | |
| 25 | + //}}AFX_DATA_INIT | |
| 26 | +} | |
| 27 | + | |
| 28 | + | |
| 29 | +void Encryption::DoDataExchange(CDataExchange* pDX) | |
| 30 | +{ | |
| 31 | + CDialog::DoDataExchange(pDX); | |
| 32 | + //{{AFX_DATA_MAP(Encryption) | |
| 33 | + DDX_Text(pDX, IDC_PWD_DATA, m_strPwdData); | |
| 34 | + DDV_MaxChars(pDX, m_strPwdData, 32); | |
| 35 | + // NOTE: the ClassWizard will add DDX and DDV calls here | |
| 36 | + //}}AFX_DATA_MAP | |
| 37 | +} | |
| 38 | + | |
| 39 | + | |
| 40 | +BEGIN_MESSAGE_MAP(Encryption, CDialog) | |
| 41 | + //{{AFX_MSG_MAP(Encryption) | |
| 42 | + ON_EN_KILLFOCUS(IDC_PWD_DATA, OnKillfocusPwdData) | |
| 43 | + // NOTE: the ClassWizard will add message map macros here | |
| 44 | + //}}AFX_MSG_MAP | |
| 45 | +END_MESSAGE_MAP() | |
| 46 | + | |
| 47 | +///////////////////////////////////////////////////////////////////////////// | |
| 48 | +// Encryption message handlers | |
| 49 | +void Encryption::OnCancel() | |
| 50 | +{ | |
| 51 | + // TODO: Add extra cleanup here | |
| 52 | + | |
| 53 | + CDialog::OnCancel(); | |
| 54 | +} | |
| 55 | + | |
| 56 | +void Encryption::OnOK() | |
| 57 | +{ | |
| 58 | + // TODO: Add extra validation here | |
| 59 | + bool bCheckPass = false; | |
| 60 | + // TODO: Add extra validation here | |
| 61 | + if(strlen(m_strPwdData) >= 1) | |
| 62 | + bCheckPass = true; | |
| 63 | + if(! bCheckPass) | |
| 64 | + { | |
| 65 | + SetDlgItemText(IDC_PWD_MSG, "EMPTY INPUT !"); | |
| 66 | + SetDlgItemText(IDC_PWD_DATA, ""); | |
| 67 | + GotoDlgCtrl(GetDlgItem(IDC_PWD_DATA)); | |
| 68 | + } | |
| 69 | + else | |
| 70 | + { | |
| 71 | + CDialog::OnOK(); | |
| 72 | + } | |
| 73 | + | |
| 74 | + //CDialog::OnOK(); | |
| 75 | +} | |
| 76 | + | |
| 77 | +void Encryption::OnKillfocusPwdData() | |
| 78 | +{ | |
| 79 | + // TODO: Add your control notification handler code here | |
| 80 | + UpdateData(TRUE); | |
| 81 | + bool bCheckPass = false; | |
| 82 | + strncpy(g_cPwd, (LPCTSTR)m_strPwdData, strlen(m_strPwdData)+1); | |
| 83 | + if(strlen(m_strPwdData) >= 1) | |
| 84 | + bCheckPass = true; | |
| 85 | + if(! bCheckPass) | |
| 86 | + { | |
| 87 | + SetDlgItemText(IDC_PWD_MSG, "EMPTY INPUT !"); | |
| 88 | + SetDlgItemText(IDC_PWD_DATA, ""); | |
| 89 | + GotoDlgCtrl(GetDlgItem(IDC_PWD_DATA)); | |
| 90 | + } | |
| 91 | + | |
| 92 | +} | |
| 93 | + | |
| 94 | +BOOL Encryption::PreTranslateMessage(MSG* pMsg) | |
| 95 | +{ | |
| 96 | + // TODO: Add your specialized code here and/or call the base class | |
| 97 | + | |
| 98 | + if(pMsg->message == WM_KEYDOWN && pMsg->wParam==VK_RETURN) | |
| 99 | + { | |
| 100 | + //AfxMessageBox("hello just for test"); | |
| 101 | + //m_strPwdData += "\n"; | |
| 102 | + UpdateData(true); | |
| 103 | + OnOK(); | |
| 104 | + return true; | |
| 105 | + } | |
| 106 | + | |
| 107 | + return CDialog::PreTranslateMessage(pMsg); | |
| 108 | +} | |
| 109 | + | |
| 110 | +BOOL Encryption::OnInitDialog() | |
| 111 | +{ | |
| 112 | + CDialog::OnInitDialog(); | |
| 113 | + | |
| 114 | + // TODO: Add extra initialization here | |
| 115 | + | |
| 116 | + GotoDlgCtrl(GetDlgItem(IDC_PWD_DATA)); | |
| 117 | + return FALSE; | |
| 118 | + //return TRUE; // return TRUE unless you set the focus to a control | |
| 119 | + // EXCEPTION: OCX Property Pages should return FALSE | |
| 120 | +} | |
| 121 | + | ... | ... |
Encryption.h
0 → 100644
| 1 | +#if !defined(AFX_ENCRYPTION_H__A1D48CD0_7BBD_4F19_92D4_9F9FDE5172E1__INCLUDED_) | |
| 2 | +#define AFX_ENCRYPTION_H__A1D48CD0_7BBD_4F19_92D4_9F9FDE5172E1__INCLUDED_ | |
| 3 | + | |
| 4 | +#if _MSC_VER > 1000 | |
| 5 | +#pragma once | |
| 6 | +#endif // _MSC_VER > 1000 | |
| 7 | +// Encryption.h : header file | |
| 8 | +// | |
| 9 | + | |
| 10 | +///////////////////////////////////////////////////////////////////////////// | |
| 11 | +// Encryption dialog | |
| 12 | +extern char g_cPwd[52]; | |
| 13 | + | |
| 14 | +class Encryption : public CDialog | |
| 15 | +{ | |
| 16 | +// Construction | |
| 17 | +public: | |
| 18 | + Encryption(CWnd* pParent = NULL); // standard constructor | |
| 19 | + | |
| 20 | +// Dialog Data | |
| 21 | + //{{AFX_DATA(Encryption) | |
| 22 | + enum { IDD = IDD_ENCRYPTION_DIALOG }; | |
| 23 | + CString m_strPwdData; | |
| 24 | + // NOTE: the ClassWizard will add data members here | |
| 25 | + //}}AFX_DATA | |
| 26 | + | |
| 27 | + | |
| 28 | +// Overrides | |
| 29 | + // ClassWizard generated virtual function overrides | |
| 30 | + //{{AFX_VIRTUAL(Encryption) | |
| 31 | + public: | |
| 32 | + virtual BOOL PreTranslateMessage(MSG* pMsg); | |
| 33 | + protected: | |
| 34 | + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support | |
| 35 | + //}}AFX_VIRTUAL | |
| 36 | + | |
| 37 | +// Implementation | |
| 38 | +protected: | |
| 39 | + | |
| 40 | + // Generated message map functions | |
| 41 | + //{{AFX_MSG(Encryption) | |
| 42 | + virtual void OnCancel(); | |
| 43 | + virtual void OnOK(); | |
| 44 | + afx_msg void OnKillfocusPwdData(); | |
| 45 | + virtual BOOL OnInitDialog(); | |
| 46 | + // NOTE: the ClassWizard will add member functions here | |
| 47 | + //}}AFX_MSG | |
| 48 | + DECLARE_MESSAGE_MAP() | |
| 49 | +}; | |
| 50 | + | |
| 51 | +//{{AFX_INSERT_LOCATION}} | |
| 52 | +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. | |
| 53 | + | |
| 54 | +#endif // !defined(AFX_ENCRYPTION_H__A1D48CD0_7BBD_4F19_92D4_9F9FDE5172E1__INCLUDED_) | ... | ... |
Execute/FPexc.cpp
0 → 100644
| 1 | +#include "StdAfx.h" | |
| 2 | +#include "FPexc.h" | |
| 3 | +#include "xboot_debug.h" | |
| 4 | +#include "Common.h" | |
| 5 | +#include "AutoGen.h" | |
| 6 | +#include "SN Writer.h" | |
| 7 | +#include "SN WriterDlg.h" | |
| 8 | +#include "ScanData.h" | |
| 9 | + | |
| 10 | +extern CSNWriterDlg *g_pMainDlg; | |
| 11 | + | |
| 12 | +FeaturePhoneSN::FeaturePhoneSN() | |
| 13 | +{ | |
| 14 | + m_hMauiMetaHandle = INVALID_META_HANDLE; | |
| 15 | +} | |
| 16 | + | |
| 17 | +FeaturePhoneSN:: ~FeaturePhoneSN() | |
| 18 | +{ | |
| 19 | + | |
| 20 | +} | |
| 21 | + | |
| 22 | +void FeaturePhoneSN::SetupMetaModeParameters() | |
| 23 | +{ | |
| 24 | + m_tMetaReq_Ex.com_port = g_sMetaComm.iCOMPort; | |
| 25 | + m_tMetaReq_Ex.ms_connect_timeout = 400000; | |
| 26 | + m_tMetaReq_Ex.close_com_port = _TRUE; | |
| 27 | + m_tMetaReq_Ex.InMetaMode=_FALSE; | |
| 28 | + m_tMetaReq_Ex.protocol = 0; // DHL | |
| 29 | + m_tMetaReq_Ex.channel_type = 0; // Native channel | |
| 30 | + m_tMetaReq_Ex.boot_meta_arg.m_bbchip_type = AUTO_DETECT_BBCHIP; | |
| 31 | + m_tMetaReq_Ex.boot_meta_arg.m_ext_clock = AUTO_DETECT_EXT_CLOCK; | |
| 32 | + | |
| 33 | + if (g_sMetaComm.bUsbEnable) | |
| 34 | + { | |
| 35 | + m_tMetaReq_Ex.boot_meta_arg.m_usb_enable = _TRUE; | |
| 36 | + m_tMetaReq_Ex.usb_enable = _TRUE; | |
| 37 | + if (g_sMetaComm.bWithoutBattery) | |
| 38 | + { | |
| 39 | + m_tMetaReq_Ex.boot_meta_arg.m_enable_without_battery = _TRUE; | |
| 40 | + } | |
| 41 | + else | |
| 42 | + { | |
| 43 | + m_tMetaReq_Ex.boot_meta_arg.m_enable_without_battery = _FALSE; | |
| 44 | + } | |
| 45 | + } | |
| 46 | + else | |
| 47 | + { | |
| 48 | + m_tMetaReq_Ex.usb_enable = _FALSE; | |
| 49 | + m_tMetaReq_Ex.boot_meta_arg.m_usb_enable = _FALSE; | |
| 50 | + m_tMetaReq_Ex.flowctrl = META_SW_FLOWCTRL; | |
| 51 | + } | |
| 52 | + | |
| 53 | + | |
| 54 | + m_tMetaReq_Ex.baudrate[0] = META_BAUD115200; | |
| 55 | + m_tMetaReq_Ex.baudrate[1] = META_BAUD230400; | |
| 56 | + m_tMetaReq_Ex.baudrate[2] = META_BAUD460800; | |
| 57 | + m_tMetaReq_Ex.baudrate[3] = META_BAUD921600; | |
| 58 | + m_tMetaReq_Ex.baudrate[4] = META_BAUD57600; | |
| 59 | + m_tMetaReq_Ex.baudrate[5] = META_BAUD_END; | |
| 60 | + | |
| 61 | + m_tMetaReq_Ex.boot_meta_arg.m_ms_boot_timeout = 30000; | |
| 62 | + m_tMetaReq_Ex.boot_meta_arg.m_scert_handle = NULL; | |
| 63 | + m_tMetaReq_Ex.boot_meta_arg.m_cb_in_brom_stage = NULL; | |
| 64 | + m_tMetaReq_Ex.boot_meta_arg.m_cb_in_brom_stage_arg = NULL; | |
| 65 | + // security level2 | |
| 66 | + m_tMetaReq_Ex.boot_meta_arg.m_speedup_brom_baudrate = _TRUE; //115200 | |
| 67 | + m_tMetaReq_Ex.boot_meta_arg.m_ready_power_on_wnd_handle = NULL; | |
| 68 | + m_tMetaReq_Ex.boot_meta_arg.m_ready_power_on_wparam = NULL; | |
| 69 | + m_tMetaReq_Ex.boot_meta_arg.m_ready_power_on_lparam = NULL; | |
| 70 | + | |
| 71 | + if (g_sMetaComm.bSecurityUSB) | |
| 72 | + { | |
| 73 | + m_tMetaReq_Ex.boot_meta_arg.m_auth_handle = Get_AuthHandle(); | |
| 74 | + m_tMetaReq_Ex.boot_meta_arg.m_cb_sla_challenge = SLA_Challenge;//SLA_Challenge(NULL,NULL,0,NULL,NULL); | |
| 75 | + m_tMetaReq_Ex.boot_meta_arg.m_cb_sla_challenge_end = SLA_Challenge_END; // NULL; | |
| 76 | + } | |
| 77 | + else | |
| 78 | + { | |
| 79 | + m_tMetaReq_Ex.boot_meta_arg.m_auth_handle = NULL; | |
| 80 | + m_tMetaReq_Ex.boot_meta_arg.m_cb_sla_challenge = NULL;//SLA_Challenge(NULL,NULL,0,NULL,NULL); | |
| 81 | + m_tMetaReq_Ex.boot_meta_arg.m_cb_sla_challenge_end = NULL; // NULL; | |
| 82 | + } | |
| 83 | + | |
| 84 | + m_tMetaReq_Ex.boot_meta_arg.m_cb_sla_challenge_arg = NULL; | |
| 85 | + m_tMetaReq_Ex.boot_meta_arg.m_cb_sla_challenge_end_arg = NULL; | |
| 86 | + m_tMetaReq_Ex.boot_meta_arg.m_cb_com_init_stage = NULL; | |
| 87 | + m_tMetaReq_Ex.boot_meta_arg.m_cb_com_init_stage_arg = NULL; | |
| 88 | +} | |
| 89 | + | |
| 90 | +META_RESULT FeaturePhoneSN::MetaHandle_Init() | |
| 91 | +{ | |
| 92 | + META_RESULT meta_result = META_SUCCESS; | |
| 93 | + if (m_hMauiMetaHandle == INVALID_META_HANDLE) | |
| 94 | + { | |
| 95 | + meta_result = ModemMetaHandle_Init(); | |
| 96 | + if (meta_result != META_SUCCESS) | |
| 97 | + { | |
| 98 | + UpdateUIMsg("Init meta handle fail, MetaResult = %s", ResultToString(meta_result)); | |
| 99 | + } | |
| 100 | + } | |
| 101 | + | |
| 102 | + return meta_result; | |
| 103 | +} | |
| 104 | + | |
| 105 | +void FeaturePhoneSN::MetaHandle_DeInit() | |
| 106 | +{ | |
| 107 | + if (m_hMauiMetaHandle != INVALID_META_HANDLE) | |
| 108 | + { | |
| 109 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::MetaHandle_DeInit() : DeInit meta handle start..."); | |
| 110 | + ModemMetaHandle_DeInit(); | |
| 111 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::MetaHandle_DeInit() : DeInit meta handle end..."); | |
| 112 | + } | |
| 113 | +} | |
| 114 | + | |
| 115 | +META_RESULT FeaturePhoneSN::ModemMetaHandle_Init() | |
| 116 | +{ | |
| 117 | + META_RESULT MetaResult = META_SUCCESS; | |
| 118 | + MetaResult = META_GetAvailableHandle( &m_hMauiMetaHandle ); | |
| 119 | + if(MetaResult != META_SUCCESS) | |
| 120 | + { | |
| 121 | + MTRACE_ERR (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_GetAvailableHandle(): Get available modem meta handle Fail, MetaResult = %s", ResultToString(MetaResult)); | |
| 122 | + return MetaResult; | |
| 123 | + } | |
| 124 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_GetAvailableHandle(): Get available modem meta handle success!"); | |
| 125 | + | |
| 126 | + MetaResult = META_Init_r( m_hMauiMetaHandle, NULL); | |
| 127 | + if(MetaResult != META_SUCCESS) | |
| 128 | + { | |
| 129 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_Init_r(): Init modem meta handle Fail, MetaResult = %s", ResultToString(MetaResult)); | |
| 130 | + return MetaResult; | |
| 131 | + } | |
| 132 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_Init_r(): Init modem meta handle success!"); | |
| 133 | + | |
| 134 | + return META_SUCCESS; | |
| 135 | +} | |
| 136 | + | |
| 137 | +void FeaturePhoneSN::ModemMetaHandle_DeInit() | |
| 138 | +{ | |
| 139 | + META_Deinit_r(&m_hMauiMetaHandle); | |
| 140 | + m_hMauiMetaHandle = INVALID_META_HANDLE; | |
| 141 | +} | |
| 142 | + | |
| 143 | +META_RESULT FeaturePhoneSN::EnterModemMeta() | |
| 144 | +{ | |
| 145 | + unsigned short comPort = 0; | |
| 146 | + META_RESULT MetaResult = META_SUCCESS; | |
| 147 | + char info[512] = {0}; | |
| 148 | + | |
| 149 | + PortEnumHelper cBromHelper; | |
| 150 | + PortEnumHelper cPreloaderHelper; | |
| 151 | + char * szBromFilter = NULL; | |
| 152 | + char * szPreloaderFilter = NULL; | |
| 153 | + | |
| 154 | + cBromHelper.SetFilter(SP_WHITE_LIST, g_sMetaComm.sPortFilter.strBromFilter); | |
| 155 | + if (cBromHelper.GetFilter()->m_uCount > 0) | |
| 156 | + szBromFilter = cBromHelper.GetFilter()->m_ppFilterID[0]; | |
| 157 | + else | |
| 158 | + szBromFilter = ""; | |
| 159 | + cPreloaderHelper.SetFilter(SP_WHITE_LIST, g_sMetaComm.sPortFilter.strPreloaderFilter); | |
| 160 | + if (cPreloaderHelper.GetFilter()->m_uCount > 0) | |
| 161 | + szPreloaderFilter = cPreloaderHelper.GetFilter()->m_ppFilterID[0]; | |
| 162 | + else | |
| 163 | + szPreloaderFilter = ""; | |
| 164 | + | |
| 165 | + if (g_sMetaComm.bUsbEnable == false) | |
| 166 | + { | |
| 167 | + UpdateUIMsg("Start enter meta mode..."); | |
| 168 | + MetaResult = META_ConnectWithMultiModeTarget_r(m_hMauiMetaHandle, &m_tMetaReq_Ex, sizeof(m_tMetaReq_Ex), m_pMetaStopFlag, &m_tMetaConnReport_Ex); | |
| 169 | + } | |
| 170 | + else | |
| 171 | + { | |
| 172 | + if (g_sMetaComm.bDualTalk) | |
| 173 | + { | |
| 174 | + SP_BOOT_ARG_S stArg; | |
| 175 | + int BootStop = SP_BOOT_INFINITE; | |
| 176 | + int iRet = S_DONE; | |
| 177 | + int ms_connect_timeout = 30000; | |
| 178 | + | |
| 179 | + memset(&stArg, 0, sizeof(SP_BOOT_ARG_S)); | |
| 180 | + //Parameter settings | |
| 181 | + stArg.m_bbchip_type = SP_AUTO_DETECT_BBCHIP; | |
| 182 | + stArg.m_ext_clock = SP_AUTO_DETECT_EXT_CLOCK; | |
| 183 | + stArg.m_ms_boot_timeout = SP_BOOT_INFINITE; | |
| 184 | + stArg.m_max_start_cmd_retry_count = SP_DEFAULT_BROM_START_CMD_RETRY_COUNT; | |
| 185 | + | |
| 186 | + stArg.m_uTimeout = 20000; | |
| 187 | + stArg.m_uRetryTime = 2000; | |
| 188 | + stArg.m_uInterval = 10; | |
| 189 | + stArg.m_uBaudrate = CBR_115200; | |
| 190 | + | |
| 191 | + stArg.m_auth_handle = NULL; | |
| 192 | + stArg.m_scert_handle = NULL; | |
| 193 | + stArg.m_cb_sla_challenge = NULL; | |
| 194 | + stArg.m_cb_sla_challenge_arg = NULL; | |
| 195 | + stArg.m_cb_sla_challenge_end = NULL; | |
| 196 | + stArg.m_cb_sla_challenge_end_arg = NULL; | |
| 197 | + | |
| 198 | + stArg.m_pStopFlag = m_pMetaStopFlag; | |
| 199 | + stArg.m_bIsUSBEnable = g_sMetaComm.bUsbEnable; | |
| 200 | + stArg.m_bIsSymbolicEnable = false; | |
| 201 | + stArg.m_bIsCompositeDeviceEnable = g_sMetaComm.bCompositeDeviceEnable; | |
| 202 | + stArg.m_euBootMode = SP_DUALTALK_SWITCH; | |
| 203 | + memset(stArg.m_szPortSymbolic, 0, 256); | |
| 204 | + | |
| 205 | + // step1: Get Preloader Port | |
| 206 | + UpdateUIMsg("Wait for usb insert..."); | |
| 207 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::EnterModemMeta(): Step1, Get preloader comport..."); | |
| 208 | + MetaResult = META_GetDynamicUSBComPortExWithFilter_r(m_hMauiMetaHandle, | |
| 209 | + ms_connect_timeout, &comPort, m_pMetaStopFlag, info, 1000, szPreloaderFilter); | |
| 210 | + if(META_SUCCESS != MetaResult) | |
| 211 | + { | |
| 212 | + MTRACE_ERR ( g_hEBOOT_DEBUG, "FeaturePhoneSN::EnterModemMeta(): Get preloader comport fail!"); | |
| 213 | + return MetaResult; | |
| 214 | + } | |
| 215 | + MTRACE( g_hEBOOT_DEBUG, "FeaturePhoneSN::EnterModemMeta(): Get preloader comport successfully, comport = %d!", comPort); | |
| 216 | + | |
| 217 | + // step2: switch to modem | |
| 218 | + stArg.m_uPortNumber = comPort; | |
| 219 | + UpdateUIMsg("Handshake with preloader."); | |
| 220 | + MTRACE ( g_hEBOOT_DEBUG, "FeaturePhoneSN::EnterModemMeta(): Step2, Switch to modem ..."); | |
| 221 | + iRet = SP_Preloader_BootMode(&stArg); | |
| 222 | + if(S_DONE != iRet) | |
| 223 | + { | |
| 224 | + MTRACE_ERR ( g_hEBOOT_DEBUG, "FeaturePhoneSN::EnterModemMeta(): Switch to modem fail!"); | |
| 225 | + return (META_RESULT)iRet; | |
| 226 | + } | |
| 227 | + MTRACE( g_hEBOOT_DEBUG, "FeaturePhoneSN::EnterModemMeta(): Switch to modem successfully!"); | |
| 228 | + | |
| 229 | + // step3: get modem comport | |
| 230 | + UpdateUIMsg("Wait for device enter meta mode..."); | |
| 231 | + MTRACE ( g_hEBOOT_DEBUG, "FeaturePhoneSN::EnterModemMeta(): Step3, Get Modem Brom Port..."); | |
| 232 | + MetaResult = META_GetDynamicUSBComPortExWithFilter_r(m_hMauiMetaHandle, | |
| 233 | + ms_connect_timeout, &comPort, m_pMetaStopFlag, info, 512, szBromFilter); | |
| 234 | + if(META_SUCCESS != MetaResult) | |
| 235 | + { | |
| 236 | + MTRACE_ERR( g_hEBOOT_DEBUG, "FeaturePhoneSN::EnterModemMeta(): Get Modem Brom Port fail!"); | |
| 237 | + return MetaResult; | |
| 238 | + } | |
| 239 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::EnterModemMeta(): Get Modem Brom Port successfully, comPort = %d!", comPort); | |
| 240 | + } | |
| 241 | + else | |
| 242 | + { | |
| 243 | + UpdateUIMsg("Wait for usb insert..."); | |
| 244 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::META_GetDynamicUSBComPortExWithFilter_r(): Start..."); | |
| 245 | + MetaResult = META_GetDynamicUSBComPortExWithFilter_r(m_hMauiMetaHandle, | |
| 246 | + m_tMetaReq_Ex.ms_connect_timeout, &comPort, m_pMetaStopFlag, info, 512, szBromFilter); | |
| 247 | + if (MetaResult != META_SUCCESS) | |
| 248 | + { | |
| 249 | + MTRACE_ERR(g_hEBOOT_DEBUG, "FeaturePhoneSN::META_GetDynamicUSBComPortExWithFilter_r(): fail, %s.", ResultToString(MetaResult)); | |
| 250 | + return MetaResult; | |
| 251 | + } | |
| 252 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::META_GetDynamicUSBComPortExWithFilter_r(): ok, COM%u.", comPort); | |
| 253 | + } | |
| 254 | + | |
| 255 | + UpdateUIMsg("Start enter meta mode..."); | |
| 256 | + m_tMetaReq_Ex.com_port = comPort; | |
| 257 | + MetaResult = META_ConnectWithMultiModeTarget_r(m_hMauiMetaHandle, &m_tMetaReq_Ex, sizeof(m_tMetaReq_Ex), m_pMetaStopFlag, &m_tMetaConnReport_Ex); | |
| 258 | + } | |
| 259 | + | |
| 260 | + if (MetaResult == META_SUCCESS) | |
| 261 | + { | |
| 262 | + m_bStopBeforeUSBInsert = false; | |
| 263 | + m_bTargetInMetaMode = true; | |
| 264 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::META_ConnectWithMultiModeTarget_r(): ok."); | |
| 265 | + } | |
| 266 | + else if (MetaResult == META_MAUI_DB_INCONSISTENT) | |
| 267 | + { | |
| 268 | + m_bStopBeforeUSBInsert = false; | |
| 269 | + m_bTargetInMetaMode = true; | |
| 270 | + if (!g_sMetaComm.sDBFileOption.bDBInitModem_1) | |
| 271 | + { | |
| 272 | + MetaResult = META_SUCCESS; | |
| 273 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::META_ConnectWithMultiModeTarget_r(): ok, md db inconsistent, directly ignore."); | |
| 274 | + } | |
| 275 | + else if (g_sMetaComm.IgnoreDBInconsistent) | |
| 276 | + { | |
| 277 | + MetaResult = META_SUCCESS; | |
| 278 | + MTRACE_WARN(g_hEBOOT_DEBUG, "FeaturePhoneSN::META_ConnectWithMultiModeTarget_r(): ok, md db inconsistent, but ignore."); | |
| 279 | + } | |
| 280 | + else | |
| 281 | + { | |
| 282 | + UpdateUIMsg("Enter meta mode fail, md db inconsistent."); | |
| 283 | + MTRACE_ERR(g_hEBOOT_DEBUG, "FeaturePhoneSN::META_ConnectWithMultiModeTarget_r(): fail, md db inconsistent."); | |
| 284 | + } | |
| 285 | + } | |
| 286 | + else | |
| 287 | + { | |
| 288 | + m_bStopBeforeUSBInsert = true; | |
| 289 | + m_bTargetInMetaMode = false; | |
| 290 | + UpdateUIMsg("Enter meta mode fail, %s", ResultToString(MetaResult)); | |
| 291 | + MTRACE_ERR(g_hEBOOT_DEBUG, "FeaturePhoneSN::META_ConnectWithMultiModeTarget_r(): fail, %s.", ResultToString(MetaResult)); | |
| 292 | + } | |
| 293 | + | |
| 294 | + return MetaResult; | |
| 295 | +} | |
| 296 | + | |
| 297 | +META_RESULT FeaturePhoneSN::ExitModemMeta() | |
| 298 | +{ | |
| 299 | + META_RESULT MetaResult = META_SUCCESS; | |
| 300 | + char strTmp[1024] = {0}; | |
| 301 | + | |
| 302 | + if (m_bTargetInMetaMode) | |
| 303 | + { | |
| 304 | + char *pFuncName = "META_DisconnectWithTarget_r"; | |
| 305 | + MetaResult = META_DisconnectWithTarget_r (m_hMauiMetaHandle); | |
| 306 | + | |
| 307 | + if (MetaResult == META_SUCCESS) | |
| 308 | + { | |
| 309 | + m_bTargetInMetaMode = false; | |
| 310 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::ExitModemMeta(): Exit meta mode by %s successfully! MetaResult = %s", | |
| 311 | + pFuncName, ResultToString(MetaResult)); | |
| 312 | + } | |
| 313 | + else | |
| 314 | + { | |
| 315 | + MTRACE_ERR (g_hEBOOT_DEBUG, "FeaturePhoneSN::ExitModemMeta(): Exit meta mode by %s Fail! MetaResult = %s", pFuncName, ResultToString(MetaResult)); | |
| 316 | + } | |
| 317 | + } | |
| 318 | + | |
| 319 | + return MetaResult; | |
| 320 | +} | |
| 321 | + | |
| 322 | +META_RESULT FeaturePhoneSN::LoadModemDatabase(int MDindex) | |
| 323 | +{ | |
| 324 | + unsigned long db; | |
| 325 | + bool bEnterCritSetion = false; | |
| 326 | + META_RESULT meta_result; | |
| 327 | + | |
| 328 | + if (!g_sMetaComm.sDBFileOption.strMD1Dbpath) | |
| 329 | + { | |
| 330 | + MTRACE_ERR(g_hEBOOT_DEBUG, "FeaturePhoneSN::LoadModemDatabase(): Incorrect database file path!"); | |
| 331 | + return META_INVALID_ARGUMENTS; | |
| 332 | + } | |
| 333 | + | |
| 334 | + if (g_sMetaComm.sDBFileOption.bDBInitModem_1) | |
| 335 | + { | |
| 336 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::META_NVRAM_Init_r(): Modem database already init done!"); | |
| 337 | + return META_SUCCESS; | |
| 338 | + } | |
| 339 | + | |
| 340 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::META_NVRAM_Init_r(): Start init modem database, DB path = %s...", g_sMetaComm.sDBFileOption.strMD1Dbpath); | |
| 341 | + | |
| 342 | + meta_result = META_NVRAM_Init_r( m_hMauiMetaHandle, g_sMetaComm.sDBFileOption.strMD1Dbpath, &db); | |
| 343 | + if (meta_result == META_SUCCESS) | |
| 344 | + { | |
| 345 | + g_sMetaComm.sDBFileOption.bDBInitModem_1 = true; | |
| 346 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_NVRAM_Init_r(): ok."); | |
| 347 | + } | |
| 348 | + else if (meta_result == META_MAUI_DB_INCONSISTENT) | |
| 349 | + { | |
| 350 | + if (g_sMetaComm.IgnoreDBInconsistent) | |
| 351 | + { | |
| 352 | + meta_result = META_SUCCESS; | |
| 353 | + g_sMetaComm.sDBFileOption.bDBInitModem_1 = true; | |
| 354 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_NVRAM_Init_r(): ok, md db inconsistent, but ignore."); | |
| 355 | + } | |
| 356 | + else | |
| 357 | + { | |
| 358 | + g_sMetaComm.sDBFileOption.bDBInitModem_1 = false; | |
| 359 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_NVRAM_Init_r(): fail, md db inconsistent."); | |
| 360 | + } | |
| 361 | + } | |
| 362 | + else | |
| 363 | + { | |
| 364 | + g_sMetaComm.sDBFileOption.bDBInitModem_1 = false; | |
| 365 | + MTRACE_ERR (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_NVRAM_Init_r(): fail, %s", ResultToString(meta_result)); | |
| 366 | + } | |
| 367 | + | |
| 368 | + return meta_result; | |
| 369 | +} | |
| 370 | + | |
| 371 | +META_RESULT FeaturePhoneSN::REQ_ReadModem_NVRAM_Start(WriteData_Type_e dataType, char *pOutData, unsigned short iRID) | |
| 372 | +{ | |
| 373 | + if(!pOutData) | |
| 374 | + { | |
| 375 | + return META_INVALID_ARGUMENTS; | |
| 376 | + } | |
| 377 | + m_bWriteNvram = true; | |
| 378 | + | |
| 379 | + int iBufLen = 0; | |
| 380 | + char *pLID = NULL; | |
| 381 | + pConductDataFunc pDataFunc = NULL; | |
| 382 | + char *pFuncName = NULL; | |
| 383 | + char *pDataType = NULL; | |
| 384 | + | |
| 385 | + switch(dataType) | |
| 386 | + { | |
| 387 | + case WRITE_BARCODE: | |
| 388 | + iBufLen = 64; | |
| 389 | + pDataType = "Barcode"; | |
| 390 | + pLID = "NVRAM_EF_BARCODE_NUM_LID"; | |
| 391 | + pDataFunc = &FeaturePhoneSN::ConductBarcodeData; | |
| 392 | + pFuncName = "ConductBarcodeData"; | |
| 393 | + break; | |
| 394 | + | |
| 395 | + case WRITE_IMEI: | |
| 396 | + iBufLen = 10; | |
| 397 | + pDataType = "IMEI"; | |
| 398 | + pLID = "NVRAM_EF_IMEI_IMEISV_LID"; | |
| 399 | + pDataFunc = ConductIMEIData; | |
| 400 | + pFuncName = "ConductIMEIData"; | |
| 401 | + break; | |
| 402 | + | |
| 403 | + case WRITE_BT: | |
| 404 | + iBufLen = 6; | |
| 405 | + pDataType = "BT"; | |
| 406 | + pLID = "NVRAM_EF_BTRADIO_MTK_BT_CHIP_LID"; | |
| 407 | + pDataFunc = &FeaturePhoneSN::ConductBTAddrData; | |
| 408 | + pFuncName = "ConductBTAddrData"; | |
| 409 | + break; | |
| 410 | + | |
| 411 | + case WRITE_WIFI: | |
| 412 | + iBufLen = 6; | |
| 413 | + pDataType = "Wifi"; | |
| 414 | + pLID = "NVRAM_EF_WNDRV_MAC_ADDRESS_LID"; | |
| 415 | + pDataFunc = &FeaturePhoneSN::ConductWifiAddrData; | |
| 416 | + pFuncName = "ConductWifiAddrData"; | |
| 417 | + break; | |
| 418 | + } | |
| 419 | + | |
| 420 | + META_RESULT meta_result = META_SUCCESS; | |
| 421 | + FT_NVRAM_READ_REQ sNVRAM_ReadReq; | |
| 422 | + FT_NVRAM_READ_CNF sNVRAM_ReadCnf; | |
| 423 | + | |
| 424 | + int iMetaTimeout = 5000; | |
| 425 | + int iReadBufSize = 0; | |
| 426 | + unsigned char pReadData[64] = {0}; | |
| 427 | + | |
| 428 | + memset(&sNVRAM_ReadReq, 0, sizeof(FT_NVRAM_READ_REQ)); | |
| 429 | + memset(&sNVRAM_ReadCnf, 0, sizeof(FT_NVRAM_READ_CNF)); | |
| 430 | + | |
| 431 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_NVRAM_GetRecLen(): Start to get nvram struct size via LID = \"%s\"...", pLID); | |
| 432 | + meta_result = META_NVRAM_GetRecLen(pLID,&iReadBufSize); | |
| 433 | + if ( META_SUCCESS != meta_result) | |
| 434 | + { | |
| 435 | + MTRACE_ERR (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_NVRAM_GetRecLen(): Get nvram struct size fail, MetaResult = %s...", ResultToString(meta_result)); | |
| 436 | + UpdateUIMsg(ResultToString(meta_result)); | |
| 437 | + return meta_result; | |
| 438 | + } | |
| 439 | + else | |
| 440 | + { | |
| 441 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_NVRAM_GetRecLen(): Get nvram struct size = %d successfully!", iReadBufSize); | |
| 442 | + if( NULL != sNVRAM_ReadCnf.buf) | |
| 443 | + { | |
| 444 | + free(sNVRAM_ReadCnf.buf); | |
| 445 | + sNVRAM_ReadCnf.buf = NULL; | |
| 446 | + } | |
| 447 | + | |
| 448 | + sNVRAM_ReadReq.LID = pLID; | |
| 449 | + sNVRAM_ReadReq.RID = iRID; | |
| 450 | + sNVRAM_ReadCnf.len = iReadBufSize; | |
| 451 | + sNVRAM_ReadCnf.buf = (unsigned char*) malloc (iReadBufSize * sizeof(unsigned char)); | |
| 452 | + if (NULL == sNVRAM_ReadCnf.buf) | |
| 453 | + { | |
| 454 | + MTRACE_ERR (g_hEBOOT_DEBUG, "FeaturePhoneSN::Malloc heap memory fail!"); | |
| 455 | + return META_FAILED; | |
| 456 | + } | |
| 457 | + } | |
| 458 | + | |
| 459 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_ReadFromModemNVRAM(): Start to read nvram data..."); | |
| 460 | + meta_result = REQ_ReadFromModemNVRAM(&sNVRAM_ReadReq, &sNVRAM_ReadCnf); | |
| 461 | + if (meta_result != META_SUCCESS ) | |
| 462 | + { | |
| 463 | + pFuncName = "FeaturePhoneSN::REQ_ReadFromModemNVRAM()"; | |
| 464 | + goto Err; | |
| 465 | + } | |
| 466 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_ReadFromModemNVRAM(): Read nvram data successfully!"); | |
| 467 | + | |
| 468 | + memcpy(pOutData, sNVRAM_ReadCnf.buf, iReadBufSize); | |
| 469 | + | |
| 470 | + if (sNVRAM_ReadCnf.buf != NULL) | |
| 471 | + { | |
| 472 | + free (sNVRAM_ReadCnf.buf); | |
| 473 | + sNVRAM_ReadCnf.buf = NULL; | |
| 474 | + } | |
| 475 | + | |
| 476 | + return meta_result; | |
| 477 | + | |
| 478 | +Err: | |
| 479 | + if (sNVRAM_ReadCnf.buf != NULL) | |
| 480 | + { | |
| 481 | + free (sNVRAM_ReadCnf.buf); | |
| 482 | + sNVRAM_ReadCnf.buf = NULL; | |
| 483 | + } | |
| 484 | + MTRACE_ERR (g_hEBOOT_DEBUG, "FeaturePhoneSN::%s cause fail! MetaResult = %s", pFuncName, ResultToString(meta_result)); | |
| 485 | + return meta_result; | |
| 486 | +} | |
| 487 | + | |
| 488 | +META_RESULT FeaturePhoneSN::REQ_WriteModem_NVRAM_Start(WriteData_Type_e dataType, char *pInData, unsigned short iRID) | |
| 489 | +{ | |
| 490 | + if(!pInData) | |
| 491 | + { | |
| 492 | + return META_INVALID_ARGUMENTS; | |
| 493 | + } | |
| 494 | + | |
| 495 | + m_bWriteNvram = true; | |
| 496 | + | |
| 497 | + int iBufLen = 0; | |
| 498 | + char *pLID = NULL; | |
| 499 | + pConductDataFunc pDataFunc = NULL; | |
| 500 | + char *pFuncName = NULL; | |
| 501 | + char *pDataType = NULL; | |
| 502 | + | |
| 503 | + switch(dataType) | |
| 504 | + { | |
| 505 | + case WRITE_BARCODE: | |
| 506 | + iBufLen = 64; | |
| 507 | + pDataType = "Barcode"; | |
| 508 | + pLID = "NVRAM_EF_BARCODE_NUM_LID"; | |
| 509 | + pDataFunc = &FeaturePhoneSN::ConductBarcodeData; | |
| 510 | + pFuncName = "ConductBarcodeData"; | |
| 511 | + break; | |
| 512 | + | |
| 513 | + case WRITE_IMEI: | |
| 514 | + iBufLen = 10; | |
| 515 | + pDataType = "IMEI"; | |
| 516 | + pLID = "NVRAM_EF_IMEI_IMEISV_LID"; | |
| 517 | + pDataFunc = &FeaturePhoneSN::ConductIMEIData; | |
| 518 | + pFuncName = "ConductIMEIData"; | |
| 519 | + break; | |
| 520 | + | |
| 521 | + case WRITE_BT: | |
| 522 | + iBufLen = 6; | |
| 523 | + pDataType = "BT"; | |
| 524 | + pLID = "NVRAM_EF_BTRADIO_MTK_BT_CHIP_LID"; | |
| 525 | + pDataFunc = &FeaturePhoneSN::ConductBTAddrData; | |
| 526 | + pFuncName = "ConductBTAddrData"; | |
| 527 | + break; | |
| 528 | + | |
| 529 | + case WRITE_WIFI: | |
| 530 | + iBufLen = 6; | |
| 531 | + pDataType = "Wifi"; | |
| 532 | + pLID = "NVRAM_EF_WNDRV_MAC_ADDRESS_LID"; | |
| 533 | + pDataFunc = &FeaturePhoneSN::ConductWifiAddrData; | |
| 534 | + pFuncName = "ConductWifiAddrData"; | |
| 535 | + break; | |
| 536 | + } | |
| 537 | + | |
| 538 | + | |
| 539 | + META_RESULT meta_result; | |
| 540 | + FT_NVRAM_WRITE_REQ sNVRAM_WriteReq; | |
| 541 | + FT_NVRAM_WRITE_CNF sNVRAM_WriteCnf; | |
| 542 | + FT_NVRAM_READ_REQ sNVRAM_ReadReq; | |
| 543 | + FT_NVRAM_READ_CNF sNVRAM_ReadCnf; | |
| 544 | + | |
| 545 | + DWORD wait_result = 0; | |
| 546 | + int iMetaTimeout = 5000; | |
| 547 | + int iWriteBufSize = 0; | |
| 548 | + unsigned char pWriteData[64] = {0}; | |
| 549 | + unsigned char pReadData[64] = {0}; | |
| 550 | + | |
| 551 | + memset(&sNVRAM_WriteReq, 0, sizeof(FT_NVRAM_WRITE_REQ)); | |
| 552 | + memset(&sNVRAM_WriteCnf, 0, sizeof(FT_NVRAM_WRITE_CNF)); | |
| 553 | + memset(&sNVRAM_ReadReq, 0, sizeof(FT_NVRAM_READ_REQ)); | |
| 554 | + memset(&sNVRAM_ReadCnf, 0, sizeof(FT_NVRAM_READ_CNF)); | |
| 555 | + | |
| 556 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_NVRAM_GetRecLen(): Start to get nvram struct size via LID = \"%s\"...", pLID); | |
| 557 | + meta_result = META_NVRAM_GetRecLen(pLID,&iWriteBufSize); | |
| 558 | + if ( META_SUCCESS != meta_result) | |
| 559 | + { | |
| 560 | + MTRACE_ERR (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_NVRAM_GetRecLen(): Get nvram struct size fail, MetaResult = %s...", ResultToString(meta_result)); | |
| 561 | + UpdateUIMsg(ResultToString(meta_result)); | |
| 562 | + return meta_result; | |
| 563 | + } | |
| 564 | + else | |
| 565 | + { | |
| 566 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_NVRAM_GetRecLen(): Get nvram struct size = %d successfully!", iWriteBufSize); | |
| 567 | + if( NULL != sNVRAM_ReadCnf.buf) | |
| 568 | + { | |
| 569 | + free(sNVRAM_ReadCnf.buf); | |
| 570 | + sNVRAM_ReadCnf.buf = NULL; | |
| 571 | + } | |
| 572 | + | |
| 573 | + sNVRAM_ReadReq.LID = pLID; | |
| 574 | + sNVRAM_ReadReq.RID = iRID; | |
| 575 | + sNVRAM_ReadCnf.len = iWriteBufSize; | |
| 576 | + sNVRAM_ReadCnf.buf = (unsigned char*) malloc (iWriteBufSize * sizeof(unsigned char)); | |
| 577 | + if (NULL == sNVRAM_ReadCnf.buf) | |
| 578 | + { | |
| 579 | + MTRACE_ERR (g_hEBOOT_DEBUG, "FeaturePhoneSN::Malloc heap memory fail!"); | |
| 580 | + return META_FAILED; | |
| 581 | + } | |
| 582 | + } | |
| 583 | + | |
| 584 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_ReadFromModemNVRAM(): Start to read nvram data..."); | |
| 585 | + meta_result = REQ_ReadFromModemNVRAM(&sNVRAM_ReadReq, &sNVRAM_ReadCnf); | |
| 586 | + if (meta_result != META_SUCCESS ) | |
| 587 | + { | |
| 588 | + pFuncName = "FeaturePhoneSN::REQ_ReadFromModemNVRAM()"; | |
| 589 | + goto Err; | |
| 590 | + } | |
| 591 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_ReadFromModemNVRAM(): Read nvram data successfully!"); | |
| 592 | + | |
| 593 | + | |
| 594 | + meta_result = (this->*pDataFunc)((char*)sNVRAM_ReadCnf.buf, iRID, pInData, iBufLen); | |
| 595 | + if (meta_result != META_SUCCESS) | |
| 596 | + { | |
| 597 | + goto Err; | |
| 598 | + } | |
| 599 | + else | |
| 600 | + { | |
| 601 | + memcpy(pWriteData, sNVRAM_ReadCnf.buf, sNVRAM_ReadCnf.len); | |
| 602 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::%s(): Conduct nvram data successfully!", pFuncName); | |
| 603 | + } | |
| 604 | + | |
| 605 | + sNVRAM_WriteReq.LID = pLID; | |
| 606 | + sNVRAM_WriteReq.RID = iRID; | |
| 607 | + sNVRAM_WriteReq.len = iWriteBufSize; | |
| 608 | + sNVRAM_WriteReq.buf = sNVRAM_ReadCnf.buf; | |
| 609 | + | |
| 610 | + //sNVRAM_WriteCnf.status = 0; | |
| 611 | + //sNVRAM_WriteCnf.LID = pLID; | |
| 612 | + sNVRAM_WriteCnf.RID = iRID; | |
| 613 | + | |
| 614 | + m_sNVRAM_OPID = iRID; | |
| 615 | + | |
| 616 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_WriteToModemNVRAM(): Start to write nvram data..."); | |
| 617 | + meta_result = REQ_WriteToModemNVRAM(&sNVRAM_WriteReq, &sNVRAM_WriteCnf); | |
| 618 | + if (meta_result != SPMETA_DLL::META_SUCCESS ) | |
| 619 | + { | |
| 620 | + pFuncName = "FeaturePhoneSN::REQ_WriteToModemNVRAM()"; | |
| 621 | + goto Err; | |
| 622 | + } | |
| 623 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_WriteToModemNVRAM(): Write nvram data successfully!"); | |
| 624 | + | |
| 625 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_WriteToModemNVRAM(): Read nvram data for check start..."); | |
| 626 | + memset(sNVRAM_ReadCnf.buf, 0 , sNVRAM_ReadCnf.len); | |
| 627 | + meta_result = REQ_ReadFromModemNVRAM (&sNVRAM_ReadReq, &sNVRAM_ReadCnf); | |
| 628 | + if (meta_result != SPMETA_DLL::META_SUCCESS ) | |
| 629 | + { | |
| 630 | + pFuncName = "FeaturePhoneSN::REQ_WriteToModemNVRAM()"; | |
| 631 | + goto Err; | |
| 632 | + } | |
| 633 | + else | |
| 634 | + { | |
| 635 | + char tmpReadData[64] = {0}; | |
| 636 | + m_bWriteNvram = false; | |
| 637 | + | |
| 638 | + memcpy(pReadData, sNVRAM_ReadCnf.buf, iBufLen); | |
| 639 | + (this->*pDataFunc)(tmpReadData, iRID, (char*)pReadData, iBufLen); | |
| 640 | + if(memcmp(pWriteData, pReadData, iBufLen) != 0) | |
| 641 | + { | |
| 642 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN: Write_%s[%s]", pDataType, pInData); | |
| 643 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN: Read_%s[%s]", pDataType, tmpReadData); | |
| 644 | + MTRACE_ERR (g_hEBOOT_DEBUG, "FeaturePhoneSN: Check nvram data FAIL!!"); | |
| 645 | + meta_result = META_FAILED; | |
| 646 | + } | |
| 647 | + else | |
| 648 | + { | |
| 649 | + | |
| 650 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN: Write_%s[%s]", pDataType, pInData); | |
| 651 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN: Read_%s[%s]", pDataType, tmpReadData); | |
| 652 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN: Check nvram data PASS!!"); | |
| 653 | + } | |
| 654 | + } | |
| 655 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_WriteToModemNVRAM(): Read nvram data for check end..."); | |
| 656 | + | |
| 657 | + if (sNVRAM_ReadCnf.buf != NULL) | |
| 658 | + { | |
| 659 | + free (sNVRAM_ReadCnf.buf); | |
| 660 | + sNVRAM_ReadCnf.buf = NULL; | |
| 661 | + } | |
| 662 | + | |
| 663 | + return meta_result; | |
| 664 | + | |
| 665 | +Err: | |
| 666 | + if (sNVRAM_ReadCnf.buf != NULL) | |
| 667 | + { | |
| 668 | + free (sNVRAM_ReadCnf.buf); | |
| 669 | + sNVRAM_ReadCnf.buf = NULL; | |
| 670 | + } | |
| 671 | + MTRACE_ERR (g_hEBOOT_DEBUG, "FeaturePhoneSN::%s cause fail! MetaResult = %s", pFuncName, ResultToString(meta_result)); | |
| 672 | + return meta_result; | |
| 673 | +} | |
| 674 | + | |
| 675 | +META_RESULT FeaturePhoneSN::REQ_BackupNvram2SDS_Start() | |
| 676 | +{ | |
| 677 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_BackupNvram2SDS_Start(): Start backup nvram to SDS/Backup_Partition if target support..."); | |
| 678 | + UINT status; | |
| 679 | + META_RESULT MetaResult = META_SUCCESS; | |
| 680 | + | |
| 681 | + UpdateUIMsg("Query target support SDS/Backup_Partition..."); | |
| 682 | + MetaResult = META_QueryIfFunctionSupportedByTarget_r(m_hMauiMetaHandle, 500, "META_MISC_EX_BackupCalibrationToStorage_r"); | |
| 683 | + | |
| 684 | + if(META_SUCCESS == MetaResult) | |
| 685 | + { | |
| 686 | + UpdateUIMsg( "Trigger backup nvram to SDS/Backup_Partition start..." ); | |
| 687 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_BackupNvram2SDS_Start(): Trigger backup nvram to SDS/Backup_Partition start..."); | |
| 688 | + MetaResult = META_MISC_EX_BackupCalibrationToStorage_r(m_hMauiMetaHandle, 5000, 0, &status); | |
| 689 | + if(MetaResult == META_SUCCESS) | |
| 690 | + { | |
| 691 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_BackupNvram2SDS_Start(): Trigger backup nvram to SDS/Backup_Partition successfully!!"); | |
| 692 | + } | |
| 693 | + else | |
| 694 | + { | |
| 695 | + MTRACE_ERR(g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_BackupNvram2SDS_Start(): Trigger backup nvram to SDS/Backup_Partition Fail, MetaResult = %s", ResultToString(MetaResult)); | |
| 696 | + } | |
| 697 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_BackupNvram2SDS_Start(): Trigger backup nvram to SDS/Backup_Partition end..."); | |
| 698 | + } | |
| 699 | + else | |
| 700 | + { | |
| 701 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_BackupNvram2SDS_Start(): Target without SDS/Backup_Partition feature"); | |
| 702 | + return META_SUCCESS;; | |
| 703 | + } | |
| 704 | + | |
| 705 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::REQ_BackupNvram2SDS_Start(): End backup nvram to SDS/Backup_Partition..."); | |
| 706 | + return MetaResult; | |
| 707 | +} | |
| 708 | + | |
| 709 | +META_RESULT FeaturePhoneSN::WriteNvramLoop() | |
| 710 | +{ | |
| 711 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::WriteNvramLoop() start..."); | |
| 712 | + | |
| 713 | + FEATURE_PHONE_STAGE_e fpStage = FP_START_STAGE; | |
| 714 | + FEATURE_PHONE_STAGE_e fpNextStage = FP_END_STAGE; | |
| 715 | + META_RESULT MetaResult = META_SUCCESS; | |
| 716 | + double fBeginProcess = 0.25; | |
| 717 | + double fStep = 0.04; | |
| 718 | + m_bBackupNvramSuccess = false; | |
| 719 | + | |
| 720 | + int iIMEINums = g_sMetaComm.sIMEIOption.iImeiNums; | |
| 721 | + | |
| 722 | + char tmpBuf[2048] = {0}; | |
| 723 | + if (g_sMetaComm.bCheckCalFlag || g_sMetaComm.bCheckFtFlag) | |
| 724 | + { | |
| 725 | + if(REQ_ReadModem_NVRAM_Start(WRITE_BARCODE, tmpBuf, 1) == META_SUCCESS) | |
| 726 | + { | |
| 727 | + bool bCheckPass = true; | |
| 728 | + bCheckPass = CheckCalFinalTestStatus(tmpBuf); | |
| 729 | + if (bCheckPass == false) | |
| 730 | + { | |
| 731 | + return META_FAILED; | |
| 732 | + } | |
| 733 | + } | |
| 734 | + } | |
| 735 | + | |
| 736 | + while((fpStage != FP_END_STAGE) && (*m_pMetaStopFlag != BOOT_STOP)) | |
| 737 | + { | |
| 738 | + switch(fpStage) | |
| 739 | + { | |
| 740 | + case FP_START_STAGE: | |
| 741 | + fpNextStage = FP_BARCODE_STAGE; | |
| 742 | + break; | |
| 743 | + | |
| 744 | + case FP_BARCODE_STAGE: | |
| 745 | + fBeginProcess += fStep; | |
| 746 | + if (g_sMetaComm.sWriteOption.bWriteBarcode) | |
| 747 | + { | |
| 748 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::Barcode = \"%s\"", m_sScanData.strBarcode); | |
| 749 | + MetaResult = REQ_WriteModem_NVRAM_Start(WRITE_BARCODE, m_sScanData.strBarcode, 1); | |
| 750 | + if (MetaResult == META_SUCCESS) | |
| 751 | + { | |
| 752 | + fpNextStage = FP_IMEI_STAGE; | |
| 753 | + } | |
| 754 | + else | |
| 755 | + { | |
| 756 | + UpdateUIMsg("FeaturePhoneSN::Barcode : MetaResult = %s", ResultToString(MetaResult)); | |
| 757 | + fpNextStage = FP_END_STAGE; | |
| 758 | + } | |
| 759 | + } | |
| 760 | + else | |
| 761 | + { | |
| 762 | + fpNextStage = FP_IMEI_STAGE; | |
| 763 | + } | |
| 764 | + break; | |
| 765 | + | |
| 766 | + case FP_IMEI_STAGE: | |
| 767 | + | |
| 768 | + if (g_sMetaComm.sWriteOption.bWriteIMEI) | |
| 769 | + { | |
| 770 | + for (int i = 0; i < iIMEINums; i++) | |
| 771 | + { | |
| 772 | + fBeginProcess += fStep; | |
| 773 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::IMEI[%d] = \"%s\"", i, m_sScanData.strIMEI[i]); | |
| 774 | + MetaResult = REQ_WriteModem_NVRAM_Start(WRITE_IMEI, m_sScanData.strIMEI[i], i+1); | |
| 775 | + if (MetaResult == META_SUCCESS) | |
| 776 | + { | |
| 777 | + if (i+1 == iIMEINums) | |
| 778 | + { | |
| 779 | + if (g_sMetaComm.sIMEIOption.bLockIMEI) | |
| 780 | + { | |
| 781 | + MetaResult = META_NVRAM_LockDown_r(m_hMauiMetaHandle, 5000); | |
| 782 | + if (MetaResult == META_SUCCESS) | |
| 783 | + { | |
| 784 | + fpNextStage = FP_BT_ADDRESS_STAGE; | |
| 785 | + } | |
| 786 | + else | |
| 787 | + { | |
| 788 | + fpNextStage = FP_END_STAGE; | |
| 789 | + } | |
| 790 | + } | |
| 791 | + else | |
| 792 | + { | |
| 793 | + fpNextStage = FP_BT_ADDRESS_STAGE; | |
| 794 | + } | |
| 795 | + | |
| 796 | + break; | |
| 797 | + } | |
| 798 | + } | |
| 799 | + else | |
| 800 | + { | |
| 801 | + if (m_bNeedBackupIMEI) | |
| 802 | + { | |
| 803 | + strncpy(g_AutoGenData.sIMEI.Next, m_strBackupIMEI, strlen(m_strBackupIMEI)); | |
| 804 | + } | |
| 805 | + UpdateUIMsg("FeaturePhoneSN::IMEI[%d] : MetaResult = %s", i, ResultToString(MetaResult)); | |
| 806 | + fpNextStage = FP_END_STAGE; | |
| 807 | + break; | |
| 808 | + } | |
| 809 | + } | |
| 810 | + } | |
| 811 | + else | |
| 812 | + { | |
| 813 | + fpNextStage = FP_BT_ADDRESS_STAGE; | |
| 814 | + } | |
| 815 | + break; | |
| 816 | + | |
| 817 | + case FP_BT_ADDRESS_STAGE: | |
| 818 | + if (g_sMetaComm.sWriteOption.bWriteBT) | |
| 819 | + { | |
| 820 | + fBeginProcess += fStep; | |
| 821 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::BT = \"%s\"", m_sScanData.strBTAddr); | |
| 822 | + MetaResult = REQ_WriteModem_NVRAM_Start(WRITE_BT, m_sScanData.strBTAddr, 1); | |
| 823 | + if (MetaResult == META_SUCCESS) | |
| 824 | + { | |
| 825 | + fpNextStage = FP_WIFI_ADDRESS_STAGE; | |
| 826 | + } | |
| 827 | + else | |
| 828 | + { | |
| 829 | + UpdateUIMsg("FeaturePhoneSN::BT : MetaResult = %s", ResultToString(MetaResult)); | |
| 830 | + fpNextStage = FP_END_STAGE; | |
| 831 | + } | |
| 832 | + } | |
| 833 | + else | |
| 834 | + { | |
| 835 | + fpNextStage = FP_WIFI_ADDRESS_STAGE; | |
| 836 | + } | |
| 837 | + break; | |
| 838 | + | |
| 839 | + case FP_WIFI_ADDRESS_STAGE: | |
| 840 | + if (g_sMetaComm.sWriteOption.bWriteWifi) | |
| 841 | + { | |
| 842 | + fBeginProcess += fStep; | |
| 843 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::Wifi = \"%s\"", m_sScanData.strWifiAddr); | |
| 844 | + MetaResult = REQ_WriteModem_NVRAM_Start(WRITE_WIFI, m_sScanData.strWifiAddr, 1); | |
| 845 | + if (MetaResult == META_SUCCESS) | |
| 846 | + { | |
| 847 | + fpNextStage = FP_BACKUP_NVRAM_STAGE; | |
| 848 | + } | |
| 849 | + else | |
| 850 | + { | |
| 851 | + UpdateUIMsg("FeaturePhoneSN::Wifi : MetaResult = %s", ResultToString(MetaResult)); | |
| 852 | + fpNextStage = FP_END_STAGE; | |
| 853 | + } | |
| 854 | + } | |
| 855 | + else | |
| 856 | + { | |
| 857 | + fpNextStage = FP_BACKUP_NVRAM_STAGE; | |
| 858 | + } | |
| 859 | + break; | |
| 860 | + | |
| 861 | + case FP_BACKUP_NVRAM_STAGE: | |
| 862 | + fBeginProcess += fStep; | |
| 863 | + MetaResult = REQ_BackupNvram2SDS_Start(); | |
| 864 | + if (MetaResult == META_SUCCESS) | |
| 865 | + { | |
| 866 | + m_bBackupNvramSuccess = true; | |
| 867 | + } | |
| 868 | + else | |
| 869 | + { | |
| 870 | + m_bBackupNvramSuccess = false; | |
| 871 | + } | |
| 872 | + fpNextStage = FP_END_STAGE; | |
| 873 | + break; | |
| 874 | + } | |
| 875 | + | |
| 876 | + fpStage = fpNextStage; | |
| 877 | + } | |
| 878 | + | |
| 879 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::WriteNvramLoop() end..."); | |
| 880 | + return MetaResult; | |
| 881 | +} | |
| 882 | + | |
| 883 | +void FeaturePhoneSN::ThreadMainEntryPoint() | |
| 884 | +{ | |
| 885 | + bool bNeedScanData = false; | |
| 886 | + | |
| 887 | + /*For dual talk project | |
| 888 | + * Due to dual talk project can`t switch back and forth between ap and modem | |
| 889 | + * When target type select feature phone, mean will write modem nvram, so need disable write ap nvram | |
| 890 | + */ | |
| 891 | + bool bWriteBT = g_sMetaComm.sWriteOption.bWriteBT; | |
| 892 | + bool bWriteWifi = g_sMetaComm.sWriteOption.bWriteWifi; | |
| 893 | + if (g_sMetaComm.bDualTalk) | |
| 894 | + { | |
| 895 | + g_sMetaComm.sWriteOption.bWriteBT = false; | |
| 896 | + g_sMetaComm.sWriteOption.bWriteWifi = false; | |
| 897 | + } | |
| 898 | + | |
| 899 | + bNeedScanData = NeedScanData(); | |
| 900 | + if (bNeedScanData == false) | |
| 901 | + { | |
| 902 | + PopupMsgBox("Warning", MB_OK|MB_ICONWARNING, "At least select one write option!!"); | |
| 903 | + return; | |
| 904 | + } | |
| 905 | + | |
| 906 | + META_RESULT MetaResult = META_SUCCESS; | |
| 907 | + bool bAnyOperationFail = false; | |
| 908 | + char strChipID[100] = {0}; | |
| 909 | + | |
| 910 | + if (g_sMetaComm.bSwithTool) | |
| 911 | + EnableUSBSwitch(); | |
| 912 | + | |
| 913 | + m_hMauiMetaHandle = INVALID_META_HANDLE; | |
| 914 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::Meta_Init(): Start..."); | |
| 915 | + MetaResult = MetaHandle_Init(); | |
| 916 | + if (MetaResult != META_SUCCESS) | |
| 917 | + { | |
| 918 | + bAnyOperationFail = true; | |
| 919 | + *m_pMetaStopFlag = BOOT_STOP; | |
| 920 | + } | |
| 921 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::Meta_Init(): End..."); | |
| 922 | + | |
| 923 | + CScanData scanDlg; | |
| 924 | + while((*m_pMetaStopFlag != BOOT_STOP) && (IDOK == scanDlg.DoModal())) | |
| 925 | + { | |
| 926 | + DebugOnOff(true); | |
| 927 | + MTRACE(g_hEBOOT_DEBUG, "------------------------------------ START -------------------------------------"); | |
| 928 | + LogConfig(); | |
| 929 | + bAnyOperationFail = false; | |
| 930 | + UpdateMainDlgUI(false, NORMAL); | |
| 931 | + | |
| 932 | + EnableStartBTN(false); | |
| 933 | + | |
| 934 | + SNThread_Init(); | |
| 935 | + UpdateProgress(0.05); | |
| 936 | + | |
| 937 | + SetupMetaModeParameters(); | |
| 938 | + UpdateProgress(0.10); | |
| 939 | + | |
| 940 | + EnableStartBTN(true); | |
| 941 | + | |
| 942 | + MetaResult = (META_RESULT)EnterModemMeta(); | |
| 943 | + if (MetaResult != META_SUCCESS) | |
| 944 | + { | |
| 945 | + bAnyOperationFail = true; | |
| 946 | + UpdateUIMsg("EnterModemMeta() : MetaResult = %s", ResultToString(MetaResult)); | |
| 947 | + goto End; | |
| 948 | + } | |
| 949 | + UpdateProgress(0.15); | |
| 950 | + | |
| 951 | + UpdateUIMsg("Start load and init database..."); | |
| 952 | + MetaResult = LoadModemDatabase(0); | |
| 953 | + if (MetaResult != META_SUCCESS) | |
| 954 | + { | |
| 955 | + bAnyOperationFail = true; | |
| 956 | + UpdateUIMsg("LoadModemDatabase() : MetaResult = %s", ResultToString(MetaResult)); | |
| 957 | + PopupMsgBox("Error", MB_OK|MB_ICONERROR, "LoadModemDatabase() : MetaResult = %s", ResultToString(MetaResult)); | |
| 958 | + goto End; | |
| 959 | + } | |
| 960 | + UpdateProgress(0.20); | |
| 961 | + | |
| 962 | + /* | |
| 963 | + META_MISC_GetRID_r(m_hMauiMetaHandle, 5000, (unsigned char*)strChipID,16); | |
| 964 | + if(strlen(strChipID) != 0) | |
| 965 | + { | |
| 966 | + MTRACE (g_hEBOOT_DEBUG, "FeaturePhoneSN::META_MISC_GetRID_r(): Get chip_id success, chip_id = %s!", strChipID); | |
| 967 | + goto End; | |
| 968 | + } | |
| 969 | + */ | |
| 970 | + | |
| 971 | + EnableStartBTN(false); | |
| 972 | + UpdateProgress(0.22); | |
| 973 | + UpdateUIMsg("Start loop write data to nvram..."); | |
| 974 | + MetaResult = WriteNvramLoop(); | |
| 975 | + if (MetaResult != META_SUCCESS) | |
| 976 | + { | |
| 977 | + bAnyOperationFail = true; | |
| 978 | + goto End; | |
| 979 | + } | |
| 980 | + | |
| 981 | +End: | |
| 982 | + if (m_bStopBeforeUSBInsert == true) | |
| 983 | + { | |
| 984 | + UpdateProgress(0.0); | |
| 985 | + UpdateUIMsg("..."); | |
| 986 | + } | |
| 987 | + else | |
| 988 | + { | |
| 989 | + if (bAnyOperationFail) | |
| 990 | + { | |
| 991 | + m_Process->SendMessage(PBM_SETBARCOLOR, 0, RGB(255, 0, 0)); | |
| 992 | + UpdateUICountResult(FAIL); | |
| 993 | + } | |
| 994 | + else | |
| 995 | + { | |
| 996 | + UpdateUIMsg("All Operate successfully!!"); | |
| 997 | + MTRACE(g_hEBOOT_DEBUG, "FeaturePhoneSN::All Operate successfully!!"); | |
| 998 | +#ifdef _AUTO_GEN_FEATURE_ | |
| 999 | + if (g_AutoGenData.bEnableAutoGen) | |
| 1000 | + { | |
| 1001 | + UpdateAutoGenParaToSetupFile(); | |
| 1002 | + } | |
| 1003 | +#endif | |
| 1004 | + UpdateUICountResult(PASS); | |
| 1005 | + } | |
| 1006 | + | |
| 1007 | + ExitModemMeta(); | |
| 1008 | + | |
| 1009 | + UpdateProgress(1.0); | |
| 1010 | + } | |
| 1011 | + | |
| 1012 | + EnableStartBTN(true); | |
| 1013 | + MTRACE(g_hEBOOT_DEBUG, "------------------------------------ END -------------------------------------"); | |
| 1014 | + DebugOnOff(false); | |
| 1015 | + } | |
| 1016 | + | |
| 1017 | + g_sMetaComm.sWriteOption.bWriteBT = bWriteBT; | |
| 1018 | + g_sMetaComm.sWriteOption.bWriteWifi = bWriteWifi; | |
| 1019 | + | |
| 1020 | + if (g_sMetaComm.bSwithTool) | |
| 1021 | + DisableUSBSwitch(); | |
| 1022 | + | |
| 1023 | + MetaHandle_DeInit(); | |
| 1024 | + UpdateMainDlgUI(true, CANCEL); | |
| 1025 | +} | |
| \ No newline at end of file | ... | ... |
Execute/FPexc.h
0 → 100644
| 1 | +#ifndef _FP_EXC_H_ | |
| 2 | +#define _FP_EXC_H_ | |
| 3 | + | |
| 4 | +#define _NEW_META_API_ | |
| 5 | +#include "SNbase.h" | |
| 6 | + | |
| 7 | +class FeaturePhoneSN : public SNBase | |
| 8 | +{ | |
| 9 | +public: | |
| 10 | + FeaturePhoneSN(); | |
| 11 | + virtual ~FeaturePhoneSN(); | |
| 12 | + | |
| 13 | +protected: | |
| 14 | + virtual void SetupMetaModeParameters(); | |
| 15 | + virtual void ThreadMainEntryPoint(); | |
| 16 | + | |
| 17 | + virtual META_RESULT MetaHandle_Init(); | |
| 18 | + virtual void MetaHandle_DeInit(); | |
| 19 | + virtual META_RESULT ModemMetaHandle_Init(); | |
| 20 | + virtual void ModemMetaHandle_DeInit(); | |
| 21 | + | |
| 22 | + virtual META_RESULT EnterModemMeta(); | |
| 23 | + virtual META_RESULT ExitModemMeta(); | |
| 24 | + | |
| 25 | + virtual META_RESULT LoadModemDatabase(int MDindex); | |
| 26 | + | |
| 27 | + virtual META_RESULT REQ_ReadModem_NVRAM_Start(WriteData_Type_e dataType, char *pOutData, unsigned short iRID); | |
| 28 | + virtual META_RESULT REQ_WriteModem_NVRAM_Start(WriteData_Type_e dataType, char *pInData, unsigned short iRID); | |
| 29 | + virtual META_RESULT REQ_BackupNvram2SDS_Start(); | |
| 30 | + virtual META_RESULT WriteNvramLoop(); | |
| 31 | +}; | |
| 32 | + | |
| 33 | +#endif | |
| \ No newline at end of file | ... | ... |
Execute/SNbase.cpp
0 → 100644
| 1 | +#include "StdAfx.h" | |
| 2 | +#include "Common.h" | |
| 3 | +#include "SNbase.h" | |
| 4 | +#include "SN Writer.h" | |
| 5 | +#include "SN WriterDlg.h" | |
| 6 | + | |
| 7 | +#include <shlwapi.h> | |
| 8 | + | |
| 9 | +CSNWriterDlg *g_pMainDlg; | |
| 10 | + | |
| 11 | +//////////////////////////////////////////////////// | |
| 12 | + | |
| 13 | +const int PortEnumHelper::ms_iFilterLen = 1024; | |
| 14 | +const int PortEnumHelper::ms_iFilterNum = PortEnumHelper::ms_iFilterLen/20; | |
| 15 | +const int PortEnumHelper::ms_iPortNum = 20; | |
| 16 | + | |
| 17 | +PortEnumHelper::PortEnumHelper() | |
| 18 | + : m_szFilter(NULL) | |
| 19 | + , m_aiFlag(NULL) | |
| 20 | + , m_astPort(NULL) | |
| 21 | +{ | |
| 22 | + memset(&m_stFiler, 0, sizeof(SP_COM_FILTER_LIST_S)); | |
| 23 | +} | |
| 24 | +PortEnumHelper::~PortEnumHelper() | |
| 25 | +{ | |
| 26 | + int i = 0; | |
| 27 | + | |
| 28 | + delete [] m_szFilter; | |
| 29 | + delete [] m_aiFlag; | |
| 30 | + delete [] m_stFiler.m_ppFilterID; | |
| 31 | + delete [] m_astPort; | |
| 32 | +} | |
| 33 | + | |
| 34 | +void PortEnumHelper::SetFilter(SP_FILTER_TYPE_E type, const char * filter, int flag /*= 0*/, bool bAppend /*= false*/) | |
| 35 | +{ | |
| 36 | + char * szFilter = NULL; | |
| 37 | + size_t nLen = 0u, nPos = 0u; | |
| 38 | + | |
| 39 | + if (m_szFilter == NULL) | |
| 40 | + m_szFilter = new char[ms_iFilterLen]; | |
| 41 | + if (m_stFiler.m_ppFilterID == NULL) | |
| 42 | + { | |
| 43 | + m_stFiler.m_ppFilterID = new char * [ms_iFilterNum]; | |
| 44 | + m_aiFlag = new int [ms_iFilterNum]; | |
| 45 | + } | |
| 46 | + | |
| 47 | + if (filter == NULL || filter[0] == '\0') | |
| 48 | + return; | |
| 49 | + | |
| 50 | + if (!bAppend) | |
| 51 | + { | |
| 52 | + memset(m_szFilter, 0, ms_iFilterLen); | |
| 53 | + memset(m_stFiler.m_ppFilterID, 0, sizeof(char *)*ms_iFilterNum); | |
| 54 | + m_stFiler.m_uCount = 0; | |
| 55 | + szFilter = m_szFilter; | |
| 56 | + } | |
| 57 | + else if (m_stFiler.m_uCount == 0) | |
| 58 | + szFilter = m_szFilter; | |
| 59 | + else | |
| 60 | + { | |
| 61 | + nLen = strlen(m_stFiler.m_ppFilterID[m_stFiler.m_uCount - 1]); | |
| 62 | + szFilter = m_stFiler.m_ppFilterID[m_stFiler.m_uCount - 1] + nLen + 1; | |
| 63 | + } | |
| 64 | + | |
| 65 | + strcpy(szFilter, filter); | |
| 66 | + m_stFiler.m_eType = type; | |
| 67 | + | |
| 68 | + nLen = strlen(szFilter); | |
| 69 | + while (nPos < nLen) | |
| 70 | + { | |
| 71 | + nPos += strspn(szFilter+nPos, " \t,;"); | |
| 72 | + if (nPos >= nLen) | |
| 73 | + break; | |
| 74 | + m_stFiler.m_ppFilterID[m_stFiler.m_uCount] = szFilter+nPos; | |
| 75 | + m_aiFlag[m_stFiler.m_uCount] = flag; | |
| 76 | + m_stFiler.m_uCount ++; | |
| 77 | + | |
| 78 | + nPos += strcspn(szFilter+nPos, " \t,;"); | |
| 79 | + if (nPos >= nLen) | |
| 80 | + break; | |
| 81 | + szFilter[nPos++] = '\0'; | |
| 82 | + } | |
| 83 | +} | |
| 84 | + | |
| 85 | +SP_COM_FILTER_LIST_S * PortEnumHelper::GetFilter() | |
| 86 | +{ | |
| 87 | + return &m_stFiler; | |
| 88 | +} | |
| 89 | + | |
| 90 | +int PortEnumHelper::GetFlag(int index) | |
| 91 | +{ | |
| 92 | + if (index >= (int)m_stFiler.m_uCount) | |
| 93 | + return -1; | |
| 94 | + return m_aiFlag[index]; | |
| 95 | +} | |
| 96 | + | |
| 97 | +SP_COM_PROPERTY_S * PortEnumHelper::GetPorts(bool bClear /*= false*/) | |
| 98 | +{ | |
| 99 | + if (m_astPort == NULL) | |
| 100 | + { | |
| 101 | + m_astPort = new SP_COM_PROPERTY_S[ms_iPortNum]; | |
| 102 | + memset(m_astPort, 0, sizeof(SP_COM_PROPERTY_S)*ms_iPortNum); | |
| 103 | + } | |
| 104 | + else if (bClear) | |
| 105 | + memset(m_astPort, 0, sizeof(SP_COM_PROPERTY_S)*ms_iPortNum); | |
| 106 | + | |
| 107 | + return m_astPort; | |
| 108 | +} | |
| 109 | + | |
| 110 | +//////////////////////////////////////////////////// | |
| 111 | + | |
| 112 | +SNBase::SNBase() | |
| 113 | +{ | |
| 114 | + memset(&m_tMetaReq_Ex, 0, sizeof(m_tMetaReq_Ex)); | |
| 115 | + memset(&m_tMetaConnReport_Ex, 0, sizeof(m_tMetaConnReport_Ex)); | |
| 116 | + | |
| 117 | + m_hThread = NULL; | |
| 118 | + m_iThreadID = 0; | |
| 119 | + m_hMauiMetaHandle = 0; | |
| 120 | + m_hSPMetaHandle = 0; | |
| 121 | + m_sNVRAM_OPID = 0; | |
| 122 | + g_iMetaStopFlag = 0; | |
| 123 | + m_pMetaStopFlag = &g_iMetaStopFlag; | |
| 124 | + m_bWriteNvram = false; | |
| 125 | + m_bWriteModemNvram = false; | |
| 126 | + m_bTargetInMetaMode = false; | |
| 127 | + m_bNeedBackupIMEI = false; | |
| 128 | + m_hReadFromNVRAMEvent = NULL; | |
| 129 | + m_hWriteToNVRAMEvent = NULL; | |
| 130 | + | |
| 131 | + memset(m_strLogDir_Sub, 0, MAX_PATH); | |
| 132 | + | |
| 133 | + memset(m_sIMEISV, 0, sizeof(IMEISV_struct_T)*4); | |
| 134 | + memset(&m_sScanData, 0, sizeof(ScanData_struct)); | |
| 135 | +} | |
| 136 | + | |
| 137 | +SNBase::~SNBase() | |
| 138 | +{ | |
| 139 | + if (g_sMetaComm.bSwithTool) | |
| 140 | + { | |
| 141 | + DisableUSBSwitch(); | |
| 142 | + } | |
| 143 | +} | |
| 144 | + | |
| 145 | +UINT SNBase::ThreadStaticEntryPoint(LPVOID pThis) | |
| 146 | +{ | |
| 147 | + SNBase * pthX = (SNBase*)pThis; // the tricky cast | |
| 148 | + pthX->ThreadMainEntryPoint(); // now call the true entry-point-function | |
| 149 | + return 1; | |
| 150 | +} | |
| 151 | + | |
| 152 | +void SNBase::SetProgress() | |
| 153 | +{ | |
| 154 | + m_iProcessRange = 1000; | |
| 155 | + m_Process->SetRange(0, m_iProcessRange); | |
| 156 | + m_Process->SendMessage(PBM_SETBARCOLOR, 0, RGB(0, 0, 255)); | |
| 157 | + UpdateProgress(0.01); | |
| 158 | +} | |
| 159 | + | |
| 160 | +int SNBase::UpdateUIMsg(const char * strMsg, ...) | |
| 161 | +{ | |
| 162 | + int iRet = 0; | |
| 163 | + char szBuf[256] = ""; | |
| 164 | + va_list varg; | |
| 165 | + | |
| 166 | + va_start(varg, strMsg); | |
| 167 | + iRet = vsprintf(szBuf, strMsg, varg); | |
| 168 | + va_end(varg); | |
| 169 | + | |
| 170 | + g_pMainDlg->SetDlgItemText(IDC_OPERATE_INFO, szBuf); | |
| 171 | + | |
| 172 | + return iRet; | |
| 173 | +} | |
| 174 | + | |
| 175 | +void SNBase::UpdateUICountResult(WriteNvram_Status_e eWriteStatus) | |
| 176 | +{ | |
| 177 | + static UINT totalNums = 0; | |
| 178 | + static UINT passNums = 0; | |
| 179 | + static UINT failNums = 0; | |
| 180 | + | |
| 181 | + char strTotal[20] = {0}; | |
| 182 | + char strPass[20] = {0}; | |
| 183 | + char strFail[20] = {0}; | |
| 184 | + | |
| 185 | + //For the user click 'STOP' button before USB still not insert | |
| 186 | + if (m_bStopBeforeUSBInsert == true) | |
| 187 | + { | |
| 188 | + return; | |
| 189 | + } | |
| 190 | + | |
| 191 | + totalNums += 1; | |
| 192 | + if (eWriteStatus == PASS) | |
| 193 | + { | |
| 194 | + passNums += 1; | |
| 195 | + } | |
| 196 | + else | |
| 197 | + { | |
| 198 | + failNums += 1; | |
| 199 | + } | |
| 200 | + sprintf(strTotal, "%d", totalNums); | |
| 201 | + sprintf(strPass, "%d", passNums); | |
| 202 | + sprintf(strFail, "%d", failNums); | |
| 203 | + g_pMainDlg->SetDlgItemText(IDC_COUNT_TOTAL, strTotal); | |
| 204 | + g_pMainDlg->SetDlgItemText(IDC_COUNT_PASS, strPass); | |
| 205 | + g_pMainDlg->SetDlgItemText(IDC_COUNT_FAIL, strFail); | |
| 206 | + | |
| 207 | + UpdateMainDlgUI(true, eWriteStatus); | |
| 208 | +} | |
| 209 | + | |
| 210 | +void SNBase::EnableStartBTN(bool bEnable) | |
| 211 | +{ | |
| 212 | + g_pMainDlg->EnableStartBTN(bEnable); | |
| 213 | +} | |
| 214 | + | |
| 215 | +void SNBase::UpdateMainDlgUI(bool bEnable, WriteNvram_Status_e eWriteStatus) | |
| 216 | +{ | |
| 217 | + if (bEnable == false) | |
| 218 | + { | |
| 219 | + g_pMainDlg->DisableUIItem(); | |
| 220 | + } | |
| 221 | + else | |
| 222 | + { | |
| 223 | + g_pMainDlg->EnableUIItem(); | |
| 224 | + } | |
| 225 | + g_pMainDlg->UpdateOperateResult(eWriteStatus); | |
| 226 | + | |
| 227 | +} | |
| 228 | + | |
| 229 | +void SNBase::UpdateProgress(double dPercent) | |
| 230 | +{ | |
| 231 | + if (dPercent >= 1) | |
| 232 | + { | |
| 233 | + dPercent = 1; | |
| 234 | + } | |
| 235 | + | |
| 236 | + int curPos = (int)(dPercent * m_iProcessRange); | |
| 237 | + m_Process->SetPos(curPos); | |
| 238 | +} | |
| 239 | + | |
| 240 | +void SNBase::PopupMsgBox(const char* strTilte, UINT uType, const char* strMsg, ...) | |
| 241 | +{ | |
| 242 | + char szBuf[256] = ""; | |
| 243 | + | |
| 244 | + va_list varg; | |
| 245 | + va_start(varg, strMsg); | |
| 246 | + vsprintf(szBuf, strMsg, varg); | |
| 247 | + va_end(varg); | |
| 248 | + g_pMainDlg->PopupMsgBox(strTilte, uType, strMsg); | |
| 249 | +} | |
| 250 | + | |
| 251 | +bool SNBase::NeedScanData() | |
| 252 | +{ | |
| 253 | + if (g_sMetaComm.sWriteOption.bWriteBarcode || | |
| 254 | + g_sMetaComm.sWriteOption.bWriteIMEI || | |
| 255 | + g_sMetaComm.sWriteOption.bWriteBT || | |
| 256 | + g_sMetaComm.sWriteOption.bWriteWifi || | |
| 257 | + g_sMetaComm.sWriteOption.bWriteEthernetMac || | |
| 258 | + g_sMetaComm.sWriteOption.bWriteDrmkeyMCID || | |
| 259 | + g_sMetaComm.sWriteOption.bWriteMeid || | |
| 260 | + g_sMetaComm.sWriteOption.bWriteEsn || | |
| 261 | + g_sMetaComm.sWriteOption.bWriteSerialNo) | |
| 262 | + { | |
| 263 | + return true; | |
| 264 | + } | |
| 265 | + else | |
| 266 | + { | |
| 267 | + return false; | |
| 268 | + } | |
| 269 | +} | |
| 270 | + | |
| 271 | +CheckCalFlag_Status_e SNBase::CheckCalibrationStatus(const char* strBarcode) | |
| 272 | +{ | |
| 273 | + CheckCalFlag_Status_e eCheckCalFlag = CAL_FLAG_PASS; | |
| 274 | + if (strBarcode[60] == '1' && strBarcode[61] == '0') //Calibration Pass | |
| 275 | + { | |
| 276 | + eCheckCalFlag = CAL_FLAG_PASS; | |
| 277 | + } | |
| 278 | + else if (strBarcode[60] == '0' && strBarcode[61] == '1')//Calibration Fail | |
| 279 | + { | |
| 280 | + eCheckCalFlag = CAL_FLAG_FAILED; | |
| 281 | + } | |
| 282 | + else | |
| 283 | + { | |
| 284 | + eCheckCalFlag = CAL_FLAG_NOT_EXIST; | |
| 285 | + } | |
| 286 | + | |
| 287 | + return eCheckCalFlag; | |
| 288 | + | |
| 289 | +} | |
| 290 | + | |
| 291 | +bool SNBase::CheckCalFinalTestStatus(const char* strBarcode) | |
| 292 | +{ | |
| 293 | + MTRACE(g_hEBOOT_DEBUG, "SNBase::CheckCalFinalTestStatus(): Check calibration & nsft flag start..."); | |
| 294 | + | |
| 295 | + if (g_sMetaComm.bCheckCalFlag) | |
| 296 | + { | |
| 297 | + CheckCalFlag_Status_e eCheckCalFlag = CAL_FLAG_PASS; | |
| 298 | + eCheckCalFlag = CheckCalibrationStatus(strBarcode); | |
| 299 | + if (eCheckCalFlag != CAL_FLAG_PASS) | |
| 300 | + { | |
| 301 | + if (eCheckCalFlag == CAL_FLAG_FAILED) | |
| 302 | + { | |
| 303 | + UpdateUIMsg("Calibration Flag : Calibration Fail!"); | |
| 304 | + MTRACE_ERR(g_hEBOOT_DEBUG, "SNBase::CheckCalFinalTestStatus(): Calibration Flag : Calibration Fail!"); | |
| 305 | + } | |
| 306 | + else if (eCheckCalFlag == CAL_FLAG_NOT_EXIST) | |
| 307 | + { | |
| 308 | + UpdateUIMsg("Calibration Flag : No exist calibration flag!!"); | |
| 309 | + MTRACE_ERR(g_hEBOOT_DEBUG, "SNBase::CheckCalFinalTestStatus(): Calibration Flag : No exist calibration flag!!"); | |
| 310 | + } | |
| 311 | + | |
| 312 | + return false; | |
| 313 | + } | |
| 314 | + | |
| 315 | + } | |
| 316 | + | |
| 317 | + if (g_sMetaComm.bCheckFtFlag) | |
| 318 | + { | |
| 319 | + CheckFinalTestFlag_Status_e eCheckFTFlag = FT_FLAG_PASS; | |
| 320 | + eCheckFTFlag = CheckFinalTestStatus(strBarcode); | |
| 321 | + if (eCheckFTFlag != FT_FLAG_PASS) | |
| 322 | + { | |
| 323 | + if (eCheckFTFlag == FT_FLAG_FAILED) | |
| 324 | + { | |
| 325 | + UpdateUIMsg("FinalTest Flag : Final test Fail!"); | |
| 326 | + MTRACE_ERR(g_hEBOOT_DEBUG, "SNBase::CheckCalFinalTestStatus(): FinalTest Flag : Final test Fail!"); | |
| 327 | + } | |
| 328 | + else if (eCheckFTFlag == FT_FLAG_NOT_EXIST) | |
| 329 | + { | |
| 330 | + UpdateUIMsg("FinalTest Flag : No exist final test flag!!"); | |
| 331 | + MTRACE_ERR(g_hEBOOT_DEBUG, "SNBase::CheckCalFinalTestStatus(): FinalTest Flag : No exist final test flag!!"); | |
| 332 | + } | |
| 333 | + return false; | |
| 334 | + } | |
| 335 | + } | |
| 336 | + | |
| 337 | + MTRACE(g_hEBOOT_DEBUG, "SNBase::CheckCalFinalTestStatus(): Check calibration & nsft flag Pass!!"); | |
| 338 | + | |
| 339 | + MTRACE(g_hEBOOT_DEBUG, "SNBase::CheckCalFinalTestStatus(): Check calibration & nsft flag end..."); | |
| 340 | + return true; | |
| 341 | +} | |
| 342 | + | |
| 343 | +CheckFinalTestFlag_Status_e SNBase::CheckFinalTestStatus(const char* strBarcode) | |
| 344 | +{ | |
| 345 | + CheckFinalTestFlag_Status_e eCheckFTFlag = FT_FLAG_PASS; | |
| 346 | + if (strBarcode[62] == 'P' ) //Final Test Pass | |
| 347 | + { | |
| 348 | + eCheckFTFlag = FT_FLAG_PASS; | |
| 349 | + } | |
| 350 | + else if (strBarcode[62] == 'F')//Final Test Fail | |
| 351 | + { | |
| 352 | + eCheckFTFlag = FT_FLAG_FAILED; | |
| 353 | + } | |
| 354 | + else | |
| 355 | + { | |
| 356 | + eCheckFTFlag = FT_FLAG_NOT_EXIST; | |
| 357 | + } | |
| 358 | + | |
| 359 | + return eCheckFTFlag; | |
| 360 | +} | |
| 361 | + | |
| 362 | +META_RESULT SNBase::ConductBarcodeData(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize) | |
| 363 | +{ | |
| 364 | + char flag_wire; // wireless flag | |
| 365 | + char flag_cal[2]; // calibration flag | |
| 366 | + char flag_nsft; // nsft flag | |
| 367 | + | |
| 368 | + flag_wire = pOutData[59]; | |
| 369 | + flag_cal[0] = pOutData[60]; | |
| 370 | + flag_cal[1] = pOutData[61]; | |
| 371 | + flag_nsft = pOutData[62]; | |
| 372 | + | |
| 373 | + strncpy(pOutData, pInDatabuf, BARCODE_MAX_LENGTH); | |
| 374 | + | |
| 375 | + if (flag_wire != '\0' && flag_cal[0] != '\0' && flag_cal[1] != '\0' && flag_nsft != '\0') | |
| 376 | + { | |
| 377 | + int barcode_len; | |
| 378 | + barcode_len = strlen(pOutData); | |
| 379 | + if (barcode_len < 59) | |
| 380 | + memset(pOutData + barcode_len, 0x20, 59 - barcode_len); | |
| 381 | + | |
| 382 | + pOutData[59] = flag_wire; | |
| 383 | + pOutData[60] = flag_cal[0]; | |
| 384 | + pOutData[61] = flag_cal[1]; | |
| 385 | + pOutData[62] = flag_nsft; | |
| 386 | + pOutData[63] = '\0'; | |
| 387 | + } | |
| 388 | + | |
| 389 | + // Sync to AP Prod_Info | |
| 390 | + strncpy(m_sScanData.strBarcode, pOutData, BARCODE_MAX_LENGTH); | |
| 391 | + | |
| 392 | + return META_SUCCESS; | |
| 393 | +} | |
| 394 | + | |
| 395 | +META_RESULT SNBase::ConductIMEIData(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize) | |
| 396 | +{ | |
| 397 | + if (!pInDatabuf || !pOutData) | |
| 398 | + { | |
| 399 | + return META_INVALID_ARGUMENTS; | |
| 400 | + } | |
| 401 | + /* | |
| 402 | + //UI input = "123459876543210" storage in nvram will be: | |
| 403 | + //imei[0] = 0x21 | |
| 404 | + //imei[1] = 0x43 | |
| 405 | + //imei[2] = 0x95 | |
| 406 | + //imei[3] = 0x78 | |
| 407 | + //imei[4] = 0x56 | |
| 408 | + //imei[5] = 0x34 | |
| 409 | + //imei[6] = 0x12 | |
| 410 | + //imei[7] = 0xf0 | |
| 411 | + */ | |
| 412 | + META_RESULT MetaResult; | |
| 413 | + char *pFuncName; | |
| 414 | + | |
| 415 | + if (m_bWriteNvram == false)//read from nvram | |
| 416 | + { | |
| 417 | + MTRACE (g_hEBOOT_DEBUG, "SNBase::Decompose_IMEI(): Start to Decompose IMEI[%d]...", RID_para-1); | |
| 418 | + pFuncName = "SNBase::Decompose_IMEI(): Decompose IMEI"; | |
| 419 | + MetaResult = Decompose_IMEI(pOutData, RID_para, pInDatabuf, bufSize); | |
| 420 | + } | |
| 421 | + else //write to nvram | |
| 422 | + { | |
| 423 | + MTRACE (g_hEBOOT_DEBUG, "SNBase::Compose_IMEI(): Start to Compose IMEI[%d]...", RID_para-1); | |
| 424 | + pFuncName = "SNBase::Compose_IMEI(): Compose IMEI"; | |
| 425 | + MetaResult = Compose_IMEI( pOutData, RID_para, pInDatabuf, bufSize, g_sMetaComm.sIMEIOption.bCheckSum); | |
| 426 | + } | |
| 427 | + | |
| 428 | + if(MetaResult == META_SUCCESS) | |
| 429 | + { | |
| 430 | + MTRACE (g_hEBOOT_DEBUG, "%s successfully!", pFuncName); | |
| 431 | + } | |
| 432 | + else | |
| 433 | + { | |
| 434 | + MTRACE_ERR (g_hEBOOT_DEBUG, "%s Fail! MetaResult = %s", pFuncName, ResultToString(MetaResult)); | |
| 435 | + } | |
| 436 | + return MetaResult; | |
| 437 | +} | |
| 438 | + | |
| 439 | +META_RESULT SNBase::ConductBTAddrData(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize) | |
| 440 | +{ | |
| 441 | + if (!pInDatabuf || !pOutData) | |
| 442 | + { | |
| 443 | + return META_INVALID_ARGUMENTS; | |
| 444 | + } | |
| 445 | + | |
| 446 | + /* | |
| 447 | + *** Feature phone *** | |
| 448 | + * UI input = "1234567890AC" storage in Modem nvram will be: | |
| 449 | + * btAddr[0] = 0xAC | |
| 450 | + * btAddr[1] = 0x90 | |
| 451 | + * btAddr[2] = 0x78 | |
| 452 | + * btAddr[3] = 0x56 | |
| 453 | + * btAddr[4] = 0x34 | |
| 454 | + * btAddr[5] = 0x12 | |
| 455 | + --------------------------------------------------------- | |
| 456 | + *** Smart Phone *** | |
| 457 | + * UI input = "1234567890AC" storage in AP nvram will be: | |
| 458 | + * btAddr[0] = 0x12 | |
| 459 | + * btAddr[1] = 0x34 | |
| 460 | + * btAddr[2] = 0x56 | |
| 461 | + * btAddr[3] = 0x78 | |
| 462 | + * btAddr[4] = 0x90 | |
| 463 | + * btAddr[5] = 0xAC | |
| 464 | + */ | |
| 465 | + | |
| 466 | + int tmpCh; | |
| 467 | + if (g_sMetaComm.eTargetType == FEATURE_PHONE) | |
| 468 | + { | |
| 469 | + if (m_bWriteNvram == false) | |
| 470 | + { | |
| 471 | + for (int i = 0; i < bufSize; i++) | |
| 472 | + { | |
| 473 | + tmpCh = (pInDatabuf[i] & 15); //15 -->0000 1111, get Low 4Bits | |
| 474 | + if (0 <= tmpCh && tmpCh <= 9) //0 - 9 | |
| 475 | + { | |
| 476 | + pOutData[(5-i)*2 + 1] = tmpCh + '0'; | |
| 477 | + } | |
| 478 | + else if (10 <= tmpCh && tmpCh <= 15) //a - f | |
| 479 | + { | |
| 480 | + pOutData[(5-i)*2 + 1] = (tmpCh - 10) + 'A'; | |
| 481 | + } | |
| 482 | + | |
| 483 | + tmpCh = ((pInDatabuf[i] & 240) >> 4); //240 -->1111 0000, get High 4Bits | |
| 484 | + if (0 <= tmpCh && tmpCh <= 9) //0 - 9 | |
| 485 | + { | |
| 486 | + pOutData[(5-i)*2] = tmpCh + '0'; | |
| 487 | + } | |
| 488 | + else if (10 <= tmpCh && tmpCh <= 15) //a - f | |
| 489 | + { | |
| 490 | + pOutData[(5-i)*2] = (tmpCh - 10) + 'A'; | |
| 491 | + } | |
| 492 | + } | |
| 493 | + } | |
| 494 | + else if(m_bWriteNvram == true) | |
| 495 | + { | |
| 496 | + strupr(pInDatabuf); //转换字符串中的小写字母为大写 | |
| 497 | + for (int i = 0; i < bufSize; i++) | |
| 498 | + { | |
| 499 | + if ('0'<= pInDatabuf[((5-i)*2)] && pInDatabuf[((5-i)*2)] <= '9') | |
| 500 | + { | |
| 501 | + tmpCh = pInDatabuf[((5-i)*2)] - '0'; | |
| 502 | + tmpCh = ((tmpCh << 4) & 240); //240 -->1111 0000, get High 4bits | |
| 503 | + } | |
| 504 | + else if('A'<= pInDatabuf[((5-i)*2)] && pInDatabuf[((5-i)*2)] <= 'F') | |
| 505 | + { | |
| 506 | + tmpCh = pInDatabuf[((5-i)*2)] - 'A' + 10; | |
| 507 | + tmpCh = ((tmpCh << 4) & 240); //240 -->1111 0000, get High 4bits | |
| 508 | + } | |
| 509 | + | |
| 510 | + if ('0'<= pInDatabuf[((5-i)*2 + 1)] && pInDatabuf[((5-i)*2 + 1)] <= '9') | |
| 511 | + { | |
| 512 | + tmpCh += pInDatabuf[((5-i)*2 + 1)] - '0'; //get Low 4bits | |
| 513 | + } | |
| 514 | + else if('A'<= pInDatabuf[((5-i)*2 + 1)] && pInDatabuf[((5-i)*2 + 1)] <= 'F') | |
| 515 | + { | |
| 516 | + tmpCh += pInDatabuf[((5-i)*2 + 1)] - 'A' + 10; //get Low 4bits | |
| 517 | + } | |
| 518 | + | |
| 519 | + pOutData[i] = tmpCh; | |
| 520 | + } | |
| 521 | + } | |
| 522 | + }//end if (g_sMetaComm.eTargetType == FEATURE_PHONE) | |
| 523 | + else | |
| 524 | + { | |
| 525 | + if (m_bWriteNvram == false) | |
| 526 | + { | |
| 527 | + for (int i = 0; i < bufSize; i++) | |
| 528 | + { | |
| 529 | + tmpCh = (pInDatabuf[i] & 15); //15 -->0000 1111, get Low 4Bits | |
| 530 | + if (0 <= tmpCh && tmpCh <= 9) //0 - 9 | |
| 531 | + { | |
| 532 | + pOutData[(i*2 + 1)] = tmpCh + '0'; | |
| 533 | + } | |
| 534 | + else if (10 <= tmpCh && tmpCh <= 15) //A - F | |
| 535 | + { | |
| 536 | + pOutData[(i*2 + 1)] = (tmpCh - 10) + 'A'; | |
| 537 | + } | |
| 538 | + | |
| 539 | + //tmpCh = ((pInDatabuf[i] >> 4) & 15); | |
| 540 | + tmpCh = ((pInDatabuf[i] & 240) >> 4); //240 -->1111 0000, get High 4Bits | |
| 541 | + if (0 <= tmpCh && tmpCh <= 9) //0 - 9 | |
| 542 | + { | |
| 543 | + pOutData[i*2] = tmpCh + '0'; | |
| 544 | + } | |
| 545 | + else if (10 <= tmpCh && tmpCh <= 15) //A - F | |
| 546 | + { | |
| 547 | + pOutData[i*2] = (tmpCh - 10) + 'A'; | |
| 548 | + } | |
| 549 | + } | |
| 550 | + } | |
| 551 | + else if(m_bWriteNvram == true) | |
| 552 | + { | |
| 553 | + strupr(pInDatabuf); //转换字符串中的小写字母为大写 | |
| 554 | + for (int i = 0; i < bufSize; i++) | |
| 555 | + { | |
| 556 | + if ('0'<= pInDatabuf[i*2] && pInDatabuf[i*2] <= '9') | |
| 557 | + { | |
| 558 | + tmpCh = pInDatabuf[i*2] - '0'; | |
| 559 | + tmpCh = ((tmpCh << 4) & 240); //240 -->1111 0000, get High 4bits | |
| 560 | + } | |
| 561 | + else if('A'<= pInDatabuf[i*2] && pInDatabuf[i*2] <= 'F') | |
| 562 | + { | |
| 563 | + tmpCh = pInDatabuf[i*2] - 'A' + 10; | |
| 564 | + tmpCh = ((tmpCh << 4) & 240); //240 -->1111 0000, get High 4bits | |
| 565 | + } | |
| 566 | + | |
| 567 | + if ('0'<= pInDatabuf[(i*2 + 1)] && pInDatabuf[(i*2 + 1)] <= '9') | |
| 568 | + { | |
| 569 | + tmpCh += pInDatabuf[(i*2 + 1)] - '0'; //get Low 4bits | |
| 570 | + } | |
| 571 | + else if('A'<= pInDatabuf[(i*2 + 1)] && pInDatabuf[(i*2 + 1)] <= 'F') | |
| 572 | + { | |
| 573 | + tmpCh += pInDatabuf[(i*2 + 1)] - 'A' + 10; //get Low 4bits | |
| 574 | + } | |
| 575 | + | |
| 576 | + pOutData[i] = tmpCh; | |
| 577 | + } | |
| 578 | + } | |
| 579 | + } | |
| 580 | + | |
| 581 | + return META_SUCCESS; | |
| 582 | +} | |
| 583 | + | |
| 584 | +/* | |
| 585 | +META_RESULT SNBase::ConductVendorIDData(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize) | |
| 586 | +{ | |
| 587 | + if (!pInDatabuf || !pOutData) | |
| 588 | + { | |
| 589 | + return META_INVALID_ARGUMENTS; | |
| 590 | + } | |
| 591 | + | |
| 592 | + *** Smart Phone *** | |
| 593 | + * UI input = "1234567890AC" storage in AP nvram will be: | |
| 594 | + * btAddr[0] = 0x12 | |
| 595 | + * btAddr[1] = 0x34 | |
| 596 | + * btAddr[2] = 0x56 | |
| 597 | + * btAddr[3] = 0x78 | |
| 598 | + * btAddr[4] = 0x90 | |
| 599 | + * btAddr[5] = 0xAC | |
| 600 | + // | |
| 601 | + | |
| 602 | + | |
| 603 | + int tmpCh; | |
| 604 | + if (m_bWriteNvram == false) | |
| 605 | + { | |
| 606 | + for (int i = 0; i < bufSize; i++) | |
| 607 | + { | |
| 608 | + tmpCh = (pInDatabuf[i] & 15); //15 -->0000 1111, get Low 4Bits | |
| 609 | + if (0 <= tmpCh && tmpCh <= 9) //0 - 9 | |
| 610 | + { | |
| 611 | + pOutData[(i*2 + 1)] = tmpCh + '0'; | |
| 612 | + } | |
| 613 | + else if (10 <= tmpCh && tmpCh <= 15) //a - f | |
| 614 | + { | |
| 615 | + pOutData[(i*2 + 1)] = (tmpCh - 10) + 'A'; | |
| 616 | + } | |
| 617 | + | |
| 618 | + //tmpCh = ((pInDatabuf[i] >> 4) & 15); | |
| 619 | + tmpCh = ((pInDatabuf[i] & 240) >> 4); //240 -->1111 0000, get High 4Bits | |
| 620 | + if (0 <= tmpCh && tmpCh <= 9) //0 - 9 | |
| 621 | + { | |
| 622 | + pOutData[i*2] = tmpCh + '0'; | |
| 623 | + } | |
| 624 | + else if (10 <= tmpCh && tmpCh <= 15) //A - F | |
| 625 | + { | |
| 626 | + pOutData[i*2] = (tmpCh - 10) + 'A'; | |
| 627 | + } | |
| 628 | + } | |
| 629 | + } | |
| 630 | + else if(m_bWriteNvram == true) | |
| 631 | + { | |
| 632 | + strupr(pInDatabuf); //转换字符串中的小写字母为大写 | |
| 633 | + for (int i = 0; i < bufSize; i++) | |
| 634 | + { | |
| 635 | + if ('0'<= pInDatabuf[i*2] && pInDatabuf[i*2] <= '9') | |
| 636 | + { | |
| 637 | + tmpCh = pInDatabuf[i*2] - '0'; | |
| 638 | + tmpCh = ((tmpCh << 4) & 240); //240 -->1111 0000, get High 4bits | |
| 639 | + } | |
| 640 | + else if('A'<= pInDatabuf[i*2] && pInDatabuf[i*2] <= 'F') | |
| 641 | + { | |
| 642 | + tmpCh = pInDatabuf[i*2] - 'A' + 10; | |
| 643 | + tmpCh = ((tmpCh << 4) & 240); //240 -->1111 0000, get High 4bits | |
| 644 | + } | |
| 645 | + | |
| 646 | + if ('0'<= pInDatabuf[(i*2 + 1)] && pInDatabuf[(i*2 + 1)] <= '9') | |
| 647 | + { | |
| 648 | + tmpCh += pInDatabuf[(i*2 + 1)] - '0'; //get Low 4bits | |
| 649 | + } | |
| 650 | + else if('A'<= pInDatabuf[(i*2 + 1)] && pInDatabuf[(i*2 + 1)] <= 'F') | |
| 651 | + { | |
| 652 | + tmpCh += pInDatabuf[(i*2 + 1)] - 'A' + 10; //get Low 4bits | |
| 653 | + } | |
| 654 | + | |
| 655 | + pOutData[i] = tmpCh; | |
| 656 | + }end for | |
| 657 | + } | |
| 658 | + | |
| 659 | + | |
| 660 | + return META_SUCCESS; | |
| 661 | +} | |
| 662 | + | |
| 663 | + | |
| 664 | +*/ | |
| 665 | + | |
| 666 | +META_RESULT SNBase::ConductWifiAddrData(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize) | |
| 667 | +{ | |
| 668 | + if (!pInDatabuf || !pOutData) | |
| 669 | + { | |
| 670 | + return META_INVALID_ARGUMENTS; | |
| 671 | + } | |
| 672 | + | |
| 673 | + //strupr(pInDatabuf); //转换字符串中的小写字母为大写 | |
| 674 | + //strlwr(pInDatabuf); //转换字符串的大写字母为小写 | |
| 675 | + /* | |
| 676 | + * UI input = "1234567890AC" storage in AP nvram will be: | |
| 677 | + * wifiAddr[0] = 0x12 | |
| 678 | + * wifiAddr[1] = 0x34 | |
| 679 | + * wifiAddr[2] = 0x56 | |
| 680 | + * wifiAddr[3] = 0x78 | |
| 681 | + * wifiAddr[4] = 0x90 | |
| 682 | + * wifiAddr[5] = 0xAC | |
| 683 | + */ | |
| 684 | + | |
| 685 | + int tmpCh; | |
| 686 | + if (m_bWriteNvram == false) | |
| 687 | + { | |
| 688 | + for (int i = 0; i < bufSize; i++) | |
| 689 | + { | |
| 690 | + tmpCh = (pInDatabuf[i] & 15); //15 -->0000 1111, get Low 4Bits | |
| 691 | + if (0 <= tmpCh && tmpCh <= 9) //0 - 9 | |
| 692 | + { | |
| 693 | + pOutData[(i*2 + 1)] = tmpCh + '0'; | |
| 694 | + } | |
| 695 | + else if (10 <= tmpCh && tmpCh <= 15) //a - f | |
| 696 | + { | |
| 697 | + pOutData[(i*2 + 1)] = (tmpCh - 10) + 'A'; | |
| 698 | + } | |
| 699 | + | |
| 700 | + //tmpCh = ((pInDatabuf[i] >> 4) & 15); | |
| 701 | + tmpCh = ((pInDatabuf[i] & 240) >> 4); //240 -->1111 0000, get High 4Bits | |
| 702 | + if (0 <= tmpCh && tmpCh <= 9) //0 - 9 | |
| 703 | + { | |
| 704 | + pOutData[i*2] = tmpCh + '0'; | |
| 705 | + } | |
| 706 | + else if (10 <= tmpCh && tmpCh <= 15) //A - F | |
| 707 | + { | |
| 708 | + pOutData[i*2] = (tmpCh - 10) + 'A'; | |
| 709 | + } | |
| 710 | + } | |
| 711 | + } | |
| 712 | + else if(m_bWriteNvram == true) | |
| 713 | + { | |
| 714 | + strupr(pInDatabuf); //转换字符串中的小写字母为大写 | |
| 715 | + for (int i = 0; i < bufSize; i++) | |
| 716 | + { | |
| 717 | + if ('0'<= pInDatabuf[i*2] && pInDatabuf[i*2] <= '9') | |
| 718 | + { | |
| 719 | + tmpCh = pInDatabuf[i*2] - '0'; | |
| 720 | + tmpCh = ((tmpCh << 4) & 240); //240 -->1111 0000, get High 4bits | |
| 721 | + } | |
| 722 | + else if('A'<= pInDatabuf[i*2] && pInDatabuf[i*2] <= 'F') | |
| 723 | + { | |
| 724 | + tmpCh = pInDatabuf[i*2] - 'A' + 10; | |
| 725 | + tmpCh = ((tmpCh << 4) & 240); //240 -->1111 0000, get High 4bits | |
| 726 | + } | |
| 727 | + | |
| 728 | + if ('0'<= pInDatabuf[(i*2 + 1)] && pInDatabuf[(i*2 + 1)] <= '9') | |
| 729 | + { | |
| 730 | + tmpCh += pInDatabuf[(i*2 + 1)] - '0'; //get Low 4bits | |
| 731 | + } | |
| 732 | + else if('A'<= pInDatabuf[(i*2 + 1)] && pInDatabuf[(i*2 + 1)] <= 'F') | |
| 733 | + { | |
| 734 | + tmpCh += pInDatabuf[(i*2 + 1)] - 'A' + 10; //get Low 4bits | |
| 735 | + } | |
| 736 | + | |
| 737 | + pOutData[i] = tmpCh; | |
| 738 | + } | |
| 739 | + } | |
| 740 | + | |
| 741 | + return META_SUCCESS; | |
| 742 | +} | |
| 743 | + | |
| 744 | +META_RESULT SNBase::ConductEthernetMacAddrData(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize) | |
| 745 | +{ | |
| 746 | + //strupr(pInDatabuf); //转换字符串中的小写字母为大写 | |
| 747 | + //strlwr(pInDatabuf); //转换字符串的大写字母为小写 | |
| 748 | + /* | |
| 749 | + * UI input = "1234567890AC" storage in AP nvram will be: | |
| 750 | + * ethMacAddr[0] = 0x12 | |
| 751 | + * ethMacAddr[1] = 0x34 | |
| 752 | + * ethMacAddr[2] = 0x56 | |
| 753 | + * ethMacAddr[3] = 0x78 | |
| 754 | + * ethMacAddr[4] = 0x90 | |
| 755 | + * ethMacAddr[5] = 0xAC | |
| 756 | + * | |
| 757 | + * The same as wifi address, so just need to call ConductWifiAddrData() function | |
| 758 | + */ | |
| 759 | + return ConductWifiAddrData(pOutData, RID_para, pInDatabuf, bufSize); | |
| 760 | +} | |
| 761 | + | |
| 762 | +META_RESULT SNBase::ConductAudioTemperatureData(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize) | |
| 763 | +{ | |
| 764 | + META_RESULT MetaResult = META_SUCCESS; | |
| 765 | + | |
| 766 | + AUDIO_SPREAKER_MONITOR_PARAM_STRUCT sWriteTempStruct; | |
| 767 | + memset(&sWriteTempStruct, 0, sizeof(AUDIO_SPREAKER_MONITOR_PARAM_STRUCT)); | |
| 768 | + memcpy(&sWriteTempStruct, pInDatabuf, sizeof(AUDIO_SPREAKER_MONITOR_PARAM_STRUCT)); | |
| 769 | + | |
| 770 | + if (m_bWriteNvram == true) | |
| 771 | + { | |
| 772 | + sWriteTempStruct.temp_initial = atof(pInDatabuf); | |
| 773 | + memcpy(pOutData, &sWriteTempStruct, sizeof(AUDIO_SPREAKER_MONITOR_PARAM_STRUCT)); | |
| 774 | + } | |
| 775 | + else | |
| 776 | + { | |
| 777 | + MetaResult = META_FAILED; | |
| 778 | + } | |
| 779 | + | |
| 780 | + return MetaResult; | |
| 781 | +} | |
| 782 | + | |
| 783 | +META_RESULT SNBase::Decompose_IMEI(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize) | |
| 784 | +{ | |
| 785 | + META_RESULT MetaResult = META_NVRAM_Decompose_IMEISV(&m_sIMEISV[RID_para-1], pInDatabuf, bufSize); | |
| 786 | + if (MetaResult == META_SUCCESS) | |
| 787 | + { | |
| 788 | + for (int i=0; i<IMEI_ARRAY_LEN; i++) | |
| 789 | + { | |
| 790 | + pOutData[i] = m_sIMEISV[RID_para-1].imei[i]; | |
| 791 | + } | |
| 792 | + } | |
| 793 | + | |
| 794 | + return MetaResult; | |
| 795 | +} | |
| 796 | + | |
| 797 | +META_RESULT SNBase::Compose_IMEI(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize, bool bChecksum) | |
| 798 | +{ | |
| 799 | + META_RESULT MetaResult = META_SUCCESS; | |
| 800 | + if (bChecksum) | |
| 801 | + { | |
| 802 | + int ret_i; | |
| 803 | + char checksum_c; | |
| 804 | + unsigned short checksum_v; | |
| 805 | + | |
| 806 | + MTRACE(g_hEBOOT_DEBUG, "SNBase::Compose_IMEI(): Calculate checksum bit start..."); | |
| 807 | + MetaResult = META_NVRAM_Calculate_IMEI_CD(pInDatabuf, &checksum_v); | |
| 808 | + if (MetaResult == META_SUCCESS) | |
| 809 | + { | |
| 810 | + checksum_c = checksum_v + '0'; | |
| 811 | + | |
| 812 | + if (pInDatabuf[IMEI_MAX_LENGTH - 1] != '\0' && pInDatabuf[IMEI_MAX_LENGTH - 1] != checksum_c) | |
| 813 | + { | |
| 814 | + char szInfo[256]; | |
| 815 | + | |
| 816 | + MTRACE_WARN (g_hEBOOT_DEBUG, "SNBase::Compose_IMEI(): check IMEI checksum bit fail."); | |
| 817 | + sprintf(szInfo, "The input IMEI %s checksum bit dismatch:\r\n" | |
| 818 | + "origin checksum %c, right checksum %c\r\n" | |
| 819 | + "Are you sure to continue anyway?", | |
| 820 | + pInDatabuf, pInDatabuf[IMEI_MAX_LENGTH - 1], checksum_c); | |
| 821 | + ret_i = ::MessageBox(NULL, szInfo, "Warning", | |
| 822 | + MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2|MB_SYSTEMMODAL|MB_SETFOREGROUND|MB_TOPMOST); | |
| 823 | + if (ret_i != IDYES) | |
| 824 | + return META_FAILED; | |
| 825 | + | |
| 826 | + pInDatabuf[IMEI_MAX_LENGTH - 1] = checksum_c; | |
| 827 | + } | |
| 828 | + } | |
| 829 | + else | |
| 830 | + { | |
| 831 | + MTRACE_ERR(g_hEBOOT_DEBUG, "SNBase::Compose_IMEI(): Calculate checksum bit fail, MetaResult = %s", ResultToString(MetaResult)); | |
| 832 | + return MetaResult; | |
| 833 | + } | |
| 834 | + MTRACE(g_hEBOOT_DEBUG, "SNBase::Compose_IMEI(): Calculate checksum bit end..."); | |
| 835 | + } | |
| 836 | + | |
| 837 | + for (int i = 0; i < IMEI_ARRAY_LEN; i++) | |
| 838 | + { | |
| 839 | + m_sIMEISV[RID_para - 1].imei[i] = pInDatabuf[i]; | |
| 840 | + } | |
| 841 | + | |
| 842 | + MetaResult = META_NVRAM_Compose_IMEISV_ex(&m_sIMEISV[RID_para - 1], pOutData, bufSize, bChecksum); | |
| 843 | + return MetaResult; | |
| 844 | +} | |
| 845 | + | |
| 846 | +META_RESULT SNBase::REQ_ReadFromModemNVRAM(FT_NVRAM_READ_REQ *psNVRAM_ReadReq, FT_NVRAM_READ_CNF *psNVRAM_ReadCnf) | |
| 847 | +{ | |
| 848 | + META_RESULT meta_result; | |
| 849 | + meta_result = META_NVRAM_Read_Ex_r(m_hMauiMetaHandle, | |
| 850 | + 15000, | |
| 851 | + psNVRAM_ReadReq, | |
| 852 | + psNVRAM_ReadCnf); | |
| 853 | + | |
| 854 | + if (meta_result != META_SUCCESS) | |
| 855 | + { | |
| 856 | + MTRACE_ERR (g_hEBOOT_DEBUG, "SNBase::META_NVRAM_Read_Ex_r(): Read nvram data fail! MetaResult = %s", | |
| 857 | + ResultToString(meta_result)); | |
| 858 | + } | |
| 859 | + | |
| 860 | + return meta_result; | |
| 861 | +} | |
| 862 | + | |
| 863 | +META_RESULT SNBase::REQ_WriteToModemNVRAM(FT_NVRAM_WRITE_REQ *psNVRAM_WriteReq, FT_NVRAM_WRITE_CNF *psNVRAM_WriteCnf) | |
| 864 | +{ | |
| 865 | + META_RESULT meta_result; | |
| 866 | + meta_result = META_NVRAM_Write_Ex_r(m_hMauiMetaHandle, | |
| 867 | + 15000, | |
| 868 | + psNVRAM_WriteReq, | |
| 869 | + psNVRAM_WriteCnf); | |
| 870 | + | |
| 871 | + if (meta_result != META_SUCCESS) | |
| 872 | + { | |
| 873 | + MTRACE_ERR (g_hEBOOT_DEBUG, "SNBase::META_NVRAM_Write_Ex_r(): Write nvram data fail! MetaResult = %s", ResultToString(meta_result)); | |
| 874 | + return meta_result; | |
| 875 | + } | |
| 876 | + | |
| 877 | + return meta_result; | |
| 878 | +} | |
| 879 | + | |
| 880 | +void SNBase::GetScanData(ScanData_struct &pScanData) | |
| 881 | +{ | |
| 882 | + memset(&m_sScanData, 0, sizeof(ScanData_struct)); | |
| 883 | + | |
| 884 | + if (g_sMetaComm.sWriteOption.bWriteBarcode) | |
| 885 | + strncpy(m_sScanData.strBarcode, pScanData.strBarcode, strlen(pScanData.strBarcode)); | |
| 886 | + | |
| 887 | + if (g_sMetaComm.sWriteOption.bWriteBT) | |
| 888 | + strncpy(m_sScanData.strBTAddr, pScanData.strBTAddr, strlen(pScanData.strBTAddr)); | |
| 889 | + | |
| 890 | + if (g_sMetaComm.sWriteOption.bWriteWifi) | |
| 891 | + strncpy(m_sScanData.strWifiAddr, pScanData.strWifiAddr, strlen(pScanData.strWifiAddr)); | |
| 892 | + | |
| 893 | + if (g_sMetaComm.sWriteOption.bWriteEthernetMac) | |
| 894 | + strncpy(m_sScanData.strEthernetMac, pScanData.strEthernetMac, strlen(pScanData.strEthernetMac)); | |
| 895 | + | |
| 896 | + if (g_sMetaComm.sWriteOption.bWriteDrmkeyMCID) | |
| 897 | + strncpy(m_sScanData.strDrmkeyMCID, pScanData.strDrmkeyMCID, strlen(pScanData.strDrmkeyMCID)); | |
| 898 | + | |
| 899 | + if (g_sMetaComm.sWriteOption.bWriteIMEI) | |
| 900 | + { | |
| 901 | + for (int i = 0; i < g_sMetaComm.sIMEIOption.iImeiNums; i++) | |
| 902 | + strncpy(m_sScanData.strIMEI[i], pScanData.strIMEI[i], strlen(pScanData.strIMEI[i])); | |
| 903 | + | |
| 904 | + if (g_AutoGenData.bAutoGenIMEI && g_sMetaComm.sIMEIOption.iImeiNums >= 2) | |
| 905 | + { | |
| 906 | + m_bNeedBackupIMEI = true; | |
| 907 | + strncpy(m_strBackupIMEI, pScanData.strIMEI[0], strlen(pScanData.strIMEI[0])); | |
| 908 | + } | |
| 909 | + } | |
| 910 | + | |
| 911 | + if (g_sMetaComm.sWriteOption.bWriteSerialNo) | |
| 912 | + strncpy(m_sScanData.strSerialNo, pScanData.strSerialNo, strlen(pScanData.strSerialNo)); | |
| 913 | + | |
| 914 | + if (g_sMetaComm.sIMEIOption.bDualIMEISame) | |
| 915 | + strncpy(m_sScanData.strIMEI[1], pScanData.strIMEI[0], strlen(pScanData.strIMEI[0])); | |
| 916 | + | |
| 917 | + if (g_sMetaComm.sWriteOption.bWriteMeid) | |
| 918 | + strncpy(m_sScanData.strMeid, pScanData.strMeid, strlen(pScanData.strMeid)); | |
| 919 | + | |
| 920 | + if (g_sMetaComm.sWriteOption.bWriteEsn) | |
| 921 | + strncpy(m_sScanData.strEsn, pScanData.strEsn, strlen(pScanData.strEsn)); | |
| 922 | +} | |
| 923 | + | |
| 924 | +void SNBase::DebugOnOff(bool bOn) | |
| 925 | +{ | |
| 926 | + static bool bDebugOn = false; | |
| 927 | + | |
| 928 | + if (bOn && !bDebugOn) | |
| 929 | + { | |
| 930 | + int ret_i = 0; | |
| 931 | + char log_file[MAX_PATH] = ""; | |
| 932 | + SYSTEMTIME time; | |
| 933 | + | |
| 934 | + // make sure log folder exist | |
| 935 | + ret_i = ::PathFileExists(g_sMetaComm.strLogDir); | |
| 936 | + if (ret_i == FALSE) | |
| 937 | + { | |
| 938 | + ret_i = ::CreateDirectory(g_sMetaComm.strLogDir, NULL); | |
| 939 | + if (ret_i == FALSE) | |
| 940 | + { | |
| 941 | + if (strcmp(g_sMetaComm.strLogDir, "C:\\SNWriter_LOG\\") == 0) | |
| 942 | + { | |
| 943 | + g_pMainDlg->MessageBox("Log Dir not exist and can not be created.", | |
| 944 | + "Warning", | |
| 945 | + MB_ICONWARNING | MB_OK); | |
| 946 | + return; | |
| 947 | + } | |
| 948 | + | |
| 949 | + g_pMainDlg->MessageBox("Log Dir not exist and can not be created.\r\nUse default C:\\SNWriter_LOG\\.", | |
| 950 | + "Warning", | |
| 951 | + MB_ICONWARNING | MB_OK); | |
| 952 | + | |
| 953 | + strcpy(g_sMetaComm.strLogDir, "C:\\SNWriter_LOG\\"); | |
| 954 | + ret_i = ::CreateDirectory(g_sMetaComm.strLogDir, NULL); | |
| 955 | + if (ret_i == FALSE) | |
| 956 | + { | |
| 957 | + g_pMainDlg->MessageBox("Can not create default log dir C:\\SNWriter_LOG\\", | |
| 958 | + "Warning", | |
| 959 | + MB_ICONWARNING | MB_OK); | |
| 960 | + return; | |
| 961 | + } | |
| 962 | + } | |
| 963 | + } | |
| 964 | + | |
| 965 | + ::GetLocalTime(&time); | |
| 966 | + sprintf(m_strLogDir_Sub, "%s%04u-%02u-%02u-%02u-%02u-%02u\\", | |
| 967 | + g_sMetaComm.strLogDir, time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond); | |
| 968 | + | |
| 969 | + ret_i = ::CreateDirectory(m_strLogDir_Sub, NULL); | |
| 970 | + if (ret_i == FALSE) | |
| 971 | + { | |
| 972 | + g_pMainDlg->MessageBox("Can not create default sub log dir.", | |
| 973 | + "Warning", | |
| 974 | + MB_ICONWARNING | MB_OK); | |
| 975 | + m_strLogDir_Sub[0] = '\0'; | |
| 976 | + return; | |
| 977 | + } | |
| 978 | + | |
| 979 | + /*ret_i = ::SHCreateDirectoryEx(g_pMainDlg != NULL ? g_pMainDlg->GetSafeHwnd() : NULL, m_strLogDir_Sub, NULL); | |
| 980 | + if (ret_i != ERROR_SUCCESS) | |
| 981 | + { | |
| 982 | + sprintf(m_strLogDir_Sub, "C:\\SNWriter_LOG\\%04u-%02u-%02u-%02u-%02u-%02u\\", | |
| 983 | + g_sMetaComm.strLogDir, time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond); | |
| 984 | + | |
| 985 | + ::SHCreateDirectoryEx(g_pMainDlg != NULL ? g_pMainDlg->GetSafeHwnd() : NULL, m_strLogDir_Sub, NULL); | |
| 986 | + }*/ | |
| 987 | + | |
| 988 | + sprintf(log_file, "%sSN Writer.log", m_strLogDir_Sub); | |
| 989 | + _Xboot_DebugOn_With_FilePath(log_file); | |
| 990 | + sprintf(log_file, "%sBROM_DLL.log", m_strLogDir_Sub); | |
| 991 | + Brom_Debug_SetLogFilename(log_file); | |
| 992 | + Brom_DebugOn(); | |
| 993 | + sprintf(log_file, "%sMETA_DLL.log", m_strLogDir_Sub); | |
| 994 | + META_DebugOn_With_FilePath(log_file); | |
| 995 | + sprintf(log_file, "%sSP_BROM_DLL.log", m_strLogDir_Sub); | |
| 996 | + SP_Brom_Debug_SetLogFilename(log_file); | |
| 997 | + SP_Brom_DebugOn(); | |
| 998 | + sprintf(log_file, "%sSP_META_DLL.log", m_strLogDir_Sub); | |
| 999 | + SPMETA_DLL::SP_META_DebugOnThePath(log_file); | |
| 1000 | + | |
| 1001 | + MTRACE(g_hEBOOT_DEBUG, "%s", g_strToolVersion); | |
| 1002 | + bDebugOn = true; | |
| 1003 | + } | |
| 1004 | + else if (!bOn && bDebugOn) | |
| 1005 | + { | |
| 1006 | + Brom_DebugOff(); | |
| 1007 | + META_DebugOff(); | |
| 1008 | + SP_Brom_DebugOff(); | |
| 1009 | + SPMETA_DLL::SP_META_DebugOff(); | |
| 1010 | + _Xboot_DebugOff(); | |
| 1011 | + | |
| 1012 | + m_strLogDir_Sub[0] = '\0'; | |
| 1013 | + | |
| 1014 | + bDebugOn = false; | |
| 1015 | + } | |
| 1016 | +} | |
| 1017 | + | |
| 1018 | +void SNBase::LogConfig() | |
| 1019 | +{ | |
| 1020 | + char szInfo[256] = ""; | |
| 1021 | + | |
| 1022 | + // connect type | |
| 1023 | + if (g_sMetaComm.bUsbEnable) | |
| 1024 | + strcpy(szInfo, " Connect by USB"); | |
| 1025 | + else | |
| 1026 | + sprintf(szInfo, " Connect by COM%d", g_sMetaComm.iCOMPort); | |
| 1027 | + MTRACE(g_hEBOOT_DEBUG, szInfo); | |
| 1028 | + | |
| 1029 | + // Target Type | |
| 1030 | + switch(g_sMetaComm.eTargetType) | |
| 1031 | + { | |
| 1032 | + case FEATURE_PHONE: strcpy(szInfo, " Target Type: Feature Phone"); break; | |
| 1033 | + case SMART_PHONE: strcpy(szInfo, " Target Type: Samrt Phone"); break; | |
| 1034 | + case SMART_PHONE_DUALMODEM: strcpy(szInfo, " Target Type: Smart DualModem Phone"); break; | |
| 1035 | + case TABLET_WIFI_ONLY: strcpy(szInfo, " Target Type: Tablet"); break; | |
| 1036 | + case RNDIG_DONGLE: strcpy(szInfo, " Target Type: Rndig Dongle"); break; | |
| 1037 | + default: strcpy(szInfo, " Target Type: Unknown"); break; | |
| 1038 | + } | |
| 1039 | + MTRACE(g_hEBOOT_DEBUG, szInfo); | |
| 1040 | + | |
| 1041 | + // Write Option | |
| 1042 | + sprintf(szInfo, " WO>" | |
| 1043 | + " Barcode(%d)" | |
| 1044 | + " IMEI(%d,%s,%s)," | |
| 1045 | + " BT Addr(%d)," | |
| 1046 | + " WIFI Addr(%d)," | |
| 1047 | + " Eth MAC(%d)," | |
| 1048 | + " Hdcp(%d)" | |
| 1049 | + , | |
| 1050 | + g_sMetaComm.sWriteOption.bWriteBarcode?1:0, | |
| 1051 | + g_sMetaComm.sWriteOption.bWriteIMEI?g_sMetaComm.sIMEIOption.iImeiNums:0, g_sMetaComm.sIMEIOption.bCheckSum?"Check":"NoCheck", g_sMetaComm.sIMEIOption.bDualIMEISame?"Same":"Indep", | |
| 1052 | + g_sMetaComm.sWriteOption.bWriteBT?1:0, | |
| 1053 | + g_sMetaComm.sWriteOption.bWriteWifi?1:0, | |
| 1054 | + g_sMetaComm.sWriteOption.bWriteEthernetMac?1:0, | |
| 1055 | + g_sMetaComm.sWriteOption.bWriteHdcp?1:0 | |
| 1056 | + ); | |
| 1057 | + MTRACE(g_hEBOOT_DEBUG, szInfo); | |
| 1058 | + sprintf(szInfo, " " | |
| 1059 | + " HdcpData(%d)," | |
| 1060 | + " Drm(%d)," | |
| 1061 | + " MCID(%d)," | |
| 1062 | + " MEID(%d)," | |
| 1063 | + " ESN(%d)," | |
| 1064 | + " Temp(%s)," | |
| 1065 | + " Serial No(%d)" | |
| 1066 | + , | |
| 1067 | + g_sMetaComm.sWriteOption.bInstallHdcpData?1:0, | |
| 1068 | + g_sMetaComm.sWriteOption.bWriteDrm?1:0, | |
| 1069 | + g_sMetaComm.sWriteOption.bWriteDrmkeyMCID?1:0, | |
| 1070 | + g_sMetaComm.sWriteOption.bWriteMeid?1:0, | |
| 1071 | + g_sMetaComm.sWriteOption.bWriteEsn?1:0, | |
| 1072 | + g_sMetaComm.sIMEIOption.Temp_Option.bWriteTemperature?g_sMetaComm.sIMEIOption.Temp_Option.strTemperatureData:"-", | |
| 1073 | + g_sMetaComm.sWriteOption.bWriteSerialNo?1:0 | |
| 1074 | + ); | |
| 1075 | + MTRACE(g_hEBOOT_DEBUG, szInfo); | |
| 1076 | + | |
| 1077 | + // Special Option | |
| 1078 | + sprintf(szInfo, " SO>" | |
| 1079 | + "AlreadyInMeta(%d)," | |
| 1080 | + " Security(%d)," | |
| 1081 | + " Bypass proinfo(%d)," | |
| 1082 | + " Ignore DB Inconsistent(%d)," | |
| 1083 | + " Check flag K(%d) NSFT(%d)," | |
| 1084 | + " Serial No from IMEI(%d)" | |
| 1085 | + , | |
| 1086 | + g_sMetaComm.bAlreadyInMeata, | |
| 1087 | + g_sMetaComm.bSecurityUSB?1:0, | |
| 1088 | + g_sMetaComm.bSkipWriteProdInfo?1:0, | |
| 1089 | + g_sMetaComm.IgnoreDBInconsistent?1:0, | |
| 1090 | + g_sMetaComm.bCheckCalFlag?1:0, g_sMetaComm.bCheckFtFlag?1:0, | |
| 1091 | + g_sMetaComm.SerialNumFromIMEI?1:0 | |
| 1092 | + ); | |
| 1093 | + MTRACE(g_hEBOOT_DEBUG, szInfo); | |
| 1094 | + | |
| 1095 | + // DB Option | |
| 1096 | + sprintf(szInfo, " DO>" | |
| 1097 | + " APDB From DUT(%d)," | |
| 1098 | + " MDDB From DUT(%d)," | |
| 1099 | + " APDB Init(%d)," | |
| 1100 | + " MDDB1 Init(%d)," | |
| 1101 | + " MDDB2 Init(%d)" | |
| 1102 | + , | |
| 1103 | + g_sMetaComm.sDBFileOption.bAPDBFromDUT?1:0, | |
| 1104 | + g_sMetaComm.sDBFileOption.bMDDBFromDUT?1:0, | |
| 1105 | + g_sMetaComm.sDBFileOption.bDBInitAP?1:0, | |
| 1106 | + g_sMetaComm.sDBFileOption.bDBInitModem_1?1:0, | |
| 1107 | + g_sMetaComm.sDBFileOption.bDBInitModem_2?1:0 | |
| 1108 | + ); | |
| 1109 | + MTRACE(g_hEBOOT_DEBUG, szInfo); | |
| 1110 | + MTRACE(g_hEBOOT_DEBUG, " APDB: %s", g_sMetaComm.sDBFileOption.strAPDbpath); | |
| 1111 | + MTRACE(g_hEBOOT_DEBUG, " MDDB1: %s", g_sMetaComm.sDBFileOption.strMD1Dbpath); | |
| 1112 | + MTRACE(g_hEBOOT_DEBUG, " MDDB2: %s", g_sMetaComm.sDBFileOption.strMD2Dbpath); | |
| 1113 | +} | |
| 1114 | + | |
| 1115 | +void SNBase::MDLogSetParam(int mdindex) | |
| 1116 | +{ | |
| 1117 | + if (g_sMetaComm.bMDLog && m_strLogDir_Sub[0] != '\0') | |
| 1118 | + { | |
| 1119 | + m_tMetaReq_Ex.trace_para.mode = FILE_DUMP_MODE; | |
| 1120 | + m_tMetaReq_Ex.trace_para.modem_index = mdindex; | |
| 1121 | + m_tMetaReq_Ex.trace_para.dump_file_path = m_strLogDir_Sub; | |
| 1122 | + m_tMetaReq_Ex.trace_para.commTrace.enable = false; | |
| 1123 | + m_tMetaReq_Ex.trace_para.commTrace.dump_file_path = NULL; | |
| 1124 | + MTRACE(g_hEBOOT_DEBUG, "SNBase::MDLogSetParam(): set modem%d log path \"%s\".", mdindex, m_strLogDir_Sub); | |
| 1125 | + } | |
| 1126 | +} | |
| 1127 | + | |
| 1128 | +void SNBase::MDLogOn() | |
| 1129 | +{ | |
| 1130 | + DWORD dwErr = 0u; | |
| 1131 | + META_RESULT mrRet; | |
| 1132 | + HANDLE hFind = NULL; | |
| 1133 | + WIN32_FIND_DATA stFindData = {0}; | |
| 1134 | + char szPath[MAX_PATH] = {0}; | |
| 1135 | + | |
| 1136 | + if (!g_sMetaComm.bMDLog || m_strLogDir_Sub[0] == '\0') | |
| 1137 | + { | |
| 1138 | + // ensure modem log be off | |
| 1139 | + MDLogOff(); | |
| 1140 | + return; | |
| 1141 | + } | |
| 1142 | + | |
| 1143 | + MTRACE(g_hEBOOT_DEBUG, "SNBase::MDLogOn(): find filter file (*.bin) in exe path..."); | |
| 1144 | + if(::GetModuleFileName(NULL, szPath, MAX_PATH) > 0) | |
| 1145 | + { | |
| 1146 | + ::PathRemoveFileSpec(szPath); | |
| 1147 | + strcat(szPath, "\\*.bin"); | |
| 1148 | + } | |
| 1149 | + else | |
| 1150 | + { | |
| 1151 | + dwErr = ::GetLastError(); | |
| 1152 | + ResultToString_Win(dwErr, szPath, MAX_PATH); | |
| 1153 | + MTRACE_WARN(g_hEBOOT_DEBUG, "SNBase::MDLogOn(): get exe file path fail(%u, %s), set to \"C:\\\".", dwErr, szPath); | |
| 1154 | + strcpy(szPath, "C:\\*.bin"); | |
| 1155 | + } | |
| 1156 | + | |
| 1157 | + hFind = ::FindFirstFile(szPath, &stFindData); | |
| 1158 | + if (hFind == INVALID_HANDLE_VALUE) | |
| 1159 | + MTRACE_WARN(g_hEBOOT_DEBUG, "SNBase::MDLogOn(): find filter file fail."); | |
| 1160 | + else | |
| 1161 | + { | |
| 1162 | + char * pTmp = NULL; | |
| 1163 | + | |
| 1164 | + pTmp = strrchr(szPath, '*'); | |
| 1165 | + if (pTmp != NULL) | |
| 1166 | + *pTmp = '\0'; | |
| 1167 | + strcat(szPath, stFindData.cFileName); | |
| 1168 | + MTRACE(g_hEBOOT_DEBUG, "SNBase::MDLogOn(): find filter file \"%s\".", szPath); | |
| 1169 | + mrRet = META_MDLogging_SetFilterToTarget_r(m_hMauiMetaHandle, szPath); | |
| 1170 | + if (mrRet != META_SUCCESS) | |
| 1171 | + MTRACE_WARN(g_hEBOOT_DEBUG, "SNBase::MDLogOn(): set filter fail, %s.", ResultToString(mrRet)); | |
| 1172 | + ::FindClose(hFind); | |
| 1173 | + } | |
| 1174 | + | |
| 1175 | + mrRet = META_Util_EnableTstMetaTraceMode_r(m_hMauiMetaHandle, 10 * 1000, (const unsigned char)FILE_DUMP_MODE); | |
| 1176 | + if (mrRet != META_SUCCESS) | |
| 1177 | + MTRACE_WARN(g_hEBOOT_DEBUG, "SNBase::MDLogOn(): open modem log fail, %s.", ResultToString(mrRet)); | |
| 1178 | +} | |
| 1179 | + | |
| 1180 | +void SNBase::MDLogOff() | |
| 1181 | +{ | |
| 1182 | + META_RESULT mrRet; | |
| 1183 | + unsigned char mode = (const unsigned char)FILE_DUMP_MODE; | |
| 1184 | + | |
| 1185 | + mrRet = META_QueryIfFunctionSupportedByTarget_r(m_hMauiMetaHandle, 10 *1000, "META_Util_QueryTstMetaTraceMode_r"); | |
| 1186 | + if (mrRet != META_SUCCESS) | |
| 1187 | + MTRACE_WARN(g_hEBOOT_DEBUG, "SNBase::MDLogOff(): query function META_Util_QueryTstMetaTraceMode_r fail, %s.", ResultToString(mrRet)); | |
| 1188 | + else | |
| 1189 | + { | |
| 1190 | + mrRet = META_Util_QueryTstMetaTraceMode_r(m_hMauiMetaHandle, 10 * 1000, &mode); | |
| 1191 | + if (mrRet != META_SUCCESS) | |
| 1192 | + MTRACE_WARN(g_hEBOOT_DEBUG, "SNBase::MDLogOff(): META_Util_QueryTstMetaTraceMode_r fail, %s.", ResultToString(mrRet)); | |
| 1193 | + } | |
| 1194 | + | |
| 1195 | + if (mode == (const unsigned char)FILE_DUMP_MODE) | |
| 1196 | + { | |
| 1197 | + for (int i = 0; i < 3; i++) | |
| 1198 | + { | |
| 1199 | + mrRet = META_Util_EnableTstMetaTraceMode_r(m_hMauiMetaHandle, 10 * 1000, (const unsigned char)GENERAL_MODE); | |
| 1200 | + if (mrRet == META_SUCCESS) | |
| 1201 | + break; | |
| 1202 | + MTRACE_WARN(g_hEBOOT_DEBUG, "SNBase::MDLogOff(): META_Util_EnableTstMetaTraceMode_r fail, %s.", ResultToString(mrRet)); | |
| 1203 | + } | |
| 1204 | + } | |
| 1205 | +} | |
| 1206 | + | |
| 1207 | +void SNBase::SNThread_Init() | |
| 1208 | +{ | |
| 1209 | + //Get main dialog handle | |
| 1210 | + //g_pMainDlg = (CSNWriterDlg*)g_MainDlgHandle; | |
| 1211 | + | |
| 1212 | + m_Process = &(g_pMainDlg->m_ProgressSN); | |
| 1213 | + SetProgress(); | |
| 1214 | + | |
| 1215 | + m_bNeedBackupIMEI = false; | |
| 1216 | + memset(m_strBackupIMEI, 0, IMEI_ARRAY_LEN); | |
| 1217 | + memset(m_sIMEISV, 0, sizeof(IMEISV_struct_T)*MAX_IMEI_NUMS); | |
| 1218 | + memset(&m_sScanData, 0, sizeof(ScanData_struct)); | |
| 1219 | + GetScanData(g_sMetaComm.sScanData); | |
| 1220 | + | |
| 1221 | + g_iMetaStopFlag = 0; | |
| 1222 | + m_hThread = NULL; | |
| 1223 | + m_iThreadID = 0; | |
| 1224 | + m_sNVRAM_OPID = 0; | |
| 1225 | + m_pMetaStopFlag = &g_iMetaStopFlag; | |
| 1226 | + m_bWriteNvram = false; | |
| 1227 | + m_bTargetInMetaMode = false; | |
| 1228 | + m_bStopBeforeUSBInsert = true; | |
| 1229 | + m_hReadFromNVRAMEvent = NULL; | |
| 1230 | + m_hWriteToNVRAMEvent = NULL; | |
| 1231 | + m_bBackupNvramSuccess = false; | |
| 1232 | + | |
| 1233 | + m_bWriteModemNvram = g_sMetaComm.sWriteOption.bWriteMeid || g_sMetaComm.sWriteOption.bWriteEsn || | |
| 1234 | + ((g_sMetaComm.sWriteOption.bWriteIMEI || g_sMetaComm.sWriteOption.bWriteBarcode) && g_sMetaComm.eTargetType != TABLET_WIFI_ONLY); | |
| 1235 | + | |
| 1236 | + UpdateUIMsg(""); | |
| 1237 | +} | |
| 1238 | + | |
| 1239 | +void SNBase::SNThread_Start() | |
| 1240 | +{ | |
| 1241 | + g_iMetaStopFlag = 0; | |
| 1242 | + m_hThread = AfxBeginThread(SNBase::ThreadStaticEntryPoint, | |
| 1243 | + (LPVOID)this, | |
| 1244 | + THREAD_PRIORITY_NORMAL, | |
| 1245 | + 0, | |
| 1246 | + 0, | |
| 1247 | + NULL); | |
| 1248 | +} | |
| 1249 | + | |
| 1250 | +void SNBase::SNThread_Stop() | |
| 1251 | +{ | |
| 1252 | + g_iMetaStopFlag = BOOT_STOP; | |
| 1253 | +} | ... | ... |
Execute/SNbase.h
0 → 100644
| 1 | +#ifndef _SN_BASE_H_ | |
| 2 | +#define _SN_BASE_H_ | |
| 3 | + | |
| 4 | +#include "Common.h" | |
| 5 | +#include "Mdebug.h" | |
| 6 | +#include "xboot_debug.h" | |
| 7 | +#include "SLA.h" | |
| 8 | + | |
| 9 | +#include "Meta.h" | |
| 10 | +#include "Brom.h" | |
| 11 | + | |
| 12 | +#include "Sp_Brom.h" | |
| 13 | +namespace SPMETA_DLL | |
| 14 | +{ | |
| 15 | + #include "spmeta.h" | |
| 16 | +}; | |
| 17 | + | |
| 18 | + | |
| 19 | +//write temperature to nvram | |
| 20 | +typedef struct | |
| 21 | +{ | |
| 22 | + float resistor[512]; | |
| 23 | + float temp_initial; | |
| 24 | + float current_sensing_resistor; | |
| 25 | + unsigned short reso_freq_center; | |
| 26 | + unsigned short reso_freq_bw; | |
| 27 | + unsigned short reso_freq_gain; | |
| 28 | + unsigned short prefer_band_upper; | |
| 29 | + unsigned short prefer_band_lower; | |
| 30 | + unsigned short temp_limit_low; | |
| 31 | + unsigned short temp_limit_high; | |
| 32 | + unsigned short temp_control_time_slots; | |
| 33 | + unsigned short monitor_timer; | |
| 34 | +}AUDIO_SPREAKER_MONITOR_PARAM_STRUCT; | |
| 35 | + | |
| 36 | +class PortEnumHelper | |
| 37 | +{ | |
| 38 | + static const int ms_iFilterLen; | |
| 39 | + static const int ms_iFilterNum; | |
| 40 | + static const int ms_iPortNum; | |
| 41 | + | |
| 42 | + char * m_szFilter; | |
| 43 | + | |
| 44 | + int * m_aiFlag; | |
| 45 | + SP_COM_FILTER_LIST_S m_stFiler; | |
| 46 | + | |
| 47 | + SP_COM_PROPERTY_S * m_astPort; | |
| 48 | + | |
| 49 | +public: | |
| 50 | + PortEnumHelper::PortEnumHelper(); | |
| 51 | + PortEnumHelper::~PortEnumHelper(); | |
| 52 | + | |
| 53 | + // suport multiport, delim by space/tab/comma | |
| 54 | + void SetFilter(SP_FILTER_TYPE_E type, const char * filter, int flag = 0, bool bAppend = false); | |
| 55 | + SP_COM_FILTER_LIST_S * GetFilter(); | |
| 56 | + int GetFlag(int index); | |
| 57 | + SP_COM_PROPERTY_S * GetPorts(bool bClear = false); | |
| 58 | +}; | |
| 59 | + | |
| 60 | +class SNBase | |
| 61 | +{ | |
| 62 | +public: | |
| 63 | + SNBase(); | |
| 64 | + virtual ~SNBase(); | |
| 65 | + | |
| 66 | +protected: | |
| 67 | + META_Connect_Ex_Req m_tMetaReq_Ex; | |
| 68 | + META_Connect_Report m_tMetaConnReport_Ex; | |
| 69 | + | |
| 70 | + HANDLE m_hThread; | |
| 71 | + unsigned int m_iThreadID; | |
| 72 | + int *m_pMetaStopFlag; | |
| 73 | + int m_hMauiMetaHandle; | |
| 74 | + int m_hSPMetaHandle; | |
| 75 | + short m_sNVRAM_OPID; | |
| 76 | + | |
| 77 | + bool m_bWriteNvram; | |
| 78 | + bool m_bWriteModemNvram; | |
| 79 | + bool m_bTargetInMetaMode; | |
| 80 | + bool m_bStopBeforeUSBInsert; | |
| 81 | + | |
| 82 | + HANDLE m_hReadFromNVRAMEvent; | |
| 83 | + HANDLE m_hWriteToNVRAMEvent; | |
| 84 | + | |
| 85 | + IMEISV_struct_T m_sIMEISV[MAX_IMEI_NUMS]; | |
| 86 | + char m_strBackupIMEI[IMEI_ARRAY_LEN]; | |
| 87 | + bool m_bNeedBackupIMEI; | |
| 88 | + ScanData_struct m_sScanData; | |
| 89 | + | |
| 90 | + char m_strLogDir_Sub[MAX_PATH]; | |
| 91 | + | |
| 92 | +protected: | |
| 93 | + static UINT ThreadStaticEntryPoint(LPVOID pThis); | |
| 94 | + virtual void SetupMetaModeParameters() = 0; | |
| 95 | + virtual void ThreadMainEntryPoint() = 0; | |
| 96 | + virtual META_RESULT MetaHandle_Init() = 0; | |
| 97 | + virtual void MetaHandle_DeInit() = 0; | |
| 98 | + virtual META_RESULT WriteNvramLoop() = 0; | |
| 99 | + | |
| 100 | + virtual META_RESULT LoadModemDatabase(int MDindex) = 0; | |
| 101 | + virtual void UpdateProgress(double dPercent); | |
| 102 | + virtual void SetProgress(); | |
| 103 | + | |
| 104 | + virtual META_RESULT ConductBarcodeData(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize); | |
| 105 | + virtual META_RESULT ConductIMEIData(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize); | |
| 106 | + virtual META_RESULT ConductBTAddrData(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize); | |
| 107 | + virtual META_RESULT ConductWifiAddrData(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize); | |
| 108 | + virtual META_RESULT ConductEthernetMacAddrData(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize); | |
| 109 | + virtual META_RESULT ConductAudioTemperatureData(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize); | |
| 110 | + | |
| 111 | + virtual META_RESULT Decompose_IMEI(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize); | |
| 112 | + virtual META_RESULT Compose_IMEI(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize, bool bChecksum); | |
| 113 | + | |
| 114 | + virtual META_RESULT REQ_ReadFromModemNVRAM(FT_NVRAM_READ_REQ *psNVRAM_ReadReq, FT_NVRAM_READ_CNF *psNVRAM_ReadCnf); | |
| 115 | + virtual META_RESULT REQ_WriteToModemNVRAM(FT_NVRAM_WRITE_REQ *psNVRAM_WriteReq, FT_NVRAM_WRITE_CNF *psNVRAM_WriteCnf); | |
| 116 | + virtual void UpdateUICountResult(WriteNvram_Status_e eWriteStatus); | |
| 117 | + virtual int UpdateUIMsg(const char * strMsg, ...); | |
| 118 | + virtual CheckCalFlag_Status_e CheckCalibrationStatus(const char* strBarcode); | |
| 119 | + virtual CheckFinalTestFlag_Status_e CheckFinalTestStatus(const char* strBarcode); | |
| 120 | + virtual bool CheckCalFinalTestStatus(const char* strBarcode); | |
| 121 | + virtual void PopupMsgBox(const char* strTilte, UINT uType, const char* strMsg, ...); | |
| 122 | + virtual bool NeedScanData(); | |
| 123 | + | |
| 124 | + void DebugOnOff(bool bOn); | |
| 125 | + // mdindex base 0 | |
| 126 | + void LogConfig(); | |
| 127 | + void MDLogSetParam(int mdindex); | |
| 128 | + void MDLogOn(); | |
| 129 | + void MDLogOff(); | |
| 130 | + | |
| 131 | +public: | |
| 132 | + void SNThread_Init(); | |
| 133 | + void SNThread_Start(); | |
| 134 | + void SNThread_Stop(); | |
| 135 | + void GetScanData(ScanData_struct &pScanData); | |
| 136 | + void UpdateMainDlgUI(bool bEnable, WriteNvram_Status_e eWriteStatus); | |
| 137 | + void EnableStartBTN(bool bEnable = true); | |
| 138 | + | |
| 139 | +protected: | |
| 140 | + CProgressCtrl *m_Process; | |
| 141 | + UINT m_iProcessRange; | |
| 142 | + bool m_bBackupNvramSuccess; | |
| 143 | +}; | |
| 144 | + | |
| 145 | +typedef META_RESULT (SNBase::*pConductDataFunc)(char *pOutData, unsigned short RID_para, char *pInDatabuf, int bufSize); | |
| 146 | + | |
| 147 | +#endif | |
| \ No newline at end of file | ... | ... |
Please
register
or
login
to post a comment