PlayerViewController+otherDelegate.mm 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. //
  2. // PlayerViewController+otherDelegate.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/10/13.
  6. //
  7. #import "PlayerViewController+otherDelegate.h"
  8. #import "RCCommandHelp.h"
  9. #import "couldPhoneBaseInfoModel.h"
  10. #import "cachesFileManager.h"
  11. #import "couldphoneSysInfoModel.h"
  12. #import "TvStatusModel.h"
  13. #import "HWVersionModel.h"
  14. #import <MJExtension.h>
  15. #import "HaveNewVersionView.h"
  16. @implementation PlayerViewController (otherDelegate)
  17. #pragma mark ComontAlretViewControllerDelegate
  18. - (void)CommonAlertokBtnClickPressed{
  19. //HLog("11111");
  20. self.isLoginAgainType = YES;
  21. [[NSNotificationCenter defaultCenter] postNotificationName:lockBypwdNotification object:nil];
  22. }
  23. - (void)CommonAlertCancelBtnClickPressed{
  24. HLog("强制退出app");
  25. exit(0);/*强制退出app*/
  26. }
  27. - (void)checkVersionFun
  28. {
  29. [self getVersion];
  30. }
  31. #pragma mark- 网络请求
  32. - (void)getVersion {
  33. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  34. [paraDict setValue:@"ios" forKey:@"type"];
  35. [paraDict setValue:@"skyworth" forKey:@"source"];
  36. [[netWorkManager shareInstance] CommonGetWithCallBackCode:upgradeNewVersion Parameters:paraDict success:^(id _Nonnull responseObject) {
  37. //HLog(@"%@", responseObject);
  38. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  39. if (model.status == 0) {
  40. HWVersionModel *model = [HWVersionModel mj_objectWithKeyValues:responseObject[@"data"]];
  41. [self checkVersion:model];
  42. }
  43. else
  44. {
  45. //[[iToast makeText:model.msg] show];
  46. }
  47. } failure:^(NSError * _Nonnull error) {
  48. HLog(@"%@", error);
  49. }];
  50. }
  51. - (void)checkVersion:(HWVersionModel*)versionModel {
  52. // NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleVersion"];
  53. NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
  54. NSString *newVersion = [versionModel.versionNumber stringByReplacingOccurrencesOfString:@"v" withString:@""]; //去掉v
  55. // HLog(@"%@---%@", newVersion, currentVersion);
  56. if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedSame) { // 本地版本号 == 服务器版本号
  57. }else if ([currentVersion compare:newVersion options:NSNumericSearch] == NSOrderedDescending) { // 本地版本号 > 服务器版本号 (异常情况)
  58. [HWDataManager setBoolWithKey:Const_haveVersion value:NO];
  59. }else { // 本地版本号 < 服务器版本号 (有新版本)
  60. [self showNewVersion:versionModel];
  61. [HWDataManager setBoolWithKey:Const_haveVersion value:YES];
  62. };
  63. }
  64. - (void)showNewVersion:(HWVersionModel*)versionModel {
  65. HaveNewVersionView *haveNewVersionView = [HaveNewVersionView shardInstance];
  66. if (haveNewVersionView.isShow) {
  67. return;
  68. }
  69. haveNewVersionView.versionModel = versionModel;
  70. haveNewVersionView.isContinueCheckAlert = NO; // 是否继续走下一步弹窗检测流程
  71. [haveNewVersionView setBackgroundColor:RGBACOLOR(0, 0, 0, 0.5)];
  72. [[iTools getKeyWindow] addSubview:haveNewVersionView];
  73. haveNewVersionView.isShow = YES;
  74. if(!versionModel.necessary){
  75. haveNewVersionView.deleteBtn.hidden = NO;
  76. }
  77. [haveNewVersionView mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.top.mas_equalTo(0);
  79. make.left.mas_equalTo(0);
  80. make.right.mas_equalTo(0);
  81. make.bottom.mas_equalTo(0);
  82. }];
  83. haveNewVersionView.alpha = 0.0;
  84. [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^ {
  85. haveNewVersionView.alpha = 1.0;
  86. KyoLog(@"in animate start");
  87. } completion:^(BOOL finished) {
  88. KyoLog(@"in animate completion");
  89. }];
  90. }
  91. - (void)getCouldPhoneBaseInfoResponseFun:(NSDictionary *)dataDict
  92. {
  93. couldPhoneBaseInfoModel *model = [[couldPhoneBaseInfoModel alloc] initWithDictionary:dataDict error:nil];
  94. [[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneBaseInfoNotification object:model];
  95. }
  96. - (void)getCouldPhoneSysInfoResponseFun:(NSDictionary *)dataDict{
  97. couldphoneSysInfoModel *model = [[couldphoneSysInfoModel alloc] initWithDictionary:dataDict error:nil];
  98. [[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneSysInfoNotification object:model];
  99. }
  100. - (void)getCouldPhoneTvStatusResponseFun:(NSDictionary *)dataDict
  101. {
  102. TvStatusModel *model = [[TvStatusModel alloc] initWithDictionary:dataDict error:nil];
  103. [[NSNotificationCenter defaultCenter] postNotificationName:getCouldPhoneTvStatusNotification object:model];
  104. }
  105. #pragma mark 监听文件开始的的通知
  106. - (void)beginGotoUploadFileFun:(NSNotification *)notification
  107. {
  108. self.isSuspendUploadType = NO;
  109. uploadFileDataModel *uploadFileDataMod = [notification object];
  110. //HLog(@"%@",uploadFileDataMod);
  111. self.curUploadFileDataMod = uploadFileDataMod;
  112. if(![uploadFileDataMod isKindOfClass:[uploadFileDataMod class]]){
  113. HLog(@"上传的文件类型不对");
  114. return;
  115. }
  116. [self ApplyUploadFileFun];
  117. }
  118. - (void)applyUploadFileServiceResponseFun:(NSDictionary *)dataDict
  119. {
  120. if([dataDict isKindOfClass:[NSDictionary class]]){
  121. if ([[dataDict allKeys] containsObject:@"data"]) {
  122. NSDictionary *data = dataDict[@"data"];
  123. if ([[data allKeys] containsObject:@"status"]) {
  124. NSString *status = [data objectForKey:@"status"];
  125. if(![status isKindOfClass:[NSString class]]){
  126. status = [[NSString alloc] initWithFormat:@"%@",status];
  127. }
  128. //if(1)
  129. if([status isEqualToString:@"1"])
  130. {
  131. //[self tryAgainApplyUploadFun];
  132. [self clearUploadFileDataFun];
  133. [[uploadFileManager shareInstance] uploadFileFailFun];
  134. }else if ([status isEqualToString:@"0"]){
  135. if ([[data allKeys] containsObject:@"taskUid"]) {
  136. NSString *taskUid = data[@"taskUid"];
  137. if(![status isKindOfClass:[NSString class]]){
  138. taskUid = [[NSString alloc] initWithFormat:@"%@",taskUid];
  139. }
  140. if(taskUid && [taskUid isEqualToString:self.taskUid]){
  141. NSNumber * fileLengthNum = @0;
  142. if ([[data allKeys] containsObject:@"fileLength"])
  143. {
  144. fileLengthNum = data[@"fileLength"];
  145. }
  146. // [[uploadFileManager shareInstance] changeUploadFileState:uploadStateUploading withDidUploadBytes:[fileLengthNum integerValue] withModel:self.curUploadFileDataMod complete:^(BOOL isSuccess) {
  147. //
  148. // }];
  149. if([fileLengthNum integerValue] == self.curUploadFileDataMod.totalBytes){
  150. self.taskUid = nil;
  151. NSMutableArray *delArr = [NSMutableArray new];
  152. [delArr addObject:self.curUploadFileDataMod];
  153. [[uploadFileManager shareInstance] deleteUploadFileRecordBy:delArr complete:^(BOOL isSuccess) {
  154. if (isSuccess) {
  155. [[NSNotificationCenter defaultCenter] postNotificationName:uploadFileDeteleNotification object:self.curUploadFileDataMod];
  156. }
  157. }];
  158. mainBlock(^{
  159. [[iToast makeText:NSLocalizedString(@"File_upload_file_already_exists",nil)] show];
  160. });
  161. HLog(@"hxd already 上传任务异常终止")
  162. return;
  163. }
  164. if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeImage){
  165. [self beginGotoUploadImageFun:fileLengthNum];
  166. }
  167. else{
  168. [self beginGotoUploadVidelFun:fileLengthNum];
  169. }
  170. }
  171. }
  172. }
  173. }
  174. }
  175. else{
  176. //异常
  177. [self tryAgainApplyUploadFun];
  178. }
  179. }
  180. else{
  181. //异常
  182. [self tryAgainApplyUploadFun];
  183. }
  184. }
  185. #pragma mark 图片上传
  186. -(void)beginGotoUploadImageFun:(NSNumber*)fileLengthNum{
  187. self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData withDidUpLoadSize:[fileLengthNum integerValue]];
  188. if(!self.cutFileDataArr){
  189. [self clearUploadFileDataFun];
  190. [[uploadFileManager shareInstance] uploadFileFailFun];
  191. self.taskUid = nil;
  192. mainBlock(^{
  193. [[iToast makeText:NSLocalizedString(@"File_upload_fail",nil)] show];
  194. });
  195. HLog(@"hxd fail 上传任务异常终止")
  196. return;
  197. }
  198. //答复的taskUid 跟申请的一致 开发发送内容
  199. [self upLoadFileFun];
  200. }
  201. #pragma mark 视频上传
  202. //每次从文件重新切一片 传一片
  203. -(void)beginGotoUploadVidelFun:(NSNumber*)fileLengthNum{
  204. NSData *data = [self cutVideoFileFunAtIndex:fileLengthNum.longLongValue];
  205. HLog(@"data leng:%ld",[data length]);
  206. self.AllFileData = data;
  207. self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData withDidUpLoadSize:0];
  208. self.indexOfUploadFlie = 0;
  209. HLog(@"data leng:%ld",[data length]);
  210. //return;
  211. // NSString*videoPathStr = [cachesFileManager getFilePathWithName:self.curUploadFileDataMod.filename type:uploadFileTypeVideo];
  212. // self.AllFileData = [NSData dataWithContentsOfFile:videoPathStr];
  213. // self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData withDidUpLoadSize:[fileLengthNum integerValue]];
  214. if(!self.cutFileDataArr){
  215. [self clearUploadFileDataFun];
  216. [[uploadFileManager shareInstance] uploadFileFailFun];
  217. self.taskUid = nil;
  218. mainBlock(^{
  219. [[iToast makeText:NSLocalizedString(@"File_upload_fail",nil)] show];
  220. });
  221. HLog(@"hxd fail 上传任务异常终止")
  222. return;
  223. }
  224. //答复的taskUid 跟申请的一致 开发发送内容
  225. [self upLoadFileFun];
  226. }
  227. #pragma mark 分段读视频文件
  228. -(NSData*)cutVideoFileFunAtIndex:(NSUInteger)dataIndex{
  229. NSString *filePath = [cachesFileManager getFilePathWithName:self.curUploadFileDataMod.filename type:uploadFileTypeVideo]; // 文件路径
  230. NSFileManager *manager0 = [NSFileManager defaultManager];
  231. if(![manager0 fileExistsAtPath:filePath]) {
  232. return [NSData new];
  233. }
  234. NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:filePath]; // 创建文件句柄
  235. // 设置分段读取的大小,这里以每次读取1KB为例
  236. const NSUInteger chunkSize = 50 * 1024 *1024;
  237. NSMutableData *data = [NSMutableData data];
  238. if (fileHandle) {
  239. long long endOfFile = [fileHandle seekToEndOfFile];
  240. if (endOfFile >= chunkSize) {
  241. // 读取文件的分段数据到某个位置
  242. [fileHandle seekToFileOffset:dataIndex];
  243. // 读取文件的分段数据
  244. NSData* chunk = [fileHandle readDataOfLength:chunkSize];
  245. if (chunk) {
  246. [data appendData:chunk];
  247. }
  248. }
  249. else{
  250. // 读取文件的分段数据到某个位置
  251. [fileHandle seekToFileOffset:dataIndex];
  252. [data appendData:[fileHandle readDataToEndOfFile]];
  253. }
  254. // 在这里可以对文件内容进行处理
  255. // ...
  256. // 关闭文件句柄
  257. [fileHandle closeFile];
  258. }
  259. return data;
  260. }
  261. - (void)upLoadFileFunServiceResponseFun:(NSDictionary *)dataDict
  262. {
  263. //{"type":"uploadFileRandomRet","data":{"progress":"9\/10","filePath":"/sdcard/Download/IMG_0036.JPG","status":"0","msg":"success"}}
  264. if([dataDict isKindOfClass:[NSDictionary class]]){
  265. if ([[dataDict allKeys] containsObject:@"data"]) {
  266. NSDictionary *data = dataDict[@"data"];
  267. if ([[data allKeys] containsObject:@"status"]) {
  268. NSString *status = [data objectForKey:@"status"];
  269. if(![status isKindOfClass:[NSString class]]){
  270. status = [[NSString alloc] initWithFormat:@"%@",status];
  271. }
  272. if ([status isEqualToString:@"1"]) {
  273. //[self tryAgainApplyUploadFun];
  274. [self clearUploadFileDataFun];
  275. [[uploadFileManager shareInstance] uploadFileFailFun];
  276. }else if ([status isEqualToString:@"0"]){
  277. NSNumber * fileLengthNum = @0;
  278. if ([[data allKeys] containsObject:@"fileLenth"])
  279. {
  280. fileLengthNum = data[@"fileLenth"];
  281. }
  282. [self handleUploadingFun:fileLengthNum];
  283. }
  284. }
  285. }
  286. else{
  287. //异常
  288. [self tryAgainApplyUploadFun];
  289. }
  290. }
  291. else{
  292. //异常
  293. [self tryAgainApplyUploadFun];
  294. }
  295. }
  296. #pragma mark 申请上传文件
  297. - (void)ApplyUploadFileFun
  298. {
  299. if(!self.taskUid){
  300. self.taskUid = [iTools getTaskUidStr];
  301. self.fileName = self.curUploadFileDataMod.filename;
  302. if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeVideo){
  303. //self.AllFileData = self.curUploadFileDataMod.videoData;
  304. }
  305. else{
  306. self.AllFileData = self.curUploadFileDataMod.imageData;
  307. }
  308. self.indexOfUploadFlie = 0;
  309. //HLog(@"%@ %@",self.taskUid,self.fileName);
  310. //self.cutFileDataArr = [self fileCutPartsBy:self.AllFileData];
  311. }
  312. NSString * commandStr = [RCCommandHelp applyForUploadFileBy:self.taskUid filePath:self.fileName];
  313. [self.commandChannelManager rc_sendData:commandStr];
  314. }
  315. #pragma mark 遇到异常时 重新上传
  316. - (void)tryAgainApplyUploadFun
  317. {
  318. self.taskUid = nil;
  319. [self ApplyUploadFileFun];
  320. }
  321. #pragma mark 处理上传过程
  322. - (void)handleUploadingFun:(NSNumber*)fileLengthNum
  323. {
  324. if(self.isSuspendUploadType){
  325. //暂停
  326. self.taskUid = nil;
  327. NSInteger didUploadSize = (self.indexOfUploadFlie+1) * (self.cutFileEachPieceSzie);
  328. [[uploadFileManager shareInstance] changeUploadFileState:uploadStateSuspend withDidUploadBytes:didUploadSize withModel:self.curUploadFileDataMod complete:^(BOOL isSuccess) {
  329. }];
  330. return;
  331. }
  332. if(self.indexOfUploadFlie < self.cutFileDataArr.count -1) {
  333. //NSInteger didUploadSize = (self.indexOfUploadFlie+1) * (self.cutFileEachPieceSzie);
  334. NSInteger didUploadSize = fileLengthNum.longLongValue;
  335. [[uploadFileManager shareInstance] changeUploadFileState:uploadStateUploading withDidUploadBytes:didUploadSize withModel:self.curUploadFileDataMod complete:^(BOOL isSuccess) {
  336. }];
  337. self.indexOfUploadFlie ++;
  338. [self upLoadFileFun];
  339. }
  340. else if(self.curUploadFileDataMod.curUploadFileType == uploadFileTypeVideo && fileLengthNum && fileLengthNum.longLongValue < self.curUploadFileDataMod.totalBytes){
  341. //视频做了二次切割 不一定上传完了
  342. HLog(@"视频上传传完一片 再来一片");
  343. [self beginGotoUploadVidelFun:fileLengthNum];
  344. }
  345. else{
  346. HLog(@"上传完成");
  347. [self clearUploadFileDataFun];
  348. [[uploadFileManager shareInstance] uploadFileDoneFun];
  349. }
  350. }
  351. -(void)clearUploadFileDataFun{
  352. //上传数据清空
  353. self.taskUid = nil;
  354. self.fileName = nil;
  355. self.AllFileData = nil;
  356. self.indexOfUploadFlie = 0;
  357. self.cutFileDataArr = nil;
  358. self.curUploadFileDataMod = nil;
  359. self.isSuspendUploadType = NO;
  360. }
  361. - (Byte)getBCC:(NSData *)data {
  362. Byte bcc = 0;
  363. unsigned char *bytes = (unsigned char *)[data bytes];
  364. for (int i = 0; i < [data length]; i++) {
  365. bcc = (Byte)(bcc ^ bytes[i]);
  366. }
  367. return bcc;
  368. }
  369. #pragma mark 文件切片
  370. -(NSMutableArray *)fileCutPartsBy:(NSData*)curData withDidUpLoadSize:(NSInteger)didLoadSize{
  371. NSData * data = curData;
  372. NSUInteger allLength = data.length;
  373. //NSUInteger subs = 100*1024;//4096;//要切片的大小,我这里设置的是4096字节
  374. NSUInteger subs = 31*1024;//4096;//要切片的大小,内存没有暴增
  375. self.cutFileEachPieceSzie = subs;
  376. NSInteger index = 0;//起始位置
  377. if(didLoadSize != 0){
  378. if (didLoadSize % subs != 0){
  379. //出错了
  380. return nil;
  381. }
  382. else{
  383. // index = didLoadSize/subs;
  384. // allLength = allLength - didLoadSize;
  385. self.indexOfUploadFlie = didLoadSize/subs;
  386. }
  387. }
  388. NSMutableArray *dataArray =[NSMutableArray new];
  389. do {
  390. @autoreleasepool {
  391. if (allLength>subs) {
  392. NSRange range =NSMakeRange(index*subs, subs);
  393. index++;
  394. //NSLog(@"%@",NSStringFromRange(range));
  395. [dataArray addObject:[data subdataWithRange:range]];
  396. allLength = allLength - subs;
  397. }else{
  398. NSRange range = NSMakeRange(index*subs, allLength);
  399. //NSLog(@"%@",NSStringFromRange(range));
  400. [dataArray addObject:[data subdataWithRange:range]];
  401. allLength = 0;
  402. }
  403. }
  404. } while (allLength>0);
  405. HLog(@"dataArray leng:%ld",dataArray.count);//最后得到切片的结果,数组里面是NSData对象
  406. return dataArray;
  407. }
  408. // int转NSData
  409. - (NSData *)int2Data:(int)i{
  410. Byte b0 = i & 0xff;
  411. Byte b1 = i >> 8 & 0xff;
  412. Byte b2 = i >> 16 & 0xff;
  413. Byte b3 = i >> 24 & 0xff;
  414. // 有大小端模式问题?
  415. //Byte result[] = {b0, b1, b2, b3};
  416. Byte result[] = {b3, b2, b1, b0};
  417. return [NSData dataWithBytes:result length:sizeof(result)];
  418. }
  419. // short转NSData
  420. - (NSData *)short2Data:(short)i{
  421. Byte b0 = i & 0xff;
  422. Byte b1 = i >> 8 & 0xff;
  423. // 有大小端模式问题?
  424. //Byte result[] = {b0, b1, b2, b3};
  425. Byte result[] = { b1, b0};
  426. return [NSData dataWithBytes:result length:sizeof(result)];
  427. }
  428. #pragma mark 可以发送文件了
  429. /*
  430. 文件数据字节流byte[]
  431. 格式1:下载日志文件压缩包
  432. |head|msgType|taskId| datalen | curNum | totalNum| data |bcc校验|end|
  433. 长度: 1 1 6 (curNum+totalNum+data) 4 4 datalen- 8 1 1
  434. 0x68 0x0e 0x16
  435. bcc校验从第1位 也就是从msgType起 到 校验位前(不包含校验位)数据作bcc校验
  436. */
  437. - (void)upLoadFileFun
  438. {
  439. //HLog(@"上传文件%ld/%ld",self.indexOfUploadFlie +1,self.cutFileDataArr.count);
  440. //data
  441. NSData *curData = self.cutFileDataArr[self.indexOfUploadFlie];
  442. //HLog(@"headData:%@",curData);
  443. //head
  444. unsigned char headNum = 104;
  445. NSData *headData = [NSMutableData dataWithBytes:&headNum length:sizeof(headNum)];
  446. //HLog(@"headData:%@",headData);
  447. //msgType
  448. //unsigned char msgType = 12;
  449. unsigned char msgType = 15;
  450. NSData *msgTypeData = [NSMutableData dataWithBytes:&msgType length:sizeof(msgType)];
  451. //HLog(@"msgTypeData:%@",msgTypeData);
  452. //taskId
  453. NSData *taskIdData = [self.taskUid dataUsingEncoding:NSUTF8StringEncoding];
  454. //HLog(@"taskIdData:%@",taskIdData);
  455. //datalen
  456. int datalenNum = int([curData length] +(4+4));
  457. //NSData *datalenData = [NSData dataWithBytes:&datalenNum length:sizeof(datalenNum)];
  458. NSData *datalenData = [self int2Data:datalenNum];
  459. //HLog(@"datalenData %@",datalenData);
  460. //curNum
  461. int curNum = (int)self.indexOfUploadFlie;
  462. //NSData *curNumData = [NSData dataWithBytes:&curNum length:sizeof(curNum)];
  463. NSData * curNumData = [self int2Data:curNum];
  464. //HLog(@"curNumData:%@",curNumData);
  465. //totalNum
  466. int totalNum = (int)self.cutFileDataArr.count;
  467. //NSData *totalNumData = [NSData dataWithBytes:&totalNum length:sizeof(totalNum)];
  468. NSData * totalNumData = [self int2Data:totalNum];
  469. //HLog(@"totalNumData:%@",totalNumData);
  470. NSMutableData *checkBCCData = [NSMutableData new];
  471. [checkBCCData appendData:msgTypeData];
  472. [checkBCCData appendData:taskIdData];
  473. [checkBCCData appendData:datalenData];
  474. [checkBCCData appendData:curNumData];
  475. [checkBCCData appendData:totalNumData];
  476. [checkBCCData appendData:curData];
  477. long length = [curData length];
  478. //HLog(@"curData length %d",length);
  479. Byte bccCheck = [self getBCC:checkBCCData];
  480. //HLog(@"bcc 000 %d",bccCheck);
  481. //bcc校验
  482. char bccNum = (char)bccCheck;
  483. NSData *bccData = [NSMutableData dataWithBytes:&bccNum length:sizeof(bccNum)];
  484. //HLog(@"%@",bccData);
  485. //end
  486. unsigned char endNum = 22;
  487. NSData *endData = [NSMutableData dataWithBytes:&endNum length:sizeof(endNum)];
  488. //HLog(@"%@",endData);
  489. NSMutableData *sendData = [NSMutableData new];
  490. [sendData appendData:headData];
  491. [sendData appendData:checkBCCData];
  492. [sendData appendData:bccData];
  493. [sendData appendData:endData];
  494. //HLog(@"sendData length %ld",[sendData length]);
  495. [self.commandChannelManager rc_sendData:sendData];
  496. //HLog(@"文件上传sendData %@",sendData);
  497. }
  498. - (void)suspendUploadFileFun:(NSNotification *)notification
  499. {
  500. self.isSuspendUploadType = YES;
  501. }
  502. @end