PlayerViewController+otherDelegate.mm 23 KB

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