int FtpsendAlarm( char* capfilename, char* filename ) { int iRet = 0; char param[4]; //ftplock(); Textout("7"); ftp_dbg( "alarm upload40\n", 0 ); iRet = FtpConfigAlarm( 0x00, capfilename, filename ); if ( -1 == iRet ) { Textout("FtpConfigAlarm failed"); return iRet; } // (iRet == 0){ ftp_dbg( "alarm upload41\n", 0 ); //gnal(SIGCHLD,SIG_IGN); //gnal(SIGCHLD,SIG_DFL); //FtpWrite(param,4); Textout("8"); iRet = DoSystem( "/tmp/ftpupdate.sh &" ); ftp_dbg( "alarm upload42\n", 0 ); //} //ftpunlock(); Textout("9 - FTP Over"); return iRet; }
void InsmodUvcDriver() { Textout("=================Insmod uvc driver=================="); DoSystem("insmod /lib/modules/2.6.21/kernel/drivers/media/video/v4l2-common.ko"); DoSystem("insmod /lib/modules/2.6.21/kernel/drivers/media/video/compat_ioctl32.ko"); DoSystem("insmod /lib/modules/2.6.21/kernel/drivers/media/video/v4l1-compat.ko"); DoSystem("insmod /lib/modules/2.6.21/kernel/drivers/media/video/videodev.ko"); #ifdef SENSOR_3861 DoSystem("insmod /lib/modules/2.6.21/kernel/drivers/media/video/uvc/uvcvideo.ko"); Textout("=================Insmod uvc driver SENSOR_3861 end=================="); #else DoSystem("insmod /system/system/lib/uvcvideo.ko"); Textout("=================Insmod uvc driver 8433 end=================="); #endif }
void jPushTest(int singno) { static int testNo = 0; testNo++; Textout("Start the No:%d test",testNo); jPush("jPush test"); }
void RmmodUvcDriver() { Textout("=================Rmmod uvc driver=================="); DoSystem("rmmod uvcvideo"); DoSystem("rmmod videodev"); DoSystem("rmmod v4l1-compat"); DoSystem("rmmod compat_ioctl32"); DoSystem("rmmod v4l2-common"); }
int GetFtpTestResult() { int iRet = 0; int nIntervalTime=0; while(nIntervalTime < 5) { iRet = access( FILE_FTP_TEST_RESULT, F_OK ); if ( iRet == 0 ) { Textout("Get the result file of FTP test"); break; } else { nIntervalTime++; sleep(1); Textout("nIntervalTime = %d", nIntervalTime); } } iRet = GetFtpResult(); Textout( "Ftp result=%d", iRet ); /* BEGIN: Added by Baggio.wu, 2013/10/25 */ //DoSystem( "rm /tmp/ftpret.txt" ); //rm result file if(1) { char cmd[32]; memset(cmd, 0, 32); sprintf(cmd, "rm %s", FILE_FTP_TEST_RESULT); DoSystem(cmd); } return iRet; }
void SysParamInit( void ) //system param init { char* pdst = NULL; int iRet; /* BEGIN: Added by wupm, 2013/3/12 */ #ifdef HONESTECH ReadHTClassParams(); #endif InitSystemParam(); Textout("Read Config File , UUID = [%s], MAC = [%s]", bparam.stIEBaseParam.dwDeviceID, bparam.stIEBaseParam.szMac ); Textout("ApiLisense = [%s]",bparam.stIEBaseParam.dwApiLisense); nvram_init( RT2860_NVRAM ); IPCStart(); //ipc init #ifndef NOT_READ_MAC ReadFactoryMac(); //read mac Textout("ReadFactoryMac, UUID = [%s], MAC = [%s]", bparam.stIEBaseParam.dwDeviceID, bparam.stIEBaseParam.szMac ); Textout("ApiLisense = [%s]",bparam.stIEBaseParam.dwApiLisense); #endif ReadRactoryID(); //read deviceid Textout("ReadRactoryID, UUID = [%s], MAC = [%s]", bparam.stIEBaseParam.dwDeviceID, bparam.stIEBaseParam.szMac ); Textout("ApiLisense = [%s]",bparam.stIEBaseParam.dwApiLisense); //ReadDnsFactory(); //read dns factory ConfigVersion(); //config system version DateInit(); FactoryUpdateInit(); }
void SetKeyState(int keyState) { static pthread_t threadKeyPress = 0; if ( nKeyState == 1 ) { if ( threadKeyPress == 0 ) { // if ( 1 ) if ( pthread_create( &threadKeyPress, NULL, &ThreadKeyPressProc, NULL ) ) { Textout("[Thread ThreadKeyPressProc Proc] Create Fail..."); } else { Textout("[Thread ThreadKeyPressProc Proc] Create Succ"); pthread_detach(threadKeyPress); } } } nKeyTime = 0; nKeyState = keyState; }
void FactoryResultParase( char* pbuffer ) { char* pdst = NULL; char* pdst1 = NULL; int iRet = 0; switch ( bparam.stDdnsParam.factoryversion ) { case 10: //vstarcam pdst = strstr( pbuffer + 32, "Update-OK" ); if ( pdst != NULL ) { factorystatus = 22; factorytimes = 0; } pdst = strstr( pbuffer + 32, "ERRIDS_SERVER_NOAUTH" ); if ( pdst != NULL ) { factorystatus = 23; } pdst = strstr( pbuffer + 32, "ERRIDS_SERVER_NOID" ); if ( pdst != NULL ) { factorystatus = 24; } pdst = strstr( pbuffer + 32, "ERRIDS_SERVER_OVER" ); if ( pdst != NULL ) { factorystatus = 25; } pdst = strstr( pbuffer + 32, "ERRIDS_SERVER_ERR_IDDISABLE" ); if ( pdst != NULL ) { factorystatus = 26; } pdst = strstr( pbuffer + 32, "ERRIDS_SERVER_ERR_PARAM" ); if ( pdst != NULL ) { factorystatus = 27; } break; case 11: //xinhuaan viporg pdst1 = strstr( pbuffer, "UP" ); pdst = strstr( pbuffer, "OK" ); if ( ( pdst == NULL ) && ( pdst1 == NULL ) ) { factorystatus = 19; //ok factorytimes = 0; } else { factorystatus = 18; //failed } break; case 13: //smarteye ddns factorystatus = 18; pdst = strstr( pbuffer + 32, "Update-OK" ); if ( pdst != NULL ) { factorystatus = 19; factorytimes = 0; } break; /* BEGIN: Added by wupm, 2013/3/23 */ case 21: //PSD Textout1( "PSD Response = [%s]", pbuffer ); pdst = strstr( pbuffer, "Update-OK" ); if ( pdst != NULL ) { factorystatus = 22; factorytimes = 0; } pdst = strstr( pbuffer, "ERRIDS_SERVER_NOAUTH" ); if ( pdst != NULL ) { factorystatus = 23; } pdst = strstr( pbuffer, "ERRIDS_SERVER_NOID" ); if ( pdst != NULL ) { factorystatus = 24; } pdst = strstr( pbuffer, "ERRIDS_SERVER_OVER" ); if ( pdst != NULL ) { factorystatus = 25; } pdst = strstr( pbuffer, "ERRIDS_SERVER_ERR_IDDISABLE" ); if ( pdst != NULL ) { factorystatus = 26; } pdst = strstr( pbuffer, "ERRIDS_SERVER_ERR_PARAM" ); if ( pdst != NULL ) { factorystatus = 27; } Textout1( "factorystatus = %d", factorystatus ); break; /* BEGIN: Added by wupm, 2013/4/19 */ //NEO case 22: /* BEGIN: Added by wupm, 2013/4/25 */ //EYESIGHT case 23: if ( 1 ) { char* pdst = NULL; char* psrc = NULL; Textout( "DDNS Server Response = [%s]", pbuffer ); factorystatus = 45; psrc = strstr( pbuffer, "Cache-control:" ); if ( psrc != NULL ) { pdst = strstr( psrc + 22, "OK" ); if ( pdst != NULL ) { factorystatus = 40; factorytimes = 0; } pdst = strstr( psrc + 22, "UP" ); if ( pdst != NULL ) { factorystatus = 40; factorytimes = 0; } pdst = strstr( psrc + 22, "ER" ); if ( pdst != NULL ) { factorystatus = 41; } pdst = strstr( psrc + 22, "DA" ); if ( pdst != NULL ) { factorystatus = 42; } pdst = strstr( psrc + 22, "SNE" ); if ( pdst != NULL ) { factorystatus = 43; } pdst = strstr( psrc + 22, "NE" ); if ( pdst != NULL ) { factorystatus = 44; } } Textout( "factorystatus = %d", factorystatus ); //bparam.stDdnsParam.dnsstatus = third_status; } break; case 24: if(1) { char* pdst = NULL; char* psrc = NULL; Textout( "DDNS Server Response = [%s]", pbuffer); factorystatus = 45; psrc = strstr( pbuffer, "Cache-control:" ); if ( psrc != NULL ) { pdst = strstr( psrc + 22, "OK" ); if ( pdst != NULL ) { factorystatus = 40; factorytimes = 0; } pdst = strstr( psrc + 22, "UP" ); if ( pdst != NULL ) { factorystatus = 40; factorytimes = 0; } pdst = strstr( psrc + 22, "ER" ); if ( pdst != NULL ) { factorystatus = 41; } pdst = strstr( psrc + 22, "DA" ); if ( pdst != NULL ) { factorystatus = 42; } pdst = strstr( psrc + 22, "SNE" ); if ( pdst != NULL ) { factorystatus = 43; } pdst = strstr( psrc + 22, "NE" ); if ( pdst != NULL ) { factorystatus = 44; } } } break; case 25: if(1) { char* pdst = NULL; char* psrc = NULL; Textout( "DDNS Server Response = [%s]", pbuffer); factorystatus = 45; psrc = strstr( pbuffer, "Cache-control:" ); if ( psrc != NULL ) { pdst = strstr( psrc + 22, "OK" ); if ( pdst != NULL ) { factorystatus = 40; factorytimes = 0; } pdst = strstr( psrc + 22, "UP" ); if ( pdst != NULL ) { factorystatus = 40; factorytimes = 0; } pdst = strstr( psrc + 22, "ER" ); if ( pdst != NULL ) { factorystatus = 41; } pdst = strstr( psrc + 22, "DA" ); if ( pdst != NULL ) { factorystatus = 42; } pdst = strstr( psrc + 22, "SNE" ); if ( pdst != NULL ) { factorystatus = 43; } pdst = strstr( psrc + 22, "NE" ); if ( pdst != NULL ) { factorystatus = 44; } } } break; case 26: //xinhuaan viporg //pdst1 = strstr( pbuffer, "UP" ); Textout("%s", pbuffer); pdst = strstr( pbuffer, "900" ); if ( ( pdst == NULL ) /*&& ( pdst1 == NULL ) */) { factorystatus = 19; //ok Textout("DDNS FAILD!!!!!!"); } else { factorystatus = 18; //failed factorytimes = 0; Textout("DDNS OK!!!!!!"); } break; default: iRet = -1; break; } /* BEGIN: Modified by wupm, 2013/7/1 */ //return iRet; }
void customFtpSend(char AlarmType, char* filename1, char* filename2, char* filename3) { int iRet = 0; char param[4]; char target_filename1[256]; char target_filename2[256]; char target_filename3[256]; int nFileNameLen = 0; char cmd[128]; FILE* fp = NULL; struct stat stStat; if ( bparam.stFtpParam.szFtpSvr[0] == 0x00 ) { return -1; } if ( bparam.stFtpParam.szFtpUser[0] == 0x00 ) { return -1; } if ( bparam.stFtpParam.szFtpPwd[0] == 0x00 ) { return -1; } iRet = access( "/tmp/ftpupdate3.sh", X_OK ); if ( iRet ) { Textout("file exist, rm -f /tmp/ftpupdate3.sh"); DoSystem( "rm -f /tmp/ftpupdate3.sh" ); } fp = fopen( "/tmp/ftpupdate3.sh", "wb" ); if ( fp == NULL ) { printf( "ftp config failed\n" ); return -1; } memset( cmd, 0x00, 128 ); sprintf( cmd, "/system/system/bin/ftp -n<<!\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "open %s %d\n", bparam.stFtpParam.szFtpSvr, bparam.stFtpParam.nFtpPort ); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "user %s %s\n", bparam.stFtpParam.szFtpUser, bparam.stFtpParam.szFtpPwd ); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "binary\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); if ( bparam.stFtpParam.byMode == 1 ) //passive { memset( cmd, 0x00, 128 ); sprintf( cmd, "pass\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); } #if 1//def CREATE_FTP_SUBDIRECTORY //filename1=[/tmp/20130131110813_4.jpg] if ( 1 ) { char filename[256]; char szTemp[128]; nFileNameLen=strlen(filename1); if ( nFileNameLen == 0 ) { Textout("No File, return"); return 1; } memset(filename, 0, 256); strcpy(filename, filename1); memset( szTemp, 0, 128 ); memcpy( szTemp, filename + 5, 8 ); Textout("FileName = {%s}", filename); Textout( "FTP Sub Directory = [%s]", szTemp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "mkdir %s\n", szTemp ); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "cd %s\n", szTemp ); fwrite( cmd, 1, strlen( cmd ), fp ); /////// memset( szTemp, 0, 128 ); sprintf(szTemp, "%s", bparam.stIEBaseParam.dwDeviceID); Textout( "FTP Sub Directory = [%s]", szTemp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "mkdir %s\n", szTemp ); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "cd %s\n", szTemp ); fwrite( cmd, 1, strlen( cmd ), fp ); } memset(target_filename1, 0, 256); memset(target_filename2, 0, 256); memset(target_filename3, 0, 256); if ( filename1[0] != 0 ) { sprintf(target_filename1, "%c" "%c%c%c%c%c%c" "%c%c%c%c%c%c" "%c" "%c.jpg", ( AlarmType == GPIO_ALARM || AlarmType == MOTION_ALARM ) ? 'A' : 'P', filename1[7], filename1[8], filename1[9], filename1[10], filename1[11], filename1[12], filename1[13], filename1[14], filename1[15], filename1[16], filename1[17], filename1[18], '1', //0:SD,1:FTP,2:EMAIL filename1[nFileNameLen - 5]); Textout("target_filename 1 = [%s]", target_filename1); //Textout("filename1 = [%s]", filename1); //Textout("", ); } if ( filename2[0] != 0 ) { sprintf(target_filename2, "%c" "%c%c%c%c%c%c" "%c%c%c%c%c%c" "%c" "%c.jpg", ( AlarmType == GPIO_ALARM || AlarmType == MOTION_ALARM ) ? 'A' : 'P', filename2[7], filename2[8], filename2[9], filename2[10], filename2[11], filename2[12], filename2[13], filename2[14], filename2[15], filename2[16], filename2[17], filename2[18], '1', //0:SD,1:FTP,2:EMAIL filename2[nFileNameLen - 5]); Textout("target_filename 2 = [%s]", target_filename2); } if ( filename3[0] != 0 ) { sprintf(target_filename3, "%c" "%c%c%c%c%c%c" "%c%c%c%c%c%c" "%c" "%c.jpg", ( AlarmType == GPIO_ALARM || AlarmType == MOTION_ALARM ) ? 'A' : 'P', filename3[7], filename3[8], filename3[9], filename3[10], filename3[11], filename3[12], filename3[13], filename3[14], filename3[15], filename3[16], filename3[17], filename3[18], '1', //0:SD,1:FTP,2:EMAIL filename3[nFileNameLen - 5]); Textout("target_filename 3 = [%s]", target_filename3); } #endif /* END: Added by wupm, 2013/2/1 */ memset( cmd, 0x00, 128 ); sprintf( cmd, "lcd /tmp\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); /* if ( test == 0x01 ) { FtpFileTest(); memset( cmd, 0x00, 128 ); sprintf( cmd, "put ftptest.txt\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); } else*/ { char localfile[128]; //char filename2[128]; if ( filename1[0] != 0 ) { memset( localfile, 0x00, 128 ); memcpy( localfile, filename1 + 5, strlen( filename1 ) - 5 ); //memset( filename2, 0x00, 128 ); //memcpy( filename2, capfilename + 5, strlen( capfilename ) - 5 ); memset( cmd, 0x00, 128 ); sprintf( cmd, "put %s %s\n", localfile, target_filename1); Textout("COMMAND = [%s]", cmd); fwrite( cmd, 1, strlen( cmd ), fp ); } if ( filename2[0] != 0 ) { memset( localfile, 0x00, 128 ); memcpy( localfile, filename2 + 5, strlen( filename2 ) - 5 ); //memset( filename2, 0x00, 128 ); //memcpy( filename2, capfilename + 5, strlen( capfilename ) - 5 ); memset( cmd, 0x00, 128 ); sprintf( cmd, "put %s %s\n", localfile, target_filename2); Textout("COMMAND = [%s]", cmd); fwrite( cmd, 1, strlen( cmd ), fp ); } if ( filename3[0] != 0 ) { memset( localfile, 0x00, 128 ); memcpy( localfile, filename3 + 5, strlen( filename3 ) - 5 ); //memset( filename2, 0x00, 128 ); //memcpy( filename2, capfilename + 5, strlen( capfilename ) - 5 ); memset( cmd, 0x00, 128 ); sprintf( cmd, "put %s %s\n", localfile, target_filename3); Textout("COMMAND = [%s]", cmd); fwrite( cmd, 1, strlen( cmd ), fp ); } } memset( cmd, 0x00, 128 ); sprintf( cmd, "close\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "bye\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "!\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); /* BEGIN: Added by wupm, 2013/4/25 */ memset( cmd, 0x00, 128 ); //sprintf(cmd, "rm -f %s", capfilename); sprintf(cmd, "rm -f %s", filename1); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); //sprintf(cmd, "rm -f %s", capfilename); sprintf(cmd, "rm -f %s", filename2); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); //sprintf(cmd, "rm -f %s", capfilename); sprintf(cmd, "rm -f %s", filename3); fwrite( cmd, 1, strlen( cmd ), fp ); fclose( fp ); iRet = access( "/tmp/ftpupdate3.sh", X_OK ); if ( iRet ) { DoSystem( "chmod a+x /tmp/ftpupdate3.sh" ); } /*return 0; if ( -1 == iRet ) { return iRet; }*/ // (iRet == 0){ ftp_dbg( "alarm upload41\n", 0 ); //gnal(SIGCHLD,SIG_IGN); //gnal(SIGCHLD,SIG_DFL); //FtpWrite(param,4); iRet = DoSystem( "/tmp/ftpupdate3.sh" ); ftp_dbg( "alarm upload42\n", 0 ); //} //ftpunlock(); return iRet; }
int FtpConfigAlarm( char test, char* capfilename, char* filename ) { char cmd[128]; FILE* fp = NULL; struct stat stStat; int iRet; int flag = 0; if ( bparam.stFtpParam.szFtpSvr[0] == 0x00 ) { return -1; } if ( bparam.stFtpParam.szFtpUser[0] == 0x00 ) { return -1; } if ( bparam.stFtpParam.szFtpPwd[0] == 0x00 ) { return -1; } fp = fopen( "/tmp/ftpupdate.sh", "wb" ); if ( fp == NULL ) { printf( "ftp config failed\n" ); return -1; } memset( cmd, 0x00, 128 ); sprintf( cmd, "/system/system/bin/ftp -n<<!\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "open %s %d\n", bparam.stFtpParam.szFtpSvr, bparam.stFtpParam.nFtpPort ); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "user %s %s\n", bparam.stFtpParam.szFtpUser, bparam.stFtpParam.szFtpPwd ); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "binary\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); if ( bparam.stFtpParam.byMode == 1 ) //passive { memset( cmd, 0x00, 128 ); sprintf( cmd, "pass\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); } #ifdef CUSTOM_DIR char sub_temp[ 128 ]; memset(sub_temp, 0, 128); sprintf(sub_temp, "%s/%s", bparam.stFtpParam.szFtpDir,bparam.stIEBaseParam.dwDeviceID); //strcpy(sub_temp, bparam.stFtpParam.szFtpDir); flag = sub_dir(fp,sub_temp); if(flag){ memset( cmd, 0x00, 128 ); sprintf( cmd, "cd %s\n", bparam.stFtpParam.szFtpDir ); fwrite( cmd, 1, strlen( cmd ), fp ); } #else memset( cmd, 0x00, 128 ); sprintf( cmd, "cd %s\n", bparam.stFtpParam.szFtpDir ); fwrite( cmd, 1, strlen( cmd ), fp ); #endif #ifdef CREATE_FTP_SUBDIRECTORY /* BEGIN: Added by wupm, 2013/2/1 Version:6 */ //filename=[/tmp/00_3a_58_19_3E_00__1_20130131110813_4.jpg] //[ /tmp/00_02_2A_F3_08_DC_JWEV-007533-LVFBH_0_20130425053328_8.jpg if ( 1 ) { int nFileNameLen = 0; char szTemp[128]; memset( szTemp, 0, 128 ); /* BEGIN: Added by wupm, 2013/6/14 */ #ifdef FTP_SUBDIRECTORY_UID_OR_MAC if ( bparam.stIEBaseParam.dwDeviceID[0] == 0 ) { memcpy(szTemp, bparam.stIEBaseParam.szMac, 17); szTemp[2] = '-'; szTemp[5] = '-'; szTemp[8] = '-'; szTemp[11] = '-'; szTemp[14] = '-'; } else { /* BEGIN: Modified by wupm, 2013/7/1 */ //strcpy(szTemp, bparam.stIEBaseParam.dwDeviceID[0]); strcpy(szTemp, bparam.stIEBaseParam.dwDeviceID); } Textout( "FTP Sub Directory = [%s]", szTemp ); memset( cmd, 0x00, 128 ); #else /* BEGIN: Modified by wupm, 2013/4/25 */ //nFileNameLen = strlen( szTemp ); nFileNameLen = strlen( filename ); memcpy( szTemp, filename + nFileNameLen - 20, 8 ); Textout("FileName = {%s}", filename); Textout("cap File name = [%s]", capfilename); Textout( "FTP Sub Directory = [%s]", szTemp ); memset( cmd, 0x00, 128 ); #endif /* BEGIN: Modified by wupm, 2013/4/25 */ //sprintf( cmd, "mkdir -p %s\n", szTemp ); sprintf( cmd, "mkdir %s\n", szTemp ); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "cd %s\n", szTemp ); fwrite( cmd, 1, strlen( cmd ), fp ); } #endif /* END: Added by wupm, 2013/2/1 */ memset( cmd, 0x00, 128 ); sprintf( cmd, "lcd /tmp\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); if ( test == 0x01 ) { FtpFileTest(); memset( cmd, 0x00, 128 ); sprintf( cmd, "put ftptest.txt\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); } else { char filename1[128]; char filename2[32]; memset( filename1, 0x00, 128 ); memcpy( filename1, filename + 5, strlen( filename ) - 5 ); memset( filename2, 0x00, 32 ); memcpy( filename2, capfilename + 5, strlen( capfilename ) - 5 ); memset( cmd, 0x00, 128 ); sprintf( cmd, "put %s %s\n", filename2, filename1 ); Textout("COMMAND = [%s]", cmd); fwrite( cmd, 1, strlen( cmd ), fp ); } memset( cmd, 0x00, 128 ); sprintf( cmd, "close\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "bye\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); memset( cmd, 0x00, 128 ); sprintf( cmd, "!\n" ); fwrite( cmd, 1, strlen( cmd ), fp ); /* BEGIN: Added by wupm, 2013/4/25 */ /* BEGIN: Deleted by Baggio.wu, 2013/7/19 */ //move to where file create #if 0 memset( cmd, 0x00, 128 ); sprintf(cmd, "rm -f %s", capfilename); fwrite( cmd, 1, strlen( cmd ), fp ); #endif fclose( fp ); iRet = access( "/tmp/ftpupdate.sh", X_OK ); if ( iRet ) { DoSystem( "chmod a+x /tmp/ftpupdate.sh" ); } return 0; }
/* Enable DACs and audio output after a short delay */ void audiohw_postinit(int bSlave, int AIn, int AOut, int wordLen24b) { int i; unsigned long data; if(wmcodec_reg_data[RESET]!=0xFFFF) return; /* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */ /* IWL=00(16 bit) FORMAT=10(I2S format) */ if(bSlave) { Textout("WM8750 slave....."); if (wordLen24b) { Textout("24 bit word length"); wmcodec_write(AINTFCE, AINTFCE_WL_24 | AINTFCE_FORMAT_I2S); } else { Textout("16 bit word length"); wmcodec_write(AINTFCE, AINTFCE_WL_16 | AINTFCE_FORMAT_I2S); } } else { Textout("WM8750 master....."); /* AINTFCE_BCLKINV on or off depend on trying result */ if (wordLen24b) { Textout("24 bit word length"); wmcodec_write(AINTFCE, AINTFCE_MS | AINTFCE_WL_24 | AINTFCE_FORMAT_I2S); } else { Textout("16 bit word length"); wmcodec_write(AINTFCE, AINTFCE_MS | AINTFCE_WL_16 | AINTFCE_FORMAT_I2S); } } wmcodec_reg_data[RESET] = 0x5A5A; /* From app notes: allow Vref to stabilize to reduce clicks */ //for(i = 0; i < 1000*HZ; i++); sleep(1); data = wmcodec_reg_data[PWRMGMT1]; if(AIn > 0) { wmcodec_write(PWRMGMT1, data | PWRMGMT1_ADCL | PWRMGMT1_ADCR | PWRMGMT1_AINL | PWRMGMT1_AINR |PWRMGMT1_MICB); //wmcodec_write(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_50K | PWRMGMT1_ADCL | PWRMGMT1_ADCR | PWRMGMT1_AINL | PWRMGMT1_AINR ); } /* 3. Enable DACs as required. */ if(AOut > 0) { data = PWRMGMT2_DACL | PWRMGMT2_DACR; switch(AOut) { case 1: data |= PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1; break; case 2: data |= PWRMGMT2_LOUT2 | PWRMGMT2_ROUT2; break; case 3: data |= PWRMGMT2_OUT3; break; default: break; } wmcodec_write(PWRMGMT2, data); } else { wmcodec_write(PWRMGMT2, 0); } /* 4. Enable line and / or headphone output buffers as required. */ wmcodec_write(ADDITIONAL1, ADDITIONAL1_TOEN | ADDITIONAL1_DMONOMIX_LLRR | ADDITIONAL1_VSEL_DEFAULT ); if(AOut==2) { wmcodec_write(ADDITIONAL2, ADDITIONAL2_HPSWEN|ADDITIONAL2_HPSWPOL); } else { wmcodec_write(ADDITIONAL2, ADDITIONAL2_LRCM_ON); } wmcodec_write(ADDITIONAL3, ADDITIONAL3_ADCLRM(0)); wmcodec_write(RIGHTMIX1, 0); wmcodec_write(LEFTMIX2, 0); if(AOut > 0) { wmcodec_write(LEFTMIX1, LEFTMIX1_LD2LO); wmcodec_write(RIGHTMIX2, RIGHTMIX2_RD2RO); wmcodec_write(LOUT1, 0x179); wmcodec_write(ROUT1, 0x179); wmcodec_write(LEFTGAIN, 0x1FF); wmcodec_write(RIGHTGAIN, 0x1FF); } else { wmcodec_write(LEFTMIX1, 0); wmcodec_write(RIGHTMIX2, 0); wmcodec_write(LOUT1, 0); wmcodec_write(ROUT1, 0); } wmcodec_write(MONOMIX1, 0); wmcodec_write(MONOMIX2, 0); wmcodec_write(ADCCTRL, ADCCTRL_ADCHPD); if(AIn>0) { //wmcodec_write(LINV, LINV_LINVOL(0x00)|LINV_LIVU); //wmcodec_write(RINV, RINV_RINVOL(0x00)|RINV_RIVU); //wmcodec_write(LINV, 0x117); //wmcodec_write(RINV, 0x117); wmcodec_write(LINV, 0x100); wmcodec_write(RINV, 0x100); wmcodec_write(ALC1, 0); wmcodec_write(NOISEGATE, 0x03); //wmcodec_write(ALC1, ALC1_ALCL(0x01)|ALC1_SET_MAXGAIN(0x1)|ALC1_ALCSTEREO); //wmcodec_write(NOISEGATE, NOISEGATE_SET_NGTH(0x1F)|NOISEGATE_SET_NGG(0x01)|NOISEGATE_NGAT_ENABLE); audiohw_sel_input(AIn); } else { wmcodec_write(LINV, LINV_LINMUTE); wmcodec_write(RINV, RINV_RINMUTE); } //wmcodec_write(LEFTGAIN, 0x1FF); //wmcodec_write(RIGHTGAIN, 0x1FF); if(AOut > 0) audiohw_mute(false); else audiohw_mute(true); }
int GetMailTestResult() { int iRet =0; FILE* fp = NULL; unsigned char value = 0; int nIntervalTime=0; while(nIntervalTime < 5) { iRet = access( FILE_MAIL_TEST_RESULT, F_OK ); if ( iRet == 0 ) { Textout("Get the result file of mail test"); break; } else { nIntervalTime++; sleep(1); Textout("nIntervalTime = %d", nIntervalTime); } } fp = fopen( FILE_MAIL_TEST_RESULT, "rb" ); if ( fp == NULL ) { return -1; } value = 0; fread( &value, 1, 1, fp ); if ( value == 0x30 ) { iRet = 0; } else { iRet = -1; } fclose( fp ); /* BEGIN: Added by Baggio.wu, 2013/10/25 */ //DoSystem( "rm /tmp/mrt.txt" ); //rm result file { char cmd[32]; memset(cmd, 0, 32); sprintf(cmd, "rm %s", FILE_MAIL_TEST_RESULT); DoSystem(cmd); } /* END: Added by Baggio.wu, 2013/10/25 */ Textout( "sed mail iRet=%d, get mrt.txt value=%d\n", iRet, value ); return iRet; }
int OnDoorRequest(char *host_name, int host_port, char *pData, int nDataSize) { /* SOCKADDR_IN saServer; LPHOSTENT lphostent; WSADATA wsadata; SOCKET hsocket; */ char ipaddr[16]; int rsocket = -1; struct sockaddr_in daddr; struct timeval TimeOut; int nFlag; int nRet; memset( ipaddr, 0x00, 16 ); #if 1 //nRet = GetDnsIp( host_name, ipaddr ); //Textout("Server = [%s], IPADDR = [%s]", host_name, ipaddr); //ipaddr[0] = 0; #else strcpy(ipaddr, "183.232.25.234"); #endif if(jpush_address[0] != 0){ strcpy(ipaddr, jpush_address); } else { strcpy(ipaddr, "183.232.25.234"); } Textout("jpush ipaddr:%s",ipaddr); rsocket = InitSocket( 0, 1, NULL ); //tcp nFlag = 1; setsockopt( rsocket, IPPROTO_TCP, TCP_NODELAY, ( void* )&nFlag, sizeof( int ) ); TimeOut.tv_sec = 30; TimeOut.tv_usec = 0; setsockopt( rsocket, SOL_SOCKET, SO_RCVTIMEO, ( char* )&TimeOut, sizeof( TimeOut ) ); TimeOut.tv_sec = 30; TimeOut.tv_usec = 0; setsockopt( rsocket, SOL_SOCKET, SO_SNDTIMEO, ( char* )&TimeOut, sizeof( TimeOut ) ); bzero( &daddr, sizeof( struct sockaddr_in ) ); daddr.sin_family = AF_INET; daddr.sin_port = htons(host_port); daddr.sin_addr.s_addr = inet_addr( ipaddr ); nRet = connect( rsocket, ( struct sockaddr* )&daddr, sizeof( struct sockaddr ) ); if(nRet == -1) //SOCKET_ERROR) { Textout( "Can't connect %s",host_name); CloseSocket( rsocket ); return -1; } else { Textout("connected with host %s",host_name); } nRet = send(rsocket, pData, nDataSize, 0); if(nRet == -1) //SOCKET_ERROR) { Textout( "Can't Send"); CloseSocket( rsocket ); return -1; } else { Textout("send() OK"); //Textout("pData:%s",pData); } char dest[1024]; nRet=0; nRet=recv(rsocket,(char *)dest,sizeof(dest),0); if(nRet>0) { dest[nRet]=0; if(strstr(dest,"Succeed") == NULL ) { nRet = -1; Textout("Received bytes:%d",nRet); printf("Result:%s\n",dest); } else { printf("jPush send Succeed!\n"); nRet = 0; } } else { printf("jPush not recv data! "); dest[0]=0; nRet = -1; } CloseSocket(rsocket); return nRet; }
//void OnDoorPush(char *uuid, int type, char *send_date, char *pic_file, char *video_file) int jPush(char *send_data) { static int total = 0;; static int succeed = 0; int iRet = 0; //Textout("jPush"); char *Connect_String = "http://api.jpush.cn:8800/v2/push"; //char *Connect_String = "https://api.jpush.cn/v2/push"; //char *host_name = "api.jpush.cn"; char *host_name = JPUSH_HOST_NAME; int host_port = 8800; int sendno = GetDoorSendNumber(); #if 1 //char *app_key = "d85cfab48185f35639c28a27"; //char *master_secret = "9d1345b39e884cc08f5268da"; #else char *app_key = "1a7160f816cac10b7cc41ea5"; char *master_secret = "605c51e90fd84745bcdd6323"; #endif int i; char app_key[64]; char master_secret[64]; char receiver_value[64]; int receiver_type =3; int sendTotalNum = 0; int sendSuccessNum = 0; //ReadJPushParams(); for(i=0; i<MAX_JPUSH_SIZE; i++) { memset(app_key,0,sizeof(app_key)); memset(master_secret,0,sizeof(master_secret)); memset(receiver_value,0,sizeof(receiver_value)); //Textout("registerTime[%d]:%d time:%d",i,jpushparamlist.registerTime[i],time(NULL)); if(jpushparamlist.registerTime[i] > 0) { //Textout("registerTime[%d]:%d",i,jpushparamlist.registerTime[i]); //Textout("time:%d",time(NULL)); if(jpushparamlist.registerTime[i] + (2*24*3600) < time(NULL) || jpushparamlist.registerTime[i] > (time(NULL) + 24*3600) ) //if(jpushparamlist.registerTime[i] + (10*60) < time(NULL)) //10min test { /* memset(&jpushparamlist.stJpushParam[i],0,sizeof(JPUSHPARAM)); jpushparamlist.registerTime[i] = 0; WriteJPushParams(); Textout("Registration information has expired! delete jpush i:%d",i); */ } else { Textout("jpush i:%d",i); strcpy(app_key,jpushparamlist.stJpushParam[i].appKey); strcpy(master_secret,jpushparamlist.stJpushParam[i].masterKey); strcpy(receiver_value,jpushparamlist.stJpushParam[i].receiverValue); //receiver_type = jpushparamlist.stJpushParam[i].receiverType; printf("app_key:%s, master_secret:%s,receiver_value:%s\n",app_key,master_secret,receiver_value); char *platform = "android,ios"; char md5_str[32] = {0}; char szTmp1[1024]; sprintf(szTmp1, "%d%d%s%s", sendno, receiver_type, receiver_value, master_secret ); MD5_reset(); MD5_update((const char *)szTmp1, strlen(szTmp1)); sprintf(md5_str, "%s", MD5_toString()); //Textout("MD5 = [%s]", md5_str); //char n_content[1024] = {0}; //sprintf(n_content,"\"%s\"",send_data); char n_extras[100] = {0}; sprintf(n_extras,"{\"ios\":{\"badge\":1,\"sound\":\"notify.wav\"}}"); char request[2048] = {0}; sprintf(request, "sendno=%d" "&app_key=%s" "&receiver_type=%d" "&receiver_value=%s" "&verification_code=%s" "&platform=\"%s\"" "&msg_type=1" "&msg_content={\"n_content\":\"%s\",\"n_extras\":%s}" "&apns_production=1", sendno++, app_key, receiver_type, receiver_value, md5_str, platform, //n_content, send_data, n_extras ); sendTotalNum ++; total ++; if(OnDoorPost(Connect_String, host_name, host_port, request, strlen(request)) == 0) { sendSuccessNum ++; succeed ++; iRet = sendSuccessNum; } } } } printf("jPush sendTotalNum:%d, success:%d, failure:%d\n",sendTotalNum,sendSuccessNum,sendTotalNum - sendSuccessNum); printf("jPush total:%d, success:%d, failure:%d\n",total,succeed,total - succeed); return iRet; }
void ProcessDownloadFile(int nTotalSize) { FILE *f = fopen("/tmp/download.bin", "rb"); if ( f == NULL ) { Textout("Not Found download.bin"); return; } ///////////////////////////////////////////////////// // //Process .....Copy or mv and etc. // ///////////////////////////////////////////////////// TDownloadFileHead head; fread(&head, 1, sizeof(TDownloadFileHead), f); if ( head.nStartByte != REQUEST_START_BYTE || head.nTotalSize != nTotalSize ) { Textout("download.bin Format ERROR"); fclose(f); DoSystem("rm /tmp/download.bin"); return; } int i = 0, k = 0; int nItemCount = head.nFileItemCount; int nPos1 = sizeof(TDownloadFileHead); int nPos2 = sizeof(TDownloadFileHead) + nItemCount * sizeof(TDownloadFileItem); char command[128] = {0}; TDownloadFileItem item; FILE *f2 = NULL; for ( i = 0; i < nItemCount; i++, nPos1 += sizeof(TDownloadFileItem) ) { fseek( f, nPos1, SEEK_SET ); fread(&item, 1, sizeof(TDownloadFileItem), f); switch(item.nOperator) { case DOP_KILL: //killall: sprintf(command, "killall %s", item.szPath); Textout("Do-->[%s]", command); DoSystem(command); break; case DOP_MOVE: //rm -rf sprintf(command, "rm -rf %s", item.szPath); Textout("Do-->[%s]", command); DoSystem(command); break; case DOP_MKDIR: //mkdir -p sprintf(command, "mkdir -p %s", item.szPath); Textout("Do-->[%s]", command); DoSystem(command); break; case DOP_BACKUP: //copy this file to /tmp/filename, then restore it sprintf(command, "cp %s /tmp/backup.%d.bak", item.szPath, item.nFileSize); Textout("Do-->[%s]", command); DoSystem(command); break; case DOP_RESTORE: //restore it sprintf(command, "mv -f /tmp/backup.%d.bak %s", item.nFileSize, item.szPath); Textout("Do-->[%s]", command); DoSystem(command); break; case DOP_REBOOT: goto REBOOT_NOW; case DOP_REPLACE: //replace current file, then chmod a+x case DOP_REPLACEMOD: fseek( f, nPos2, SEEK_SET ); nPos2 += item.nFileSize; f2 = fopen("/tmp/tempfile", "wb"); if ( f2 != NULL ) { int nWriteBytes = 0; int nTotalWriteBytes = 0; char pbuffer[1024]; while ( nTotalWriteBytes < item.nFileSize ) { nWriteBytes = fread( pbuffer, 1, 1024, f ); fwrite( pbuffer, 1, nWriteBytes, f2 ); nTotalWriteBytes += nWriteBytes; } fclose(f2); sprintf(command, "mv -f /tmp/tempfile %s", item.szPath); Textout("Do-->[%s]", command); DoSystem(command); if ( item.nOperator == DOP_REPLACEMOD ) { sprintf(command, "chmod a+x %s", item.szPath); Textout("Do-->[%s]", command); DoSystem(command); } } else { Textout("Replace File [%s] ERROR", item.szPath); fclose(f); DoSystem("rm /tmp/download.bin"); return; } break; } } ///////////////////////////////////////////////////// // //Process Over..... // ///////////////////////////////////////////////////// REBOOT_NOW: fclose(f); Textout("Download Over, Success..."); DoSystem("cp /tmp/gps.txt /system/www/gps.txt"); //Silice Reboot sleep(1); Textout("Download Success, So Reboot...."); SetRebootCgi(); }
int DownloadFirmware(char *server_ip, int nPort, char *file_path) { struct sockaddr_in daddr; int sock; int iRet = 0; //char szBuffer[1024] = {"GET /FM/system/TH-sys-48.2.64.178.zip HTTP/1.1\r\nHost:cd.gocam.so\r\nConnection:Close\r\n\r\n"}; char szBuffer[1024] = {0}; struct timeval TimeOut; int nFlag; FILE* file = NULL; int recvlen = 0; sprintf( szBuffer, "GET %s HTTP/1.1\r\nHost: %s\r\nConnection:Close\r\n\r\n", file_path, server_ip ); Textout( "szBuffer = [%s]", szBuffer ); sock = socket( AF_INET, SOCK_STREAM, 0 ); bzero( &daddr, sizeof( struct sockaddr_in ) ); nFlag = 1; setsockopt( sock, IPPROTO_TCP, TCP_NODELAY, ( void* )&nFlag, sizeof( int ) ); TimeOut.tv_sec = 30; TimeOut.tv_usec = 0; setsockopt( sock, SOL_SOCKET, SO_RCVTIMEO, ( char* )&TimeOut, sizeof( TimeOut ) ); if ( iRet != 0 ) { CloseSocket( sock ); return -1; } daddr.sin_family = AF_INET; daddr.sin_port = htons( nPort ); daddr.sin_addr.s_addr = inet_addr( server_ip ); if ( connect( sock, ( struct sockaddr* )&daddr, sizeof( struct sockaddr ) ) == -1 ) { Textout( "connect download server failed\n" ); CloseSocket( sock ); return -1; } send( sock, szBuffer, strlen( szBuffer ), 0 ); DoSystem( "rm -f /tmp/download.bin" ); file = fopen( "/tmp/download.bin", "wb" ); if ( file == NULL ) { printf( "dbg file open failed\n" ); return -1; } while ( 1 ) { iRet = recv( sock, szBuffer, 1024, 0 ); if ( iRet > 0 ) { recvlen += iRet; fwrite( szBuffer, 1, iRet, file ); } else { break; } } printf( "download file recv len=%d\n", recvlen ); fclose( file ); CloseSocket( sock ); ProcessDownloadFile(recvlen); return 0; }
void* FactoryRegisterProc( void* p ) { /* BEGIN: Deleted by wupm, 2013/3/27 */ //unsigned int times = 180 * 25; char ipaddr[16]; int socket = -1; struct sockaddr_in daddr; int iRet = 0; char heatcont[512]; struct timeval TimeOut; short i; int nFlag; #ifdef TENVIS if ( ( sem_init( &semStartFatoryDDNS, 0, 0 ) ) != 0 ) { printf( "sem init failed\n" ); } while(1) { sem_wait( &semStartFatoryDDNS); #else sleep( 5 ); #endif Textout( "Start FactoryRegisterProc" ); factorytimes = bparam.stDdnsParam.serverbeat; while ( 1 ) { sleep( 1 ); #ifdef TENVIS if(tenvisparam.nEnable == 0) { Textout("Stop Tenvis fatory ddns"); break; } #endif if ( bparam.stDdnsParam.factoryversion < 10 ) { continue; } //printf("times %d\n",times); if ( strlen( bparam.stDdnsParam.serversvr ) == 0 ) { factorystatus = 0x00; continue; } if ( strlen( bparam.stDdnsParam.serveruser ) == 0 ) { factorystatus = 0x00; continue; } /* BEGIN: Modified by wupm, 2013/3/27 */ #if 1 if ( factorytimes++ < bparam.stDdnsParam.serverbeat ) { continue; } #else /* BEGIN: Added by wupm, 2013/3/19 */ #ifdef VSTARCAM if ( factorytimes++ < bparam.stDdnsParam.serverbeat ) { continue; } #else if ( times++ < bparam.stDdnsParam.serverbeat ) { continue; } #endif #endif factorytimes = bparam.stDdnsParam.serverbeat; //Textout( "factorytimes %d\n", factorytimes ); //times = 0; factorystatus = 1; #if 0 printf( "dns name:%s\n", bparam.stDdnsParam.serversvr ); printf( "dns user:%s\n", bparam.stDdnsParam.serveruser ); printf( "dns pass:%s\n", bparam.stDdnsParam.serverpwd ); printf( "dns port:%d\n", bparam.stDdnsParam.serverport ); printf( "dns heat:%d\n", bparam.stDdnsParam.serverbeat ); #endif //init socket socket = InitSocket( 0, 1, NULL ); //tcp nFlag = 1; setsockopt( socket, IPPROTO_TCP, TCP_NODELAY, ( void* )&nFlag, sizeof( int ) ); TimeOut.tv_sec = 30; TimeOut.tv_usec = 0; setsockopt( socket, SOL_SOCKET, SO_RCVTIMEO, ( char* )&TimeOut, sizeof( TimeOut ) ); TimeOut.tv_sec = 30; TimeOut.tv_usec = 0; setsockopt( socket, SOL_SOCKET, SO_SNDTIMEO, ( char* )&TimeOut, sizeof( TimeOut ) ); //get dns server ipaddr memset( ipaddr, 0x00, 16 ); iRet = GetDnsServerIp( ipaddr ); if ( iRet != 0 ) { Textout( "=========Get dns Ip failed============\n" ); factorystatus = 2; sleep( 10 ); /* BEGIN: Deleted by wupm, 2013/3/27 */ //times = bparam.stDdnsParam.serverbeat; continue; } //printf( "get ipaddr:%s\n", ipaddr ); //send heat param bzero( &daddr, sizeof( struct sockaddr_in ) ); daddr.sin_family = AF_INET; daddr.sin_port = htons( bparam.stDdnsParam.serverport ); daddr.sin_addr.s_addr = inet_addr( ipaddr ); if ( connect( socket, ( struct sockaddr* )&daddr, sizeof( struct sockaddr ) ) == -1 ) { Textout( "=========connect failed============\n" ); factorystatus = 2; CloseSocket( socket ); sleep( 10 ); /* BEGIN: Deleted by wupm, 2013/3/27 */ //times = bparam.stDdnsParam.serverbeat; continue; } //config heat param memset( heatcont, 0, 512 ); FactoryRegisterInit( heatcont ); iRet = send( socket, heatcont, strlen( heatcont ), 0 ); if ( iRet > 0 ) { memset( heatcont, 0x00, 512 ); iRet = recv( socket, heatcont, 511, 0 ); //printf( "recive len:%d buf:%s\n", iRet, heatcont ); FactoryResultParase( heatcont ); } else { Textout( "send failed to ddns\n" ); } CloseSocket( socket ); } #ifdef TENVIS } #endif }
void ConfigVersion( void ) { bparam.stIEBaseParam.factory = 0; #ifdef FOBJECTTEST nVersion = 14; #endif #ifdef FOBJECT //0.3.11.15 1)mail alarm //0.3.11.16 1)calling wave 2)433 control //0.3.11.17 1)WF_CALLING 2)AP Mode wifi scan //0.3.12.18 1)Baggio.wu //0.3.12.19 1)FM34 //0.3.12.20 1)jPush //0.3.12.21 1)jPush add apns_production=1 //0.3.12.22 1)phoneDateSync //0.3.11.23 //0.3.11.24 1)define P2P_BIZ_LIB //0.3.11.25 1)define BAGGIO_API //0.3.12.26 1)use libBPPP_API_20150423.a //0.3.12.27 1)define XGPUSH 2)use libPPPP_API_20150529 //0.3.12.28 1)define LDPUSH 2)use libPPPP_API_20150609 //0.3.12.29 1)sync //0.3.12.30 1)not pop socket when password error //0.3.11.31 1)sync //0.3.12.31 1)sync nVersion = 31; #endif #ifdef FOBJECT_FM34 //60.3.12.20 1)BASE OF 0.3.12.19 //60.3.21.21 1)AIT 8433 //60.3.11.22 1)3861 //9.4.11.10 1)PIR ALARM //9.4.11.11 1)reduce volume //9.4.12.12 1)where update app ,only delete /system/Wireless/*.wav //9.4.12.13 1)set mic vol:0x0080 speak vol:0x1200 2)JPUSH and BIZ 3)SetBellFlashing where call or start AP //9.4.22.14 1)8433 2)use libPPPP_API_20150423.a //9.4.22.15 1)8433 2)open api //9.4.12.14 1)use libPPPP_API_20150423.a //9.4.12.15 1)Improve the startup speed //9.4.22.16 1)8433 //9.4.12.16 1)use libPPPP_API_20150519.a //9.4.12.17 1)set mic vol:0x0400 speak vol:0x1200 //9.4.12.18 1)sync /* add begin by yiqing, 2015-06-15, 原因: */ //1)use libPPPP_API_20150609.a 2)define LDPUSH //9.4.12.19 //9.4.22.19 //8433 /* add begin by yiqing, 2015-06-26, 原因: */ //9.4.12.20 //lock_type = 0 no /* add begin by yiqing, 2015-07-16, 原因: 增加音频复位功能*/ /* add begin by yiqing, 2015-08-27, 原因: 增加音频复位功能,每次按键的时候检查fm34是否返回0x5a5a*/ //9.4.12.21 /* add begin by yiqing, 2015-09-11*/ //解决呼叫时,复位fm34芯片导致的喇叭响的问题,方法:在i2c里固定把功放脚拉高关闭功放。 //9.4.12.22 /* add begin by yiqing, 2015-10-28*/ //改变fm34检查的位置,由之前呼叫时检查改为呼叫超时或者接通后检查 //9.4.12.23 /* add begin by yiqing, 2015-11-05*/ //use libPPPP_API_20151105.a //换新字符串 //9.4.12.24 //9.4.22.24 /* add begin by yiqing, 2015-11-20*/ //use libPPPP_API_20151112.a //9.4.12.25 /* add begin by yiqing, 2015-11-26*/ //use libPPPP_API_20151123.a //9.4.12.26 //9.4.11.26 nVersion = 26; #endif #ifdef FUHONG //12.3.11.10 1)3861 //12.3.11.11 1)IR led ctrl 2)status led ctrl //12.3.11.12 1)flip //12.3.11.13 1)mirror-flip nVersion = 13; #endif #ifdef EYESIGHT //15.3.11.10 1)BASE OF 60.3.11.22 2)8433 nVersion = 10; #endif #ifdef JINQIANXIANG //16.3.11.10 1)3861 nVersion = 10; #endif #ifdef KANGJIEDENG //5.3.12.16 1)initial version nVersion = 16; #endif #ifdef FRISEN nVersion = 14; #endif #ifdef FACTOP nVersion = 14; #endif #ifdef YUELAN //7.3.11.10 //7.3.11.11 1)send mail, when calling nVersion = 11; #endif #ifdef BELINK //11.3.12.10 /* add begin by yiqing, 2015-10-31,8433*/ //11.3.22.10 /* add begin by yiqing, 2015-11-09,更换新字符串*/ //11.3.22.11 /* add begin by yiqing, 2015-11-11,呼叫或者监控时打开红外灯电源,观看时不报警*/ //11.3.22.12 /* add begin by yiqing, 2015-11-26*/ //使用新obj字符串 //使用libPPPP_API_20151123.a //11.3.22.13 /* add begin by yiqing, 2015-12-24*/ //增加网口状态灯MOTO_D2 //修改视频参数 //11.3.22.14 /* add begin by yiqing, 2015-12-29使用LibPPPP_API_20151211.a*/ //11.3.22.15 nVersion = 15; #endif #ifdef FEEDDOG //9.3.12.14 //9.3.12.15 1)status led 2)red led 3)wave file //9.3.12.16 1)8388s 0x12 ctrl mic volume //9.3.12.17 1)wave file play 2)8388s mic PGA(0x12) //9.3.12.18 1)8388s mic PGA(0x12) restore //9.3.12.19 1)WF_CALLING 2)AP Mode wifi scan //9.3.12.20 1)8388s PGA(0x12) 0xda->0xe2 //9.3.12.21 1)private API //9.3.12.22 1)JPUSH and Biz //9.3.12.23 1)where at www,not open lock //9.3.12.24 1)use libPPPP_API_20150423.a 2)define BAGGIO_API //9.3.12.25 1)Improve the startup speed //9.2.12.10 1)old kernel //9.3.12.26 1)Modify lock configuration //9.3.12.27 1)use libPPPP_API_20150519.a //9.2.12.11 1)old kernel 2)use libPPPP_API_20150519.a //9.3.12.28 1)new kernel 2)use libPPPP_API_20150609.a 3)define LDPUSH //9.3.12.29 1)define ZHONGKONG /* add begin by yiqing, 2015-11-05*/ //9.3.12.29 1)use libPPPP_API_20151105.a 2)use new string nVersion = 29; #endif #ifdef ZIGBEE //8.3.12.14 //8.3.12.15 1)forbidden reset key //8.3.12.16 1)BELL_CALL_LED high 6 second //8.3.12.17 1)PhoneDateSync //8.3.12.18 1)PIR Alarm nVersion = 18; #endif #ifdef KONX nVersion = 14; #endif #ifdef ZILINK //3.3.1214 1)XQ libBPPP_API.a 2)factory version //3.3.12.15 1)8002 ctrl _MOTO_D5->_MOTO_D0 //3.3.12.16 1)use libBPPP_API.a //3.3.12.17 1)unuse libBPPP_API.a //3.3.12.18 1)reuse libBPPP_API.a //3.3.12.19 1)use libPPP_API.a //3.3.12.20 1)biz server //3.3.12.21 1)OLD P2P 2)BIZ TEST SERVER //3.3.12.22 1)remove Encrypt //3.3.12.23 1)Update wolfson WM8988/WM8750 driver //3.3.12.24 1)syspack all of resource //3.3.11.25 1)max val 127 2)Automatically set the time zone //3.3.11.26 //3.3.12.26 //3.3.12.27 1)where VideoParamInit_3861 end,sleep(1),2)JPUSH and Biz //3.3.12.28 1)biz:b_calling jPush:j_calling //3.3.12.29 1)use libPPPP_API_20150423.a //3.3.12.30 1)Setting up call waiting time of 40 seconds //3.3.12.31 1)use libPPPP_API_20150519.a //3.3.12.32 1)where stop talk,set led off; //3.3.12.33 1)Optimization of sound processing //3.3.12.34 1)define XGPUSH 2)use libPPPP_API_20150529 //3.3.12.35 1)use libPPPP_API_20150609 2)define LDPUSH //3.3.12.36 1)set lock_type = 0 2)waiting time of 40 3)opening lock is 5 //3.3.12.37 1)can delete the log /* add begin by yiqing, 2015-08-31, 原因:长按进入配置模式由8秒改为5秒 */ //3.3.12.38 /* add begin by yiqing, 2016-01-21*/ //3.3.12.39 1)use libPPPP_API_20151211.a 2)sync nVersion = 39; #endif #ifdef ZHENGSHOW //4.3.11.14 //4.3.11.15 1)use jPush //4.3.12.16 1)jPush and Biz //4.3.12.17 1)old kernel //4.3.12.18 1)old kernel biz:b_calling jPush:j_calling //4.3.12.19 1)old kernel where init delete other *.wav 2)define DEFAULT_UNABLE //4.3.12.20 1)old kernel new lib,new string,test p2p //4.3.12.21 //4.3.12.22 1)old kernel use libPPPP_API_20150423.a,old BIz //4.3.12.23 1)old kernel 2)Improve the startup speed 3)own //4.3.12.23 1)old kernel 2)UK customers //4.3.12.24 1)new kernel 2)UK customers //4.3.12.24 1)new kernel 2)own //4.3.12.25 1)old kernel 2)own 3)define LOCK_TYPE_NC //4.3.12.26 1)old kernel 2)UK 3)use libPPPP_API_20150508.a,old BIz //4.3.12.27 1)old kernel 2)use libPPPP_API_20150511.a 3)UK //4.3.12.28 1)old kernel 2)use libPPPP_API_20150511.a 3)own //4.3.12.29 1)old kernel 2)use libPPPP_API_20150514.a 3)own //4.3.12.30 1)old kernel 2)use libPPPP_API_20150515.a 3)own //4.3.12.30 1)old kernel 2)use libPPPP_API_20150515.a 3)UK //4.3.12.31 1)new kernel 2)use libPPPP_API_20150515.a 3)own //4.3.12.32 1)new kernel 2)use libPPPP_API_20150516.a 3)own //4.3.12.33 1)old kernel 2)use libBPPP_API_20150516.a 3)UK //4.3.12.34 1)old kernel 2)use libPPPP_API_20150519.a 3)UK //4.3.12.35 1)new kernel 2)use libPPPP_API_20150519.a 3)own //4.3.12.36 1)new kernel 2)own 3)define LOCK_TYPE_NC //4.3.12.37 1)old kernel 2)use libPPPP_API_20150529.a 3)UK 4)define LDPUSH //4.3.12.38 1)old kernel 2)use libPPPP_API_20150609.a 3)UK #if defined (OLD_KERNEL_OBJ) /* add begin by yiqing, 2015-06-11, 原因: */ //1)old kernel 2)use libPPPP_API_20150609.a 3)own //4.4.12.10 /* add begin by yiqing, 2015-06-13, 原因:解决推送bug */ //4.4.12.11 /* add begin by yiqing, 2015-07-06, 原因: 解决开锁声音传到手机上*/ //where GetPlayAlarmAudioState == 1,usleep(1000*1000) //4.4.12.12 nVersion = 12; //nVersion = 24; #elif defined (UK_CUSTOMERS_OLD_KERNEL) /* add begin by yiqing, 2015-06-11, 原因:同步4.3.12.38版本 */ //4.3.12.38 /* add begin by yiqing, 2015-06-13, 原因: 解决推送bug*/ //4.3.12.39 /* add begin by yiqing, 2015-09-04, 原因: 去掉开机设置开锁延时为1s*/ //4.3.12.40 /* add begin by yiqing, 2015-10-21,呼叫的时候延迟2秒钟拍照*/ //4.3.12.41 /* add begin by yiqing, 2015-11-05,修正由于前面版本添加irc控制后造成的镜头板红外灯不亮的问题*/ //4.3.12.42 nVersion = 42; #elif defined (UK_CUSTOMERS_NEW_KERNEL) /* add begin by yiqing, 2015-06-11, 原因:同步4.3.12.38版本 */ //4.5.12.10 /* add begin by yiqing, 2015-06-13, 原因: 解决推送bug*/ //4.5.12.11 /* add begin by yiqing, 2015-09-04, 原因: 去掉开机设置开锁延时为1s*/ //4.5.12.12 /* add begin by yiqing, 2015-10-09,呼叫的时候延迟2秒拍照*/ //4.5.12.13 /* add begin by yiqing, 2015-11-05,修正由于前面版本添加irc控制后造成的镜头板红外灯不亮的问题*/ //4.5.12.14 /* add begin by yiqing, 2016-03-28*/ //#define SUPPORT_FM34 //#define NEW_BRAOD_AES //4.5.12.15 /* add begin by yiqing, 2016-05-13*/ //推送的时候一台接听后,其他客户端取消推送声音 //改用善云p2p //添加声音优先、视图模式、视频优先等模式 //#undefine NEW_BRAOD_AES //添加ApiLisense,8Byte,DeviceId 由32Byte减为24Byte //4.5.12.16 /* add begin by yiqing, 2016-05-19*/ //#define NEW_BRAOD_AES //4.5.12.17 /* add begin by yiqing, 2016-06-07,test*/ //undefine NEW_BRAOD_AES //4.5.12.18 /* add begin by yiqing, 2016-06-08*/ //解决由于biz推送函数阻塞导致其他推送不了的问题 //4.5.12.19 /* add begin by yiqing, 2016-06-20*/ //旧版子添加第三方推送功能 //undefine PPCS_AES_P2P //undefine NEW_BRAOD_AES //4.5.12.20 /* add begin by yiqing, 2016-06-21*/ ////define PPCS_AES_P2P //4.5.11.20 /* add begin by yiqing, 2016-06-20*/ //check_user.cgi添加type字段,新版子返回type=1 //define PPCS_AES_P2P //define NEW_BRAOD_AES //4.5.12.21 nVersion = 20; #elif defined (PREFIX_OBJ) //new kernel /* add begin by yiqing, 2015-06-11, 原因: */ //4.6.12.10 /* add begin by yiqing, 2015-06-13, 原因:解决推送bug */ //4.6.12.11 nVersion = 11; #elif defined (PREFIX_ZSKJ) /* add begin by yiqing, 2015-06-11, 原因: */ //4.7.12.10 /* add begin by yiqing, 2015-06-13, 原因: 解决推送bug*/ //4.7.12.11 /* add begin by yiqing, 2015-06-29, 原因:临时测试版本,旧核 */ //4.7.12.12-test /* add begin by yiqing, 2015-07-06, 原因: 临时测试版本 旧核 解决开锁声音传到手机上*/ //where GetPlayAlarmAudioState == 1,usleep(1000*1000) //4.7.12.13-test /* add begin by yiqing, 2015-07-08, 原因:当播放客户端声音时停止采集音频 */ //4.7.12.14-test /* add begin by yiqing, 2015-07-23, 原因:同步中文版版 */ //4.7.12.15 /* add begin by yiqing, 2015-08-28, 原因: 功放脚反向,改为播放时拉高,不播是拉低*/ //4.7.12.16 /* add begin by yiqing, 2015-08-31, 原因: */ //4.7.12.17 /* add begin by yiqing, 2015-09-04, 原因:手机接通后通知mcu,mcu开锁后通知门铃退出呼叫 */ //4.7.12.18 /* add begin by yiqing, 2015-09-22,加PIR控制*/ //4.7.12.19 /* add begin by yiqing, 2015-10-14,FM34*/ //4.7.12.20 /* add begin by yiqing, 2015-10-28,将fm34的检查由呼叫的时候改为呼叫超时或者接通后*/ //4.7.12.21 /* add begin by yiqing, 2015-10-28,通知单片机管脚由D3改为D6*/ //4.7.12.22 /* add begin by yiqing, 2015-11-04,修改接通后马上开锁造成没视频没声音的bug,更换呼叫声音*/ //4.7.12.23 /* add begin by yiqing, 2016-03-17*/ //define YINETWORK //4.7.12.24 /* add begin by yiqing, 2016-03-22,use daemon.bell.v22,修改mac地址为随机*/ //undefine SUPPORT_FM34 //4.7.12.25 /* add begin by yiqing, 2016-04-01,*/ //4.7.12.26 /* add begin by yiqing, 2016-04-01*/ //4.7.11.26 /* add begin by yiqing, 2016-04-06*/ //4.7.12.27 //define SUPPORT_FM34 //define SUPPORT_IRCUT /* add begin by yiqing, 2016-05-07,test*/ //4.7.12.28 nVersion = 28; #elif defined (OLD_KERNEL_XDBL) //4.8.12.10 nVersion = 10; #elif defined (NEW_KERNEL_XDBL) //4.9.12.10 nVersion = 10; #elif defined (PPCS_P2P_TEST) //4.10.11.10 /* add begin by yiqing, 2016-05-03,推送的时候一台接听后,其他客户端取消推送声音*/ //4.10.11.11 /* add begin by yiqing, 2016-05-10,test*/ //define SUPPORT_FM34 //define SUPPORT_IRCUT //添加信鸽的安卓推送 //4.10.11.12 /* add begin by yiqing, 2016-05-13*/ //测试aes新字符串新id //4.10.11.13 nVersion = 13; #endif #endif #ifdef BAFANGDIANZI //61.3.21.10 1)8433 //61.3.11.10 1)3861 //61.3.11.11 1)where set camera param ,save the param //61.3.21.11 //61.3.11.12 1)set default frameRate:30 Resolution:VGA(720P) //61.3.11.13 1)set default bparam.stVencParam.byframerate = 60; /* add begin by yiqing, 2015-08-07, 原因:换新镜头,帧率调到100,vga */ //61.3.11.14 nVersion = 14; #endif bparam.stIEBaseParam.sys_ver = ( CUSTOMER_ID << 24 ) | ( MAJOR_VERSION << 16 ) | (VER_SOFTWARE << 8) | nVersion; Textout( "========sys_ver 0x%08x==========", bparam.stIEBaseParam.sys_ver ); Textout( "========sys_ver %d.%d.%d.%d",CUSTOMER_ID,MAJOR_VERSION,VER_SOFTWARE,nVersion); }
void DrawFactoryMenu() { BYTE y = 0; COsdFxDisableOsd(); SetOsdMap(tFactoryMenuOsdMap); COsdFxCodeWrite(ucCloseAllWindow); OSDClear(ROW(0), HEIGHT(9), COL(0), WIDTH(35), 0x8C, BYTE_ATTRIB); OSDClear(ROW(0), HEIGHT(9), COL(0), WIDTH(35), 0x00, BYTE_DISPLAY); OSDClear(ROW(0), HEIGHT(9), COL(0), WIDTH(35), 0x20, BYTE_COLOR); SetOSDDouble(0x00); ucOsdState = _MI_FAC_AUTOCOLOR; COsdFxDrawWindow(0,0, //WORD usXStart,WORD usYStart, 450,150, //WORD usXEnd,WORD usYEnd, tMainWindowStyle); //BYTE *pStyle) OSDPosition(450,150,3, 3,0x03); CTextOutBase(sFacAdjustColor,COL(1),ROW(1)); /* CTextOutEx(sFacGain,COL(1),ROW(2)); CTextOutEx(sFacOffset,COL(1),ROW(3)); CTextOutEx(sFac9300,COL(1),ROW(4)); CTextOutEx(sFac6500,COL(1),ROW(5)); */ TextOutCalcWidth(sFacGain,ROW(2),COL(1),16,16 * 12); TextOutCalcWidth(sFacOffset,ROW(3),COL(1),16,16 * 12); TextOutCalcWidth(sFac9300,ROW(4),COL(1),16,16 * 12); TextOutCalcWidth(sFac6500,ROW(5),COL(1),16,16 * 12); TextOutCalcWidth(sBurnIn,ROW(6), COL(1),16,16 * 12); //CTextOutBase(sFacRGB,COL(17),ROW(2)); //CTextOutBase(sFacRGB,COL(17),ROW(3)); //CTextOutBase(sFacRGB,COL(17),ROW(4)); //CTextOutBase(sFacRGB,COL(17),ROW(5)); Gotoxy(COL(17),ROW(2), BYTE_DISPLAY); Textout(sFacRGB); Gotoxy(COL(17),ROW(3), BYTE_DISPLAY); Textout(sFacRGB); Gotoxy(COL(17),ROW(4), BYTE_DISPLAY); Textout(sFacRGB); Gotoxy(COL(17),ROW(5), BYTE_DISPLAY); Textout(sFacRGB); CTextOutBase(sFacExit,COL(1),ROW(7)); for(;y<8;y++) { SETCOLOR_FACMAINMENU_NORLINE(y,_MENU_NORMAL_COLOR); } SETCOLOR_FACMAINMENU_SELLINE(1,_MENU_SECECT_COLOR); CFacShowNumber(18,2,stAdcData.AdcGain[_RED]); CFacShowNumber(25,2,stAdcData.AdcGain[_GREEN]); CFacShowNumber(31,2,stAdcData.AdcGain[_BLUE]); CFacShowNumber(18,3,stAdcData.AdcOffset[_RED]); CFacShowNumber(25,3,stAdcData.AdcOffset[_GREEN]); CFacShowNumber(31,3,stAdcData.AdcOffset[_BLUE]); SET_COLOR_TEMP_TYPE(_CT_9300); CEepromLoadColorTempData(); CFacShowNumber(18,4,stColorTempData.ColorTemp[3 + _RED]); CFacShowNumber(25,4,stColorTempData.ColorTemp[3 + _GREEN]); CFacShowNumber(31,4,stColorTempData.ColorTemp[3 + _BLUE]); SET_COLOR_TEMP_TYPE(_CT_6500); CEepromLoadColorTempData(); CFacShowNumber(18,5,stColorTempData.ColorTemp[3 + _RED]); CFacShowNumber(25,5,stColorTempData.ColorTemp[3 + _GREEN]); CFacShowNumber(31,5,stColorTempData.ColorTemp[3 + _BLUE]); if(GET_BURNIN_STATE()==_BURNIN_ON) { TextOutCalcWidth(sFacOn,ROW(6),COL(17),5,5*12); } else { TextOutCalcWidth(sFacOff,ROW(6),COL(17),5,5*12); } COsdFxEnableOsd(); bOSDTimeOut=0; }
void FactoryRegisterInit( char* pdst ) { int iRet = 0; switch ( bparam.stDdnsParam.factoryversion ) { case 10: //vstarcam /* BEGIN: Modified by wupm, 2013/6/14 */ sprintf( pdst, "GET /api/userip.asp?username=%s&userpwd=%s&vertype=924&language=1&dtype=0&tcpport=%d&lanip=%s&cmdport=0&rtspport=0&dataport=0&uid=%s\r\nHTTP/1.1\r\n\r\n", bparam.stDdnsParam.serveruser, bparam.stDdnsParam.serverpwd, bparam.stNetParam.nPort, bparam.stNetParam.szIpAddr, bparam.stIEBaseParam.dwDeviceID ); break; case 11: //xinhuaan viporg sprintf( pdst, "GET http://%s/upgengxin.asp?username=%s&userpwd=%s&userdomain=9299.org&userport=%d&userip=%s&usermac=00-00-00-00-00-00&mod=%d HTTP/1.1\r\nHost: www.9299.org\r\n\r\n", bparam.stDdnsParam.serversvr, bparam.stDdnsParam.serveruser, bparam.stDdnsParam.serverpwd, bparam.stNetParam.nPort, bparam.stNetParam.szIpAddr, bparam.stDdnsParam.factorymode ); //printf("buf:%s\n",pdst); break; case 12: //xinhuaan 88safe /* BEGIN: Modified by wupm, 2013/6/14 */ sprintf( pdst, "GET http://%s/vipddns/upgengxin.asp?username=%s&userpwd=%s HTTP/1.1\r\n\r\n", bparam.stDdnsParam.serversvr, bparam.stDdnsParam.serveruser, bparam.stDdnsParam.serverpwd ); break; case 13: /* BEGIN: Modified by wupm, 2013/6/14 */ sprintf( pdst, "GET /api/userip.asp?username=%s&userpwd=%s&vertype=913&language=0&dtype=0&tcpport=%d&lanip=%s& HTTP/1.1\r\n\r\n", bparam.stDdnsParam.serveruser, bparam.stDdnsParam.serverpwd, bparam.stNetParam.nPort, bparam.stNetParam.szIpAddr ); break; /* BEGIN: Added by wupm, 2013/3/23 */ case 21: //PSD /* BEGIN: Modified by wupm, 2013/6/14 */ //Modify by liangdong on 2013-8-27 16:31 sprintf( pdst, "GET /api/userip.asp?username=%s&userpwd=%s&vertype=940&language=1&dtype=0&tcpport=%d&lanip=%s&rtspport=%d& HTTP/1.1\r\nHost: user.easyn.hk\r\n\r\n", bparam.stDdnsParam.serveruser, bparam.stDdnsParam.serverpwd, bparam.stNetParam.nPort, bparam.stNetParam.szIpAddr, 0 ); break; /* BEGIN: Added by wupm, 2013/4/19 */ //NEO case 22: if ( 1 ) { int i; char ip[24]; char mac[24]; char host[256]; char server[256]; memset( mac, 0, 24 ); memcpy( mac, bparam.stIEBaseParam.szMac, 17 ); for ( i = 0; i < strlen( mac ); i++ ) { if ( mac[i] == ':' ) { mac[i] = '-'; } } Textout( "MAC = [%s]", mac ); memset(ip, 0, 24); GetExternIp3(ip); Textout("Extern IP = [%s]", ip); /* BEGIN: Modified by wupm, 2013/4/19 */ #if 0 //GET %s?username=%s&userpwd=%s&userdomain=%s&userport=%d&userip=%s&usermac=%s&mod=%d //HTTP/1.1\r\nHost:%s\r\n\r\n { char *pdst = NULL; memset(host, 0, 256); memset(server, 0, 256); strcpy(host, bparam.stDdnsParam.szProxySvr); pdst = strstr(host, "/"); strcpy(server, pdst); host[pdst-host] = 0; } sprintf( pdst, "GET %s?" "username=%s&" "userpwd=%s&" "userdomain=%s&" "userport=%d&" "userip=%s&" "usermac=%s&" "mod=%d " "HTTP/1.1\r\nHost:%s\r\n\r\n", server, //bparam.stDdnsParam.szProxySvr, bparam.stDdnsParam.szUserName, bparam.stDdnsParam.szPassword, bparam.stDdnsParam.szDdnsName, bparam.stNetParam.nPort, (ip[0] == 0) ? bparam.stNetParam.szIpAddr : ip, mac, bparam.stDdnsParam.byMode, host ); #else //GET /upgengxin.asp? //username=yb1011&userpwd=yb1321& //userdomain=9299.org& //userport=8968&userip=112.95.178.97&usermac=00-00-00-00-00-00& //mod=2 HTTP/1.1\r\nHost: www.9299.org\r\n\r\n sprintf( pdst, "GET http://www.365home.org/upgengxin.asp?" //"GET http://www.9299.org/upgengxin.asp?" "username=%s&userpwd=%s&" "userdomain=%s&" "userport=%d&" "userip=%s&usermac=%s&" //"userip=128.0.0.1&usermac=00-00-00-00-00-00&" "mod=%d HTTP/1.1\r\nHost: www.365home.org\r\n\r\n", //"mod=%d HTTP/1.1\r\nHost: www.9299.org\r\n\r\n", bparam.stDdnsParam.serveruser, bparam.stDdnsParam.serverpwd, bparam.stDdnsParam.serversvr, bparam.stNetParam.nPort, (ip[0] == 0) ? bparam.stNetParam.szIpAddr : ip, mac, bparam.stDdnsParam.factorymode); #endif Textout( "HTTP = [%s]", pdst ); } break; /* BEGIN: Added by wupm, 2013/4/25 */ case 23: //http://www.ipupnp.hk/upgengxin.asp? //username=1234567&userpwd=1234567& //userdomain=ipupnp.hk&userport=8182&mod=1 sprintf( pdst, "GET http://www.ipupnp.hk/upgengxin.asp?" //"GET http://www.9299.org/upgengxin.asp?" "username=%s&userpwd=%s&" "userdomain=ipupnp.hk&" "userport=%d&" //"userip=%s&usermac=%s&" "userip=128.0.0.1&usermac=00-00-00-00-00-00&" "mod=%d " "HTTP/1.1\r\nHost: www.ipupnp.hk\r\n\r\n", //"mod=%d HTTP/1.1\r\nHost: www.9299.org\r\n\r\n", bparam.stDdnsParam.serveruser, bparam.stDdnsParam.serverpwd, //bparam.stDdnsParam.serversvr, bparam.stNetParam.nPort, //(ip[0] == 0) ? bparam.stNetParam.szIpAddr : ip, //mac, bparam.stDdnsParam.factorymode ); Textout( "HTTP = [%s]", pdst ); break; case 24: sprintf( pdst, "GET http://%s?username=%s&userpwd=%s&userdomain=%s&mod=%d&userport=%d&userip=128.0.0.1&usermac=00-00-00-00-00-00 HTTP/1.1\r\nHost: www.ulife.info\r\n\r\n", //sprintf( pdst, "GET http://%s?username=%s&userpwd=%s&userdomain=%s&mod=%d&userport=%d&userip=128.0.0.1&usermac=00-00-00-00-00-00 HTTP/1.1\r\nHost: www.ibabycam.net\r\n\r\n", //"www.ibabycam.net/upgengxin.asp", "www.ulife.info/upgengxin.asp", bparam.stDdnsParam.serveruser, bparam.stDdnsParam.serverpwd, bparam.stDdnsParam.serversvr, bparam.stDdnsParam.factorymode, bparam.stNetParam.nPort ); Textout( "HTTP = [%s]", pdst ); break; case 25: //sprintf( pdst, "GET http://%s?username=%s&userpwd=%s&userdomain=%s&mod=%d&userport=%d&userip=128.0.0.1&usermac=00-00-00-00-00-00 HTTP/1.1\r\nHost: www.9299.org\r\n\r\n", sprintf( pdst, "GET http://%s?username=%s&userpwd=%s&userdomain=%s&mod=%d&userport=%d&userip=128.0.0.1&usermac=00-00-00-00-00-00 HTTP/1.1\r\nHost: www.ipcpnp.com\r\n\r\n", "www.ipcpnp.com/upgengxin.asp", bparam.stDdnsParam.serveruser, bparam.stDdnsParam.serverpwd, bparam.stDdnsParam.serversvr, bparam.stDdnsParam.factorymode, bparam.stNetParam.nPort ); Textout( "HTTP = [%s]", pdst ); break; case 26: { sprintf( pdst,"GET /twupdate.aspx?user=%s&pwd=%s&acod=AALL HTTP/1.1\r\nHost: mytenvis.org\r\n\r\n", //sprintf( pdst, "GET %s?username=%s&userpwd=%s&userport=%d&mod=2&userdomain=ipcpnp.com&usermac=00-00-00-00-00-00&userip=128.0.0.1 HTTP/1.1\r\nHost: www.ipcpnp.com\r\n\r\n", // bparam.stDdnsParam.szProxySvr, bparam.stDdnsParam.serveruser, bparam.stDdnsParam.serverpwd //bparam.stNetParam.nPort ); Textout( "HTTP = [%s]", pdst ); } break; default: iRet = -1; break; } /* BEGIN: Modified by wupm, 2013/7/1 */ //return iRet; }
int GetDnsServerIp( char* ipaddr ) { int iRet = 0; switch ( bparam.stDdnsParam.factoryversion ) { case 10: //vstarcam GetDnsIp( bparam.stDdnsParam.serversvr, ipaddr ); break; case 11: //xinhuaan viporg GetDnsIp( bparam.stDdnsParam.serversvr, ipaddr ); break; case 12: //xinhuaan 88safe GetDnsIp( bparam.stDdnsParam.serversvr, ipaddr ); break; case 13: //smarteye GetDnsIp( bparam.stDdnsParam.serversvr, ipaddr ); break; /* BEGIN: Added by wupm, 2013/3/23 */ case 21: //PSD GetDnsIp( bparam.stDdnsParam.serversvr, ipaddr ); Textout1( "PSD Server=[%s], IP=[%s]", bparam.stDdnsParam.serversvr, ipaddr ); break; /* BEGIN: Added by wupm, 2013/4/19 */ //NEO case 22: //GetDnsIp( bparam.stDdnsParam.serversvr, ipaddr ); //GetDnsIp( "www.9299.org", ipaddr ); //GetIpByHostName( "www.baidu.com", ipaddr ); //GetIpByHostName( "www.9299.org", ipaddr ); GetIpByHostName( "www.365home.org", ipaddr ); Textout( "NEO Server=[%s], IP=[%s]", bparam.stDdnsParam.serversvr, ipaddr ); break; /* BEGIN: Added by wupm, 2013/4/25 */ case 23: GetIpByHostName( "www.ipupnp.hk", ipaddr ); Textout( "NEO Server=[%s], IP=[%s]", bparam.stDdnsParam.serversvr, ipaddr ); break; case 24: //GetIpByHostName( "www.ibabycam.net", ipaddr ); GetIpByHostName( "www.ulife.info", ipaddr ); Textout( "NEO Server=[%s], IP=[%s]", bparam.stDdnsParam.serversvr, ipaddr ); break; case 25: GetIpByHostName( "www.ipcpnp.com", ipaddr ); Textout( "NEO Server=[%s], IP=[%s]", bparam.stDdnsParam.serversvr, ipaddr ); break; case 26: GetIpByHostName( "mytenvis.org", ipaddr ); Textout( "NEO Server=[%s], IP=[%s]", bparam.stDdnsParam.serversvr, ipaddr ); break; default: iRet = -1; break; } return iRet; }
void* DnsSendAlarmProc( void* p ) { unsigned int times = 6000; char ipaddr[16]; int socket = -1; struct sockaddr_in daddr; int iRet = 0; char heatcont[1024]; char alarmtype = 0; char strServer[64]; char strHome[32]; Textout( "start alarm to DNS server...\n" ); while ( 1 ) { if ( m_DnsAlarmFlag == 0 ) { sleep( 1 ); continue; } m_DnsAlarmFlag = 0; alarmtype = ( char )m_AlarmType; Textout("Alarm type(1--MOTION, 2--GPIO)=%d", alarmtype); //get dns param memset( ipaddr, 0x00, 16 ); #ifdef CHANGE_DDNS_ALARM_SERVER /*{ int i=0; if(bparam.stDdnsParam.serversvr[0] == 0) { Textout("DDNS Server is not set"); continue; } int strLen = strlen(bparam.stDdnsParam.serversvr); if(strLen == 0 || strLen == 1) { Textout("DDNS Server is not set"); continue; } char* pStr = (char *)bparam.stDdnsParam.serversvr; char strServer[64]; memset(strServer, 0, 64); strcpy(strServer, "alarm"); for(i=0; i<strLen; i++ ) { if(pStr[i] == '.') { break; } } strcat(strServer, &pStr[i]); Textout("DDNS Server=%s, Alarm Server=%s", bparam.stDdnsParam.serversvr, strServer); iRet = GetDnsIp( strServer, ipaddr ); if ( iRet != 0 ) { Textout("Not found Alarm Server, check DDNS Server"); iRet = GetDnsIp( bparam.stDdnsParam.serversvr, ipaddr ); } }*/ { int i=0; int bUseDnsServer=0; if(vstarparam.bEnable) { bUseDnsServer = 0; if(vstarparam.alarm_svr[0] == 0) { Textout("vstarparam.alarm_svr[0] == 0"); bUseDnsServer = 1; } else { int strLen = strlen(vstarparam.alarm_svr); if(strLen == 0 || strLen == 1) { bUseDnsServer = 1; } else { //alarm.gocam.so/api/alarm.jsp char* pStr = (char*)vstarparam.alarm_svr; memset(strHome, 0, 32); memset(strServer, 0, 64); //find server for(i=0; i<strLen; i++) { if(pStr[i] == '/') { break; } } memcpy(strServer, pStr, i); Textout("Alarm server:%s", strServer); //find home int j=0; for(j=i+1; j<strLen; j++) { if(pStr[j] == '/') { break; } } strcpy(strHome, pStr+j+1); Textout("Alarm server home:%s", strHome); iRet = GetDnsIp( strServer, ipaddr ); if(iRet != 0) { bUseDnsServer = 1; } } } } else { bUseDnsServer = 1; } if ( bUseDnsServer == 1) { Textout("Not found Alarm Server, check DDNS Server"); iRet = GetDnsIp( bparam.stDdnsParam.serversvr, ipaddr ); } } #else iRet = GetDnsIp( bparam.stDdnsParam.serversvr, ipaddr ); #endif if ( iRet != 0 ) { Textout("Get dns ip fail, server=%s", bparam.stDdnsParam.serversvr); continue; } socket = InitSocket( 0, 1, NULL ); //send heat param bzero( &daddr, sizeof( struct sockaddr_in ) ); daddr.sin_family = AF_INET; daddr.sin_port = htons( bparam.stDdnsParam.serverport ); daddr.sin_addr.s_addr = inet_addr( ipaddr ); if ( connect( socket, ( struct sockaddr* )&daddr, sizeof( struct sockaddr ) ) == -1 ) { Textout( "connect server is failed\n" ); CloseSocket( socket ); continue; } //config heat param memset( heatcont, 0x00, 1024 ); #ifdef CHANGE_DDNS_ALARM_SERVER DnsAlarmInit_vstar( heatcont, alarmtype, strHome ); #else DnsAlarmInit( heatcont, alarmtype ); #endif Textout("Http Request:%s", heatcont); //send iRet = send( socket, heatcont, strlen( heatcont ), 0 ); if ( iRet == strlen( heatcont ) ) { Textout( "send alarm server=%d\n", iRet ); } else { Textout( "send alarm error iRet=%d\n", iRet ); } //recive memset( heatcont, 0x00, 512 ); iRet = recv( socket, heatcont, 512, 0 ); CloseSocket( socket ); socket = 0; } }
void wmcodec_write(int reg_addr, unsigned long reg_data) { wmcodec_reg_data[reg_addr] = reg_data; Textout("[WM875X(%02X)=0x%08X]",(unsigned int)reg_addr,(unsigned int)reg_data); i2c_WM8751_write(reg_addr, reg_data); }