SDEASYCAM 手机APP软件 后30页代码.docx
#pragmamark-保存设置-(void)save:(id)sender(NSIntegerstart,end;startSWeekIndex*49+SHourIndex*2+SMinuteIndex;end=eWeekindex'49+eHorlnde×*2+eMintelnde×if(end>start)for(NSIntegeri=start:i<end:i+)(if(i-48Hi97Ui-146i»195i-244i293i-342)continue;)planTime(i='P'doubledelaylnSends=0.15;dispalch_lime_tpopTime-dispatch_time(DISPATCH_TIME_NOW,(int64j)(delaylnSeconds,NSEC_PER_SEC);dispatch-after(popTime1dispatch_get_main_queue(),ft(void)SMsgAVItrlSetScheduleReq*s2-malloc(sizeof(SMsgAVIoctrlSetScheduleReq);memset(s21O1Sizeof(SMsgAvioctrISetScheduIeReq):memcpy(s2->sDayData,planTime,sizeof(plaTime);s2->u32SchedulType=AVIOTCSCHEDULETYPEALARM;self.camerasendlOClrlToChannel:0Type:IOTYPE_USER_IPCAM_SET_SCHEDULE_REQData:(Char*)s2Dalasizersizeof(SMsgAvioctrISetScheduIeReq);free(s2);!);eseif(sWeeklndex=6&&eWeeklndex=0&&eHourlndex=0&&eMinutelndex=0)(end=342:for(NSIntegeri=start;i<end;i+)(if(i-48Hi-97i-146i»195i-244i»293i-342)continue;)plaTimel,P'doubledaylnSends=0.15;dispatchjime_tpopTime=dispatch_time(DISPATCH_TIME_NOW,(int64-t)(delaylnSends'NSEC_PER_SEC);dispatch_af(er(popTime,dispatch_get_main_queue(),ft(void)SMSgAVloCmSetSChedUIeReq*s2=malloc(sizeof(SMsgAVIoctrlSetScheduleReq);memset(s2,O1Sizeof(SMsgAvioctrtSetScheduIeReq);memcpy(s2->sDayData,planTime,sizeof(planTime);s2->u32ScheduleType=AVIOTC_SCHEDULETYPE_ALARM;self.camerasendlOCtrlToChannel:0Type:IOTYPE_USER_IPCAM_SET_SCHEDULE_REQData:(char*)s2Datasizersizeof(SMsgAvioctrISetScheduIeReq);free(s2);!);elseif(sWeeklndex=0&&sHourlndex=0&&sMinutelndex=0&&eWeeklndex=0&&eHourlndex=0&&eMinutelndex=0)(else(MBProgressHUDshowError:(NSStringstringWithFormat:NSLocalizedString("Error,Plstrysettingtimeagain!",return;/saveandIoadup/sendCMDSMsgAvioctrISetGuardReqEn*s1=malloc(sizeof(SMsgAVItrlSetGuardReqEn);memset(s1,O,sizeof(SMsgAVItrlSetGuardReqEn);s1->chanel=O;/memcpy(s1->ftpServer1sServerUTF8String,(sServerlength);Hmemcpy(s1->userName,sAccountUTF8String,sAccountlength);Hmemcpy(sl->password,sPasswdUTF8Strig,sPasswdlength);Hs1->ftpPort=(int)nPort;s1->alarm_motion_armed=self.isMotioSwitch;s1->alarm_motion_sensitivityself.motionDetection:sl->alarm_preset=self.alarmPresetValue;(Self-CamerasendlOCtrIToChannekOType:IOTYPE_USER_IPCAM_SETGUARD_REQData:(char*)s1Datasizersizeof(SMsgAvioctrISetGuardReqEn);free(s1):Z/2savevideotoSDCardSMsgAvioctrISetAlarmLinkageReqs2=mall。C(SiZeOf(SMSgAVIoCmSetAIarmLinkageReq);memset(s2,O,Sizeof(SMsgAvioctrISetAIarmLinkageReq);s2->channel=O;s2->VidToSDCard(inl)self.isSaveVideoToSD;Self-CamerasendIOCtriToChannekOType:IOTYPE_USER_IPCAM_SET_ALARM_LINKAGE_REQData:(char)s2Datasizeisizeof(SMsgAvioctrISetAlarmLinkageReq);free(s2);/quit(self.navigationControllerpopViewControllerAnimatedYES;)#pragmamark-sensiSpresetDelegate-(Vold)ClidSeleCtsenSitiVityValUe:(NSlnteger)VaIUe(self.motionDetection=value;SeIf-IabIeViewreIoadData;-(void)didSelectPresetValue:(NSInteger)valueself.alarmPreselValuevalue;SeIf-IabIeViewreIoadData;#pragmamark-MyCameraDeIegateMethods-(VOid)Camera:(MyCamera)Camera_didReceivelOClrlWithType:(NSIntec)er)typeData:(COnSlehar*)dataDataSiZe:(NSlntegerjSiZeif(camera.=self.camera&&type=IOTYPE_USER_IPCAM_GETGUARD_RESP)1057SMsgAvioctrIGetGuardRespEn*s=(SMSgAVioetriGetGUardReSPEn")data;SelfjsMotionSwitchs->alarm_motion_armed;self.motionDetection=s->aarmmotionsensitivity;NSLog(">%ld",(Iong)SeILmotionDetection);self.alarmPresetValues->alarm_PreSel;SelfjabeIHinLhiddenMYES;(Self-SenderIndicatorstopAnimating;self.navigationltem.righiBarButtonltem.enabledlself.senderlndicator.isAnimating;SetfAabIeViewreIoadData;elseif(camera,=self.camera&&type=IOTYPEUSERIPCAMGETMOTIONDETECTRESP)(SMsgAvioctrIGetMotionDetectResp's=(SMsgAVIoctrtGtMotionDtectRsp*)clata;self.motionDetection=s->sensitivity;SetfJabIeViewreIoadData;Jelseif(camera.=self.camera&&type=IOTYPE_USER_IPCAM_SET_ALARM_LINKAGE_RESP)SMsgAvioctrISetAIarmLinkageResp*s=(SMSgAVlOCtrlSetAIarmLinkageReSP"data;if(s->32Resut=O)(NSLog(”设pic&video保存到ftp成功!!");SeIf-IabIeViewreIoadData;elseif(camera_=sclf.camera&&type=IOTYPEUSERIPCAMGETALARMLINKAGERESP)/SMsgAvioctrIGetAIarmLinkageResp(1057SMSgAVloCmGetAIarmLinkageReSP*s=(SMsgAVIoctrIGetAIarmLinkageResp*)data;SelfjsSaveVideoToSDs>vidToSDCard;self.tableViewreIoadData;#pragmamark-UipickerViewDataSoure-(NSInteger)numberOfComponentslnPickerView:(UIPickerView,)pickerViewif(pickerType=WEEK_PICKER_VIEW)return1;elseif(pickerType=HM_PICKER_VIEW)(return2;retur1;)-(NSInteger)PiCkeMeW:(UIPiCkerVieW*)pickerViewnumberOfRowslnComponentr(NSInteger)mponent(if(pickerType=WEEK_PICKER_VIEW)(returnweekArr.count;elseif(pickerType=HM_PICKERVIEW)(if(component-0)retumhourArr.count;)else(retumminuteArr.count;return;)#Pragmamark-UIPickerViewDeIegate-(nullableNSString")PiCkerVieWXUlPiCkerVieW,)pickerViewtitleForRow:(NSInteger)rowforComponent:(NSlnteger)component(if(pickerType“WEEK_PICKER_VIEW)returnweekArrobjectAtlndex:row;elseif(pickerType=HM_PICKER_VIEW)(if(component=0)returnIhourArrobjectAtIndex:row:Jelseif(component=1)(returnminuteArrobjectAtlndex:row;)return"test")-(void)pickerView:(UIPickerView)pickerViewdidSelectRow:(NSInteger)rowinComponent:(NSlnteger)ComPonent(if(pickerType=WEEK_PICKER_VIEW)if(WhitchBtn=100)(SWeekIndex-row;eseif(whitchBtn=101)eWeekindexrow;Jelseif(pickerType=HMPICKERVIEW)(if(component0)(if(whitchBtn=200)(SHourIndex=row;)elseif(whitchBtn=201)(eHourindex=row;)elseif(component=1)(if(whitchBtn=200)(SMinuteIndex>row;eseif(whitchBtn=201)(eMinuteindexrow;)I#import<IOTCameraAVIOCTRLDEFs.h>#import"AboutDeviceController.h"#import,MBProgressHUD.h"implementationAboutDeviceControIIer©synthesizecamera:©synthesizelabelItems;SyntheSiZemodel;©synthesizeversion;©synthesizevender;SyntheSiZetotalSize;©synthesizeIreeSize;©synthesizemodellndicator;SyntheSiZeversionindicator;©synthesizeVenelerIndiCator;(synthesizetotallndicator;SyntheSiZefreelndicator; (IBAction)back:(id)sender(self.navigationControllerpopViewControllerAnimaied:YES;) Pragmamark-Viewlifecycle (Void)ViewDidLoad(SuperviewDidLoad):labelitems=NSArrayaIIocinitWithObjects:NSLoCaliZedString("FreeSize",NSLoCaIiZedString(”Tota1Size",NSLocalizedString("FormatSD",(§>""),nil;UIButton,customButton=(UIButtonbuttonWithType:UIButtonTypeCustom;CustomButton.frame-CGRectMake(O,0,44,44);CustomButtonsetBackgroundlmage:UllmageimageNamed:"cam_back"forState:UIControlStateNormal;(CustomButtonsetBackgroundlmage:(UllmageimageNamed:"cam_back_clicked'forState:UIControlStateHighlighted;CustomButtonaddTarget:selfaction:selector(back:)forControlEvents:UIControlEventTouchUplnside;UlBarButtonItem*backBtton=UlBarButtonItemaIIocinitWithCustomView:customButton;UIBarButtonItem*negativeSpacer=(UlBarButtonItemaIIocinitWithBarButtonSystemltem:UIBarButtonSystemltemFixedSpacetarget:nilaction:nil;negativeSpacer.width=-16;self.navigationltem.IeftBarButtonItems=NSArrayarrayWithObjects:negativeSpacer,backButton,nil;backButtonrelease);InegaliveSpacerrelease;self.navigationltem.tit=NSLOCaliZedString(-FOrmatSD",self.modelIndicator=UlActivitylndicatorViewaIIocinitWithActivitylndicatorStyle:UIActivitylndicatorViewStyleGrayautorelease:Self.Versionlndicator=(UIActivityIndicatorViewallinitWithActivitylndicatorstyleruiActivitylndicatorViewStyIeGrayautorelease;SeILvenderIndicator=(UlActivitylndicatorViewaIIocinitWithActivitylndicatorStyle:UIActivrtylndicatorViewStyleGrayautorelease;self.totallndicator-UlActivitylndicatorViewaIIocInitwithActivitylndicatorstyleiuiActivitylndicatorViewStyIeGrayautorelease;SeIfJreeIndicator=UIActivitylndicatorViewaIIocInitWithActivityIndicatorStyle:UIActivityIdicatorViewStyIeGrayautorelease; (void)viewDidUnloadself.modellndicator=nil;Self-Versionlndicator=nil;seif.venderindicator=nil;Selttotallndicator-nil;Slf.freelndicator=nil;self.modelnil;self.version-1;self.vendernil;self.totalSize-1:SeIfjreeSiZe-1;SeIfJabeIItems=nil;self.camera=nil;SuperviewDidUnload; (void)viewWillAppear:(BOOL)animated(SuperviewWiIIAppearianimated;SeIttotaISize-1;self.freeSize-1;camera.delegate2self;SMsgAvioctrIDevicelnfoReq,s=malloc(sizeof(SMsgAVIoctrlDeviceInfoReq);memset(s,O,Sizeof(SMsgAvioctrIDeviceInfoReq);(CamerasendIOCtrIToChannel:0Type:IOTYPE_USER_IPCAM_DEVINFO_REQData:(char*)sDatasizezsizeof(SMsgAvioctrIDeviceInfoReq);free(s); (void)viewWillDiSaPPear:(BoOL)animated(SuperviewwiIIDisappearianimated;camera.delegate2=nil;# (void)dealloc(modelindicatorrelease:versionIndicatorreease;venderindicatorrelease;totallndcatorrelease;(freelndicatorrelas;(modelrelease;venderrelease:(Iabelltemsrelease;(camerarelease):(Superdealloc;)# Pragmamark-TabIeViewDataSourceMethods# (NSInteger)numberOfSectionslnTableView:(UITableView,)tabeViewreturn1;)-(NSInteger)tableView:(UITableView*)tableViewnumberfRoWSlnSeetion:(NSIntegeljSeCtion(returlabelltems.cont;)-(UlTabIeViewCeII*)tableView:(UITableView*)tableViewCelIForRoWAundeXPath:(NSIndeXPath*)inde×PathNSUIntegerrow=indexPathrow);StaticNSString'AboutDeviceTabIeIdentifier=AboutDeviceTableIdentifier"UlTableViewCeII"cell=(self.tableViewdequeueReusableCellWithldentifier:AboutDeviceTabIeIdentifier;if(cell=nil)cellUlTableviewceIIaIIocinitWithStyle:UITableViewCellStyleValue1reuseldentifier:AboutDeviceTableldentifierautorelease;NSIntegerinde×=row;CeILtextLabeLtext=IabeiltemsobjectAtIndexjrKiex;CelI.SeIectionStyIe=UITableViewCellSelectionStyleNone;if(row=O)if(freeSize<O)celladdSubviewrfreelndicator:freelndicatorstartAnimating;freelndicalor.center-CGPointMake(280,22);)else(freelndicatorstopAnimating);IfreelndiCaIorremoveFromSuperview;)CeILdetaiITextLabeLtext(freeSize>O)?(NSStringstringWithFormati(g>,%ldMB",(log)freeSize:nil;elseif(row=1)if(totalSize<0)celladdSubviwnotallndicator;totalIndicatorstartAnimating:totallndicator.center=CGPointMake(280,22);elsetotalIndicatorstopAnimating;RotaIlndiCaIorremoveFromSuperview;)CeILdetaiITextLabel.te×t=(totalSize>=O)?NSStringstringWithFormat:"%ldMB",(Iong)IotaISize:nil:)returncell:)升pragmamark-Tableviewdelegate-(VOid)tableView:(UlTabIeView*)tableViewdidSelectRowAtlndexPath:(NSIndexPath*)inde×Path(NSIntegerrow=indexPathrow:if(row-2)UIAIertView,alert=UlAlertViewallocinitWithTitle:NSLocaliz©dString("Warmtips","")message:NSLocalizedString("FormatcommandwillERASEalldataofyourSDCard","")delegate:SeIfCanee旧UttOnTntie:NSLoCaliZedString(-Cance,"")OlherBUttOnTities:NSLOCaliZedString(-0K'nil;alertshow;)#Pragmamark-UIAIertViewDeIegate-(Void)alertView:(UIAlertVieW)alertViewClickedButtonAtlndex:(NSInteger)buttonInde×f(buttonindex-1)if(camera!»nil)(SMsgAVltrlFormatExtStorageReq*smalloc(sizeof(SMsgAVIoctrlFormatExtStorageReq);memset(s,O,Sizeof(SMsgAvioctrIFormatExtStorageReq);s->storage=O;CamerasendlOCtrIToChannekOType:IOTYPE_USER_IPCAM_FORMATEXTSTORAGE_REQData:(Char,)sDatasizeisizeof(SMsgAvioctrIFormatExtStorageReq);freefs);)- Pragmamark-CameraDeIegateMethods- (VOId)Camera:(MyCamera*)camera_CIidReCeiVelOCtrIWithTyPe:(NSlntegeIjtyPeData:(COnStehar*)dataDataSiZe:(NSlnlegerjSiZeif(camera,=camera&&type=IOTYPEUSERJPCAMDEVINFORESP)SMsgAvioctrlDeviceInfoResp*strctDevlnfo=(SMsgAVIoctrIDevicelnfoResp*)data:self,totalSize=structDevlnfo->total;self.freeSize=StructDevInfo->free;self.tableViewreloadData;elseif(camera-.Camera&&type»IOTYPE_USER_IPCAM_FORMATEXTSTORAGE_RESP)SMsgAvioctrlFormatExtStorageResp*s=(SMsgAvioctrlFormatExtStorageResp,)data;if(s->resut=O)(MBProgressHUD*hud=MBProgressHUDshowHUDAddedTo:self.viewanimated:YES);hd.mode=MBProgressHUDModeText;hud.labelText=NSLocalizedString('Formatcompleted.",hud.removeFromSuperViewOnHide=YES;hudhide:YESafterDelay:2;else(MBProgressHUD*hud=MBProgressHUDshowHUDAddedTo:self.viewanimated:YES;hud.mod=MBProgrssHUDModeText;hud.labelText=NSLocalizedString(*Formatfailed.",hud.remOVeFromSUPerVieWonHide=YES;hudhide:YESafterDeIay:2);)- (void)CheckTimeoutif(truebDoWaiting)UITabIeViewCeircell=self.tableViewcellForRowAtlndexPath:(NSIndexPathindexPathForRow:OinSection:0);UlActivityIndicatorView*waitView(UIActivityIndicatorView*)cellVieWWiIhTag:77;if(waitView)waitViewStopAnimating;waitViewremoveFromSuperview;UIAIertView,alert=(UlAlertViewaIIocinrtWithTitle:nilmessage:(NSStringstringWithFormat:NSLocalizedString("lrK»rrectpasswordfor%”,ssiddelegatemilcanCelBUttonTitle:NSLoCaHZedStringCloSe-,"")OtherButtonTitIesinil;alertshow:alertrelease;)- (IBAction)joinz(id)seder(NSString,password=nil;bDoWaiting.FALSE;if(IextFieIdBeingEdited!=nil)passwordIexlFieIdBeingEdited.Iext;f(password!=nil&&passwordlength>0)f(passwordlength<=30)SMsgAvioctrISetWifiReq,s=malloc(sizeof(SMsgAVIoctrISetWifiReq);memcpy(s->ssid,(ssidUTF8Slring,32);memcpy(s->password,passwordUTF8String132);s->enctype=enctype;s->modemode;(CamerasendioctrlTochannelX)TypeiIOTYPEUSERIPCAMSETWIFIREQData:(char*)sDatasizersizeof(SMsgAvioctrISetWifiReq);free(s);bDoWaiting=TRUE;(SeIfPerformSel©ctor:SeIeCtor(CheCkTimeOUt)WithobjeCtnlafterDelay:30;)else(UIAlertView*alert=(UlAlertViewaIIocinitWithTitle:nilmessage:NSLocalizedString("Thepasswordismorethan30characters",delegate:nilcancelButtonTitle:NSLocalizedString("Close","")OtherBUttOnTiUesmil;alertshow;alertrelease;elseUIAIertView,aert=(UlAlertViewaIIocinitWithTitle:nilmessage:(NSStringstringWithFonnat:NSLocaliz©dString("Pleaseenterpassword",delegate:nilcancelButtonTitle:NSLocalizedString("Close",OtherButtonTitIeszniI;alertshow:alertrelease;if(bDoWaitig)UITableViewCeircell=self.tableViewcellForRowAtlndexPath:NSIndexPathindexPathForRow:OinSection:0;UlActivilyIfXjicatorView*indicatorUIActivityIndicatorViewallocinilWithActivitylndicatorSty1e:UIActivitylndicatorViewStyleGray;/indicator.center=CGPointMake(SeILtextFieIdBeingEditedJrameQrigimx-20,self.textFieldBeingEdited.frame.origin.y+(self.texlFieldBeingEdited.frame.size.height/2);indicator.center=CGPointMake(260,22);indicator.lag-77;celladdSubviewdndicator;indicatorStartAnimating;(indicatorrelease;)-(IBAction)CanceIi(Id)Sender(self.navigationControllerpopViewControllerAnimatedYE