123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732 |
- //
- // PlayerViewController+otherDelegate.m
- // 隐私保护
- //
- // Created by xd h on 2023/10/13.
- //
- #import "PlayerViewController+otherDelegate.h"
- #import "RCCommandHelp.h"
- #import "couldPhoneBaseInfoModel.h"
- #import "cachesFileManager.h"
- #import "couldphoneSysInfoModel.h"
- #import "TvStatusModel.h"
- #import "HWVersionModel.h"
- #import <MJExtension.h>
- #import "HaveNewVersionView.h"
- #import "connectDeviceManager.h"
- @implementation PlayerViewController (otherDelegate)
- #pragma mark ComontAlretViewControllerDelegate
- - (void)CommonAlertokBtnClickPressed{
- //HLog("11111");
-
- self.isLoginAgainType = YES;
-
- [[NSNotificationCenter defaultCenter] postNotificationName:lockBypwdNotification object:nil];
- }
- - (void)CommonAlertCancelBtnClickPressed{
- HLog("强制退出app");
-
- exit(0);/*强制退出app*/
- }
- - (void)checkVersionFun
- {
- [self getVersion];
- }
- #pragma mark- 网络请求
- - (void)getVersion {
-
- NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
- [paraDict setValue:@"ios" forKey:@"type"];
- [paraDict setValue:@"skyworth" forKey:@"source"];
-
- [[netWorkManager shareInstance] CommonGetWithCallBackCode:upgradeNewVersion Parameters:paraDict success:^(id _Nonnull responseObject) {
- //HLog(@"%@", responseObject);
- SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
- if (model.status == 0) {
- HWVersionModel *model = [HWVersionModel mj_objectWithKeyValues:responseObject[@"data"]];
- [self checkVersion:model];
- }
- else
- {
- //[[iToast makeText:model.msg] show];
- }
- } failure:^(NSError * _Nonnull error) {
- HLog(@"%@", error);
- }];
- }
- - (void)checkVersion:(HWVersionModel*)versionModel {
- // NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
- NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
- NSString *newVersion = [versionModel.versionNumber stringByReplacingOccurrencesOfString:@"v" withString:@""]; //去掉v
- // HLog(@"%@---%@", newVersion, currentVersion);
- if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedSame) { // 本地版本号 == 服务器版本号
- }else if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedDescending) { // 本地版本号 > 服务器版本号 (异常情况)
- [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
- }else { // 本地版本号 < 服务器版本号 (有新版本)
- [self showNewVersion:versionModel];
- [HWDataManager setBoolWithKey:Const_haveVersion value:YES];
- };
- }
- #pragma mark 需要强制重启
- - (void)updateForceStartFun{
-
-
- NSString* curSn = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
-
- NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
- [paraDict setValue:curSn forKey:@"sn"];
- [paraDict setValue:[NSNumber numberWithBool:YES] forKey:@"isForceStart"];
-
- [[netWorkManager shareInstance] CommonPostCallBackCode:updateForceStart Parameters:paraDict success:^(id _Nonnull responseObject) {
-
- SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
- if (model.status == 0) {
-
- }
- else
- {
-
- }
- } failure:^(NSError * _Nonnull error) {
- HLog(@"%@", error);
- }];
- }
- - (void)showNewVersion:(HWVersionModel*)versionModel {
-
- HaveNewVersionView *haveNewVersionView = [HaveNewVersionView shardInstance];
- if (haveNewVersionView.isShow) {
- return;
- }
- haveNewVersionView.versionModel = versionModel;
- haveNewVersionView.isContinueCheckAlert = NO; // 是否继续走下一步弹窗检测流程
- [haveNewVersionView setBackgroundColor:RGBACOLOR(0, 0, 0, 0.5)];
- [[iTools getKeyWindow] addSubview:haveNewVersionView];
- haveNewVersionView.isShow = YES;
-
- if(!versionModel.necessary){
- haveNewVersionView.deleteBtn.hidden = NO;
- }
-
- [haveNewVersionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(0);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(0);
- }];
- haveNewVersionView.alpha = 0.0;
- [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
- haveNewVersionView.alpha = 1.0;
- KyoLog(@"in animate start");
- } completion:^(BOOL finished) {
- KyoLog(@"in animate completion");
- }];
- }
- - (void)getCouldPhoneBaseInfoResponseFun:(NSDictionary *)dataDict
- {
- couldPhoneBaseInfoModel *model = [[couldPhoneBaseInfoModel alloc] initWithDictionary:dataDict error:nil];
- [[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneBaseInfoNotification object:model];
- }
- - (void)getCouldPhoneSysInfoResponseFun:(NSDictionary *)dataDict{
- couldphoneSysInfoModel *model = [[couldphoneSysInfoModel alloc] initWithDictionary:dataDict error:nil];
- [[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneSysInfoNotification object:model];
-
- NSString * predatestr = [HWDataManager getObjectWithKey:Const_did_show_image_version_date];
-
- NSString *datestr = [iTools getNowDateString];
-
- // if(predatestr && [predatestr isEqualToString:datestr]){
- // return;
- // }
-
- NSString *hostImgVer = model.data.data.hostImgVer;
-
- if (!hostImgVer || hostImgVer.length < 3) {
- //[self showImageViewRenewTipViewFun];
- return;
- }
-
- NSArray *versionArr = [hostImgVer componentsSeparatedByString:@"."];
-
- if(versionArr.count >= 2)
- {
- NSString * oneStr = versionArr[0];
- NSString * twoStr = versionArr[1];
-
- if(oneStr.integerValue >=1 && twoStr.integerValue >=2){
- return;
- }
- }
-
-
- [self showImageViewRenewTipViewFun];
- }
- - (void)getCouldPhoneTvStatusResponseFun:(NSDictionary *)dataDict
- {
- TvStatusModel *model = [[TvStatusModel alloc] initWithDictionary:dataDict error:nil];
- [[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneTvStatusNotification object:model];
-
- if(![model.msg containsString:@"PushStreamBActivity"])
- {
- return;
- }
-
- UIViewController*topVc = self.navigationController.viewControllers.lastObject;
- if([topVc isKindOfClass:[PlayerViewController class]]){
- [[iToast makeText:NSLocalizedString(@"tv_p2p_ing",nil)] show];
- }
- }
- - (void)showImageViewRenewTipViewFun
- {
- imageVersionRenewTipView * RenewTipView = [[imageVersionRenewTipView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H)];
- [self.view addSubview:RenewTipView];
- [self.view bringSubviewToFront:RenewTipView];
- }
- #pragma mark 监听文件开始的的通知
- - (void)beginGotoUploadFileFun:(NSNotification *)notification
- {
- self.isSuspendUploadType = NO;
-
- uploadFileDataModel *uploadFileDataMod = [notification object];
- //HLog(@"%@",uploadFileDataMod);
-
- // if(self.curUploadFileDataMod && uploadFileDataMod.bg_id.integerValue == self.curUploadFileDataMod.bg_id.integerValue){
- // return;
- // }
-
- self.curUploadFileDataMod = uploadFileDataMod;
-
- if(![uploadFileDataMod isKindOfClass:[uploadFileDataMod class]]){
- HLog(@"上传的文件类型不对");
- return;
- }
-
- [self ApplyUploadFileFun];
- }
- - (void)applyUploadFileServiceResponseFun:(NSDictionary *)dataDict
- {
- if([dataDict isKindOfClass:[NSDictionary class]]){
- if ([[dataDict allKeys] containsObject:@"data"]) {
- NSDictionary *data = dataDict[@"data"];
- if ([[data allKeys] containsObject:@"status"]) {
- NSString *status = [data objectForKey:@"status"];
- if(![status isKindOfClass:[NSString class]]){
- status = [[NSString alloc] initWithFormat:@"%@",status];
- }
-
- //if(1)
- if([status isEqualToString:@"1"])
- {
- //[self tryAgainApplyUploadFun];
- [self clearUploadFileDataFun];
- [[uploadFileManager shareInstance] uploadFileFailFun];
-
- }else if ([status isEqualToString:@"0"]){
- if ([[data allKeys] containsObject:@"taskUid"]) {
- NSString *taskUid = data[@"taskUid"];
- if(![status isKindOfClass:[NSString class]]){
- taskUid = [[NSString alloc] initWithFormat:@"%@",taskUid];
- }
-
- if(taskUid && [taskUid isEqualToString:self.taskUid]){
-
- NSNumber * fileLengthNum = @0;
- if ([[data allKeys] containsObject:@"fileLength"])
- {
- fileLengthNum = data[@"fileLength"];
- }
-
- // [[uploadFileManager shareInstance] changeUploadFileState:uploadStateUploading withDidUploadBytes:[fileLengthNum integerValue] withModel:self.curUploadFileDataMod complete:^(BOOL isSuccess) {
- //
- // }];
-
- if([fileLengthNum integerValue] == self.curUploadFileDataMod.totalBytes){
- self.taskUid = nil;
-
- NSMutableArray *delArr = [NSMutableArray new];
- [delArr addObject:self.curUploadFileDataMod];
- [[uploadFileManager shareInstance] deleteUploadFileRecordBy:delArr withDelCache:NO complete:^(BOOL isSuccess) {
- if (isSuccess) {
- [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileDeteleNotification object:self.curUploadFileDataMod];
- }
- }];
-
- // mainBlock(^{
- // [[iToast makeText:NSLocalizedString(@"File_upload_file_already_exists",nil)] show];
- // });
-
- HLog(@"hxd already 上传任务异常终止")
- return;
- }
-
- if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeImage){
- [self beginGotoUploadImageFun:fileLengthNum];
- }
- else{
- [self beginGotoUploadVidelFun:fileLengthNum];
- }
- }
- }
-
- }
- }
- }
- else{
- //异常
- [self tryAgainApplyUploadFun];
- }
- }
- else{
- //异常
- [self tryAgainApplyUploadFun];
- }
- }
- #pragma mark 图片上传
- -(void)beginGotoUploadImageFun:(NSNumber*)fileLengthNum{
-
- self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData withDidUpLoadSize:[fileLengthNum integerValue]];
-
- if(!self.cutFileDataArr){
- [self clearUploadFileDataFun];
- [[uploadFileManager shareInstance] uploadFileFailFun];
-
- self.taskUid = nil;
-
- mainBlock(^{
- [[iToast makeText:NSLocalizedString(@"File_upload_fail",nil)] show];
- });
- HLog(@"hxd fail 上传任务异常终止")
- return;
- }
-
- //答复的taskUid 跟申请的一致 开发发送内容
- [self upLoadFileFun];
- }
- #pragma mark 视频上传
- //每次从文件重新切一片 传一片
- -(void)beginGotoUploadVidelFun:(NSNumber*)fileLengthNum{
-
- NSData *data = [self cutVideoFileFunAtIndex:fileLengthNum.longLongValue];
- HLog(@"data leng:%ld",[data length]);
- self.AllFileData = data;
- self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData withDidUpLoadSize:0];
- self.indexOfUploadFlie = 0;
- HLog(@"data leng:%ld",[data length]);
-
- //return;
- // NSString*videoPathStr = [cachesFileManager getFilePathWithName:self.curUploadFileDataMod.filename type:uploadFileTypeVideo];
- // self.AllFileData = [NSData dataWithContentsOfFile:videoPathStr];
- // self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData withDidUpLoadSize:[fileLengthNum integerValue]];
-
- if(!self.cutFileDataArr){
- [self clearUploadFileDataFun];
- [[uploadFileManager shareInstance] uploadFileFailFun];
-
- self.taskUid = nil;
-
- mainBlock(^{
- [[iToast makeText:NSLocalizedString(@"File_upload_fail",nil)] show];
- });
- HLog(@"hxd fail 上传任务异常终止")
- return;
- }
-
- //答复的taskUid 跟申请的一致 开发发送内容
- [self upLoadFileFun];
- }
- #pragma mark 分段读视频文件
- -(NSData*)cutVideoFileFunAtIndex:(NSUInteger)dataIndex{
- NSString *filePath = [cachesFileManager getFilePathWithName:self.curUploadFileDataMod.filename type:uploadFileTypeVideo]; // 文件路径
-
- NSFileManager *manager0 = [NSFileManager defaultManager];
- if(![manager0 fileExistsAtPath:filePath]) {
-
- return [NSData new];
- }
-
- NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:filePath]; // 创建文件句柄
-
- // 设置分段读取的大小,这里以每次读取1KB为例
- //const NSUInteger chunkSize = 50 * 1024 *1024;
- const NSUInteger chunkSize = 5 * 1024 *1024;
- NSMutableData *data = [NSMutableData data];
-
- if (fileHandle) {
-
- long long endOfFile = [fileHandle seekToEndOfFile];
- if (endOfFile >= chunkSize) {
-
- // 读取文件的分段数据到某个位置
- [fileHandle seekToFileOffset:dataIndex];
-
- // 读取文件的分段数据
- NSData* chunk = [fileHandle readDataOfLength:chunkSize];
- if (chunk) {
- [data appendData:chunk];
- }
- }
- else{
- // 读取文件的分段数据到某个位置
- [fileHandle seekToFileOffset:dataIndex];
-
- [data appendData:[fileHandle readDataToEndOfFile]];
- }
-
- // 在这里可以对文件内容进行处理
- // ...
-
- // 关闭文件句柄
- [fileHandle closeFile];
- }
-
- return data;
- }
- - (void)upLoadFileFunServiceResponseFun:(NSDictionary *)dataDict
- {
- //{"type":"uploadFileRandomRet","data":{"progress":"9\/10","filePath":"/sdcard/Download/IMG_0036.JPG","status":"0","msg":"success"}}
-
- if([dataDict isKindOfClass:[NSDictionary class]]){
- if ([[dataDict allKeys] containsObject:@"data"]) {
- NSDictionary *data = dataDict[@"data"];
- if ([[data allKeys] containsObject:@"status"]) {
- NSString *status = [data objectForKey:@"status"];
- if(![status isKindOfClass:[NSString class]]){
- status = [[NSString alloc] initWithFormat:@"%@",status];
- }
-
- if ([status isEqualToString:@"1"]) {
- //[self tryAgainApplyUploadFun];
- [self clearUploadFileDataFun];
- [[uploadFileManager shareInstance] uploadFileFailFun];
-
- }else if ([status isEqualToString:@"0"]){
-
- NSNumber * fileLengthNum = @0;
- if ([[data allKeys] containsObject:@"fileLenth"])
- {
- fileLengthNum = data[@"fileLenth"];
- }
-
- [self handleUploadingFun:fileLengthNum];
- }
- }
- }
- else{
- //异常
- [self tryAgainApplyUploadFun];
- }
- }
- else{
- //异常
- [self tryAgainApplyUploadFun];
- }
-
- }
- #pragma mark 申请上传文件
- - (void)ApplyUploadFileFun
- {
- //if(!self.taskUid){
- self.taskUid = [iTools getTaskUidStr];
- self.fileName = self.curUploadFileDataMod.filename;
- if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeVideo){
- //self.AllFileData = self.curUploadFileDataMod.videoData;
- }
- else{
- self.AllFileData = self.curUploadFileDataMod.imageData;
- }
-
- self.indexOfUploadFlie = 0;
-
- //HLog(@"%@ %@",self.taskUid,self.fileName);
- //self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData];
- //}
-
- NSString * commandStr = [RCCommandHelp applyForUploadFileBy:self.taskUid filePath:self.fileName];
- [self.commandChannelManager rc_sendData:commandStr];
- }
- #pragma mark 遇到异常时 重新上传
- - (void)tryAgainApplyUploadFun
- {
- self.taskUid = nil;
- [self ApplyUploadFileFun];
- }
- #pragma mark 处理上传过程
- - (void)handleUploadingFun:(NSNumber*)fileLengthNum
- {
- if(self.isSuspendUploadType){
- //暂停
- self.taskUid = nil;
- //NSInteger didUploadSize = (self.indexOfUploadFlie+1) * (self.cutFileEachPieceSzie);
- NSInteger didUploadSize = fileLengthNum.longLongValue;
- [[uploadFileManager shareInstance] changeUploadFileState:uploadStateSuspend withDidUploadBytes:didUploadSize withModel:self.curUploadFileDataMod complete:^(BOOL isSuccess) {
- }];
-
- return;
- }
-
- if(self.indexOfUploadFlie < self.cutFileDataArr.count -1) {
-
- //NSInteger didUploadSize = (self.indexOfUploadFlie+1) * (self.cutFileEachPieceSzie);
- NSInteger didUploadSize = fileLengthNum.longLongValue;
-
- [[uploadFileManager shareInstance] changeUploadFileState:uploadStateUploading withDidUploadBytes:didUploadSize withModel:self.curUploadFileDataMod complete:^(BOOL isSuccess) {
- }];
-
- self.indexOfUploadFlie ++;
- [self upLoadFileFun];
- }
- else if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeVideo && fileLengthNum && fileLengthNum.longLongValue < self.curUploadFileDataMod.totalBytes){
- //视频做了二次切割 不一定上传完了
- HLog(@"视频上传传完一片 再来一片");
- [self beginGotoUploadVidelFun:fileLengthNum];
- }
- else{
- HLog(@"上传完成");
-
- [self clearUploadFileDataFun];
- [[uploadFileManager shareInstance] uploadFileDoneFun];
- }
- }
- -(void)clearUploadFileDataFun{
- //上传数据清空
- self.taskUid = nil;
- self.fileName = nil;
- self.AllFileData = nil;
- self.indexOfUploadFlie = 0;
- self.cutFileDataArr = nil;
- self.curUploadFileDataMod = nil;
- self.isSuspendUploadType = NO;
-
- }
- - (Byte)getBCC:(NSData *)data {
- Byte bcc = 0;
- unsigned char *bytes = (unsigned char *)[data bytes];
- for (int i = 0; i < [data length]; i++) {
- bcc = (Byte)(bcc ^ bytes[i]);
- }
- return bcc;
- }
- #pragma mark 文件切片
- -(NSMutableArray *)fileCutPartsBy:(NSData*)curData withDidUpLoadSize:(NSInteger)didLoadSize{
-
- NSData * data = curData;
-
- NSUInteger allLength = data.length;
-
- NSUInteger subs = 1*1024*1024;//4096;//要切片的大小,我这里设置的是4096字节
- //NSUInteger subs = 31*1024;//4096;//要切片的大小,内存没有暴增
-
- self.cutFileEachPieceSzie = subs;
-
- NSInteger index = 0;//起始位置
-
- if(didLoadSize != 0){
- if (didLoadSize % subs != 0){
- //出错了
- return nil;
- }
- else{
- // index = didLoadSize/subs;
- // allLength = allLength - didLoadSize;
-
- self.indexOfUploadFlie = didLoadSize/subs;
- }
- }
- NSMutableArray *dataArray =[NSMutableArray new];
-
- do {
- //@autoreleasepool {
- if (allLength>subs) {
-
- NSRange range =NSMakeRange(index*subs, subs);
-
- index++;
-
- //NSLog(@"%@",NSStringFromRange(range));
-
- [dataArray addObject:[data subdataWithRange:range]];
-
- allLength = allLength - subs;
-
- }else{
- NSRange range = NSMakeRange(index*subs, allLength);
-
- //NSLog(@"%@",NSStringFromRange(range));
-
- [dataArray addObject:[data subdataWithRange:range]];
-
- allLength = 0;
- }
- //}
-
- } while (allLength>0);
-
- HLog(@"dataArray leng:%ld",dataArray.count);//最后得到切片的结果,数组里面是NSData对象
- return dataArray;
- }
- // int转NSData
- - (NSData *)int2Data:(int)i{
- Byte b0 = i & 0xff;
- Byte b1 = i >> 8 & 0xff;
- Byte b2 = i >> 16 & 0xff;
- Byte b3 = i >> 24 & 0xff;
- // 有大小端模式问题?
- //Byte result[] = {b0, b1, b2, b3};
- Byte result[] = {b3, b2, b1, b0};
- return [NSData dataWithBytes:result length:sizeof(result)];
- }
- // short转NSData
- - (NSData *)short2Data:(short)i{
- Byte b0 = i & 0xff;
- Byte b1 = i >> 8 & 0xff;
- // 有大小端模式问题?
- //Byte result[] = {b0, b1, b2, b3};
- Byte result[] = { b1, b0};
- return [NSData dataWithBytes:result length:sizeof(result)];
- }
- #pragma mark 可以发送文件了
- /*
- 文件数据字节流byte[]
- 格式1:下载日志文件压缩包
- |head|msgType|taskId| datalen | curNum | totalNum| data |bcc校验|end|
- 长度: 1 1 6 (curNum+totalNum+data) 4 4 datalen- 8 1 1
- 0x68 0x0e 0x16
- bcc校验从第1位 也就是从msgType起 到 校验位前(不包含校验位)数据作bcc校验
- */
- - (void)upLoadFileFun
- {
- //HLog(@"上传文件%ld/%ld",self.indexOfUploadFlie +1,self.cutFileDataArr.count);
-
- if(self.cutFileDataArr.count <= self.indexOfUploadFlie)
- {
- return;
- }
-
- //data
- NSData *curData = self.cutFileDataArr[self.indexOfUploadFlie];
- //HLog(@"headData:%@",curData);
-
- //head
- unsigned char headNum = 104;
- NSData *headData = [NSMutableData dataWithBytes:&headNum length:sizeof(headNum)];
- //HLog(@"headData:%@",headData);
-
- //msgType
- //unsigned char msgType = 12;
- unsigned char msgType = 15;
- NSData *msgTypeData = [NSMutableData dataWithBytes:&msgType length:sizeof(msgType)];
- //HLog(@"msgTypeData:%@",msgTypeData);
-
- //taskId
- NSData *taskIdData = [self.taskUid dataUsingEncoding:NSUTF8StringEncoding];
- //HLog(@"taskIdData:%@",taskIdData);
-
- //datalen
- int datalenNum = int([curData length] +(4+4));
- //NSData *datalenData = [NSData dataWithBytes:&datalenNum length:sizeof(datalenNum)];
- NSData *datalenData = [self int2Data:datalenNum];
- //HLog(@"datalenData %@",datalenData);
-
-
- //curNum
- int curNum = (int)self.indexOfUploadFlie;
- //NSData *curNumData = [NSData dataWithBytes:&curNum length:sizeof(curNum)];
- NSData * curNumData = [self int2Data:curNum];
- //HLog(@"curNumData:%@",curNumData);
-
- //totalNum
- int totalNum = (int)self.cutFileDataArr.count;
- //NSData *totalNumData = [NSData dataWithBytes:&totalNum length:sizeof(totalNum)];
- NSData * totalNumData = [self int2Data:totalNum];
- //HLog(@"totalNumData:%@",totalNumData);
-
- NSMutableData *checkBCCData = [NSMutableData new];
- [checkBCCData appendData:msgTypeData];
- [checkBCCData appendData:taskIdData];
- [checkBCCData appendData:datalenData];
- [checkBCCData appendData:curNumData];
- [checkBCCData appendData:totalNumData];
- [checkBCCData appendData:curData];
-
- long length = [curData length];
- //HLog(@"curData length %d",length);
-
- Byte bccCheck = [self getBCC:checkBCCData];
- //HLog(@"bcc 000 %d",bccCheck);
-
- //bcc校验
- char bccNum = (char)bccCheck;
- NSData *bccData = [NSMutableData dataWithBytes:&bccNum length:sizeof(bccNum)];
- //HLog(@"%@",bccData);
-
- //end
- unsigned char endNum = 22;
- NSData *endData = [NSMutableData dataWithBytes:&endNum length:sizeof(endNum)];
- //HLog(@"%@",endData);
-
- NSMutableData *sendData = [NSMutableData new];
- [sendData appendData:headData];
- [sendData appendData:checkBCCData];
- [sendData appendData:bccData];
- [sendData appendData:endData];
-
- //HLog(@"sendData length %ld",[sendData length]);
- [self.commandChannelManager rc_sendData:sendData];
- //HLog(@"文件上传sendData %@",sendData);
- }
- - (void)suspendUploadFileFun:(NSNotification *)notification
- {
- self.isSuspendUploadType = YES;
- }
- @end
|