|
@@ -8,13 +8,21 @@
|
|
|
|
|
|
#import "BTDataProcess.h"
|
|
#import "BTDataProcess.h"
|
|
#import "IOSPlatformSDK.h"
|
|
#import "IOSPlatformSDK.h"
|
|
|
|
+#include "Game.h"
|
|
#define NSLog(format, ...) printf("TIME:%s FILE:%s(%d行) FUNCTION:%s %s\n",__TIME__, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String])
|
|
#define NSLog(format, ...) printf("TIME:%s FILE:%s(%d行) FUNCTION:%s %s\n",__TIME__, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String])
|
|
@interface BTDataProcess ()<NSURLSessionDataDelegate>
|
|
@interface BTDataProcess ()<NSURLSessionDataDelegate>
|
|
|
|
|
|
|
|
+{
|
|
|
|
+@private
|
|
|
|
+ Game *game;
|
|
|
|
+}
|
|
|
|
+
|
|
@property (strong, nonatomic)NSMutableArray * deviceArray;/**< 蓝牙设备个数 */
|
|
@property (strong, nonatomic)NSMutableArray * deviceArray;/**< 蓝牙设备个数 */
|
|
@property (nonatomic,strong)IOSPlatformSDK * sdk;//ios_sdk
|
|
@property (nonatomic,strong)IOSPlatformSDK * sdk;//ios_sdk
|
|
-@property (nonatomic,strong)GameObjc * game ;//主设备蓝牙算法sdk
|
|
|
|
-@property (nonatomic,strong)GameObjc * viceDeviceGame ;//副设备设备蓝牙算法sdk
|
|
|
|
|
|
+
|
|
|
|
+//@property (nonatomic,strong)GameObjc * game ;//主设备蓝牙算法sdk
|
|
|
|
+
|
|
|
|
+//@property (nonatomic,strong)GameObjc * viceDeviceGame ;//副设备设备蓝牙算法sdk
|
|
@property(nonatomic,weak)NSTimer * timer;//定时器 定时请求主、副设备电量
|
|
@property(nonatomic,weak)NSTimer * timer;//定时器 定时请求主、副设备电量
|
|
@property(nonatomic,assign)BOOL gameModel;//是否开启游戏模式
|
|
@property(nonatomic,assign)BOOL gameModel;//是否开启游戏模式
|
|
|
|
|
|
@@ -27,9 +35,9 @@
|
|
@property (nonatomic,assign)int tempTs;
|
|
@property (nonatomic,assign)int tempTs;
|
|
@property (nonatomic,assign)int loss;
|
|
@property (nonatomic,assign)int loss;
|
|
@property (nonatomic,assign)int totalPackages;
|
|
@property (nonatomic,assign)int totalPackages;
|
|
-@property (nonatomic,strong)NSString * dataString;//缓存plist
|
|
|
|
|
|
+//@property (nonatomic,strong)NSString * dataString;//缓存plist
|
|
@property (nonatomic,strong)NSString * tempStepString;//缓存plist
|
|
@property (nonatomic,strong)NSString * tempStepString;//缓存plist
|
|
-
|
|
|
|
|
|
+@property(nonatomic,assign) NSNumber *RSSI;//威严要的测试数据
|
|
/*****测试*******/
|
|
/*****测试*******/
|
|
|
|
|
|
@end
|
|
@end
|
|
@@ -230,7 +238,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
if (self.deviceArray.count == 0){//数据源为0
|
|
if (self.deviceArray.count == 0){//数据源为0
|
|
|
|
|
|
// NSLog(@"add 扫描发现蓝牙设备 %@",peripheral.name);
|
|
// NSLog(@"add 扫描发现蓝牙设备 %@",peripheral.name);
|
|
-
|
|
|
|
|
|
+// peripheral.RSSI
|
|
[self.deviceArray addObject:peripheral];
|
|
[self.deviceArray addObject:peripheral];
|
|
//判断扫描到外设之后是否要链接蓝牙
|
|
//判断扫描到外设之后是否要链接蓝牙
|
|
[self ifAppJumpWithIdentifier:peripheral];
|
|
[self ifAppJumpWithIdentifier:peripheral];
|
|
@@ -310,10 +318,10 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
//初始化运轨sdk
|
|
//初始化运轨sdk
|
|
if (self.deviceType==DEVICETYPE_MAIN){
|
|
if (self.deviceType==DEVICETYPE_MAIN){
|
|
LEManager.peripheral = peripheral;
|
|
LEManager.peripheral = peripheral;
|
|
- self.game = [[GameObjc alloc] initWithGametype:self.game_id];
|
|
|
|
|
|
+ game = new Game(self.game_id);
|
|
}else if (self.deviceType == DEVICETYPE_VICE){
|
|
}else if (self.deviceType == DEVICETYPE_VICE){
|
|
LEManager.vicePeripheral = peripheral;
|
|
LEManager.vicePeripheral = peripheral;
|
|
- self.viceDeviceGame = [[GameObjc alloc] initWithGametype:self.game_id];
|
|
|
|
|
|
+// self.viceDeviceGame = [[GameObjc alloc] initWithGametype:self.game_id];
|
|
}
|
|
}
|
|
|
|
|
|
//根据ios_sdk传入deviceType 链接 主/副 设备
|
|
//根据ios_sdk传入deviceType 链接 主/副 设备
|
|
@@ -379,6 +387,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
if ([characteristic.UUID.UUIDString isEqualToString:@"6E400003-B5A3-F393-E0A9-E50E24DCCA9E"]){//判断是不是我们设备的特征值
|
|
if ([characteristic.UUID.UUIDString isEqualToString:@"6E400003-B5A3-F393-E0A9-E50E24DCCA9E"]){//判断是不是我们设备的特征值
|
|
// NSLog(@"characteristic.UUID.UUIDString = %@",characteristic.UUID.UUIDString);
|
|
// NSLog(@"characteristic.UUID.UUIDString = %@",characteristic.UUID.UUIDString);
|
|
[self verifyData:characteristic deviceType:type];
|
|
[self verifyData:characteristic deviceType:type];
|
|
|
|
+ [peripheral readRSSI];
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -386,21 +395,33 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
LEManager.writeToCharacteristicBlock = ^(CBPeripheral * _Nonnull peripheral,CBCharacteristic * _Nonnull characteristic, NSError * _Nonnull error, DEVICE_TYPE type){
|
|
LEManager.writeToCharacteristicBlock = ^(CBPeripheral * _Nonnull peripheral,CBCharacteristic * _Nonnull characteristic, NSError * _Nonnull error, DEVICE_TYPE type){
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ //
|
|
|
|
+ LEManager.rssiBlock = ^(NSNumber * _Nonnull RSSI){
|
|
|
|
+ self.RSSI = RSSI;
|
|
|
|
+// NSLog(@"self.RSSI = %@",self.RSSI );
|
|
|
|
+ };
|
|
|
|
+
|
|
//蓝牙连接成功
|
|
//蓝牙连接成功
|
|
LEManager.successfulBlock = ^(CBPeripheral * _Nonnull peripheral){
|
|
LEManager.successfulBlock = ^(CBPeripheral * _Nonnull peripheral){
|
|
// if (peripheral == LEManager.peripheral){
|
|
// if (peripheral == LEManager.peripheral){
|
|
[[AnimationView shanreAnimationView] stopAnimation];
|
|
[[AnimationView shanreAnimationView] stopAnimation];
|
|
};
|
|
};
|
|
|
|
|
|
-// //蓝牙连接失败
|
|
|
|
-// LEManager.connectFailureBlock = ^(NSError * _Nonnull error){
|
|
|
|
|
|
+ //蓝牙连接失败
|
|
|
|
+ LEManager.connectFailureBlock = ^(NSError * _Nonnull error){
|
|
|
|
+ NSLog(@"蓝牙链接失败");
|
|
// if (peripheral == LEManager.peripheral){
|
|
// if (peripheral == LEManager.peripheral){
|
|
-// [[AnimationView shanreAnimationView] addAnimation];
|
|
|
|
-// }
|
|
|
|
-// };
|
|
|
|
//
|
|
//
|
|
|
|
+// }
|
|
|
|
+ };
|
|
|
|
+
|
|
//蓝牙连接丢失
|
|
//蓝牙连接丢失
|
|
LEManager.disConnectBlock = ^(CBPeripheral * _Nonnull peripheral, NSError * _Nonnull error){
|
|
LEManager.disConnectBlock = ^(CBPeripheral * _Nonnull peripheral, NSError * _Nonnull error){
|
|
|
|
+
|
|
|
|
+ NSLog(@"蓝牙链接丢失");
|
|
|
|
+ //断线重连
|
|
|
|
+ [self initCBCentralManager];
|
|
|
|
+
|
|
if (peripheral == LEManager.peripheral){
|
|
if (peripheral == LEManager.peripheral){
|
|
if (LEManager.peripheral!=nil){
|
|
if (LEManager.peripheral!=nil){
|
|
|
|
|
|
@@ -427,7 +448,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
#pragma mark ===============================================>> 读取特征后 鞋子打开游戏模式 & 激光开关 &查询鞋子蓝牙状态 & 主设备初始化缓存游戏步数
|
|
#pragma mark ===============================================>> 读取特征后 鞋子打开游戏模式 & 激光开关 &查询鞋子蓝牙状态 & 主设备初始化缓存游戏步数
|
|
-(void)initGameAction:(DEVICE_TYPE)deviceType{
|
|
-(void)initGameAction:(DEVICE_TYPE)deviceType{
|
|
|
|
|
|
-
|
|
|
|
//初始化缓存动作数据
|
|
//初始化缓存动作数据
|
|
if (deviceType==DEVICETYPE_MAIN){
|
|
if (deviceType==DEVICETYPE_MAIN){
|
|
|
|
|
|
@@ -575,20 +595,16 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
|
|
|
|
// NSLog(@"主设备 接收到 鞋子动作数据 data = %@",characteristic);
|
|
// NSLog(@"主设备 接收到 鞋子动作数据 data = %@",characteristic);
|
|
//调取鞋子SDK
|
|
//调取鞋子SDK
|
|
- [self shoseSDKRight_pos:right_pos Right_att:right_att Right_acc:righrAcc LeftPos:left_pos Left_att:left_att Left_acc:left_acc ts:ts rightZupt:rightZupt leftZupt:leftZupt jump:jump down:down rssi:rssi girlShoes:girlShoes right_press:right_press left_press:left_press];
|
|
|
|
|
|
+ [self shoseSDKRight_pos:right_pos Right_att:right_att Right_acc:righrAcc LeftPos:left_pos Left_att:left_att Left_acc:left_acc ts:ts rightZupt:rightZupt leftZupt:leftZupt jump:jump down:down rssi:rssi girlShoes:girlShoes right_press:right_press left_press:left_press characteristic:characteristic];
|
|
|
|
|
|
}else if (deviceType==DEVICETYPE_VICE){//副设备动作数据
|
|
}else if (deviceType==DEVICETYPE_VICE){//副设备动作数据
|
|
|
|
|
|
// NSLog(@"副设备 接收到 鞋子动作数据 data = %@",characteristic);
|
|
// NSLog(@"副设备 接收到 鞋子动作数据 data = %@",characteristic);
|
|
- //调取鞋子SDK
|
|
|
|
- [self viceShoseSDKRight_pos:right_pos Right_att:right_att Right_acc:righrAcc LeftPos:left_pos Left_att:left_att Left_acc:left_acc ts:ts rightZupt:rightZupt leftZupt:leftZupt jump:jump down:down rssi:rssi girlShoes:girlShoes right_press:right_press left_press:left_press];
|
|
|
|
|
|
+// //调取鞋子SDK
|
|
|
|
+// [self viceShoseSDKRight_pos:right_pos Right_att:right_att Right_acc:righrAcc LeftPos:left_pos Left_att:left_att Left_acc:left_acc ts:ts rightZupt:rightZupt leftZupt:leftZupt jump:jump down:down rssi:rssi girlShoes:girlShoes right_press:right_press left_press:left_press];
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
- //开启剑波sdk数据字符串存储
|
|
|
|
- [self ocGetGameDataStr:characteristic];
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
}else if (dataType == -95){//获取的是查询的数据 char-->int a1 = -95
|
|
}else if (dataType == -95){//获取的是查询的数据 char-->int a1 = -95
|
|
|
|
|
|
if (characteristic.length == 74){//A1+0 >> 0: 设备基本信息 ==>> 预留参数 趣动app用 sdk暂未调用
|
|
if (characteristic.length == 74){//A1+0 >> 0: 设备基本信息 ==>> 预留参数 趣动app用 sdk暂未调用
|
|
@@ -609,7 +625,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
// int rightPressure = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(17, 4)]];
|
|
// int rightPressure = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(17, 4)]];
|
|
// int rightStepCount = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(21, 4)]];
|
|
// int rightStepCount = [AlgorithmTool dataToInt:[characteristic subdataWithRange:NSMakeRange(21, 4)]];
|
|
|
|
|
|
-
|
|
|
|
if (deviceType==DEVICETYPE_MAIN){//主设备
|
|
if (deviceType==DEVICETYPE_MAIN){//主设备
|
|
|
|
|
|
NSLog(@"主设备 接收到 鞋子硬件数据 data 26 = %@ 电量 %d %d",characteristic,leftElectricity,rightElectricity);
|
|
NSLog(@"主设备 接收到 鞋子硬件数据 data 26 = %@ 电量 %d %d",characteristic,leftElectricity,rightElectricity);
|
|
@@ -655,38 +670,37 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
rssi:(int)rssi
|
|
rssi:(int)rssi
|
|
girlShoes:(int)girlShoes
|
|
girlShoes:(int)girlShoes
|
|
right_press:(int)right_press
|
|
right_press:(int)right_press
|
|
- left_press:(int)left_press{
|
|
|
|
|
|
+ left_press:(int)left_press
|
|
|
|
+ characteristic:(NSData*)characteristic{
|
|
|
|
|
|
/********************初始化 运动轨迹算法 SDK *****************/
|
|
/********************初始化 运动轨迹算法 SDK *****************/
|
|
- [self.game gameProcess:ts
|
|
|
|
- rightPos:right_pos
|
|
|
|
- rightAtt:right_att
|
|
|
|
- rightAcc:right_acc
|
|
|
|
- rightZupt:rightZupt
|
|
|
|
- right_press:right_press
|
|
|
|
- leftPos:left_pos
|
|
|
|
- leftAtt:left_att
|
|
|
|
- leftAcc:left_acc
|
|
|
|
- leftZupt:leftZupt
|
|
|
|
- left_press:left_press
|
|
|
|
- jump:jump
|
|
|
|
- down:down
|
|
|
|
- rssi:rssi
|
|
|
|
- girl_shoes:girlShoes];
|
|
|
|
|
|
+ //游戏数据
|
|
|
|
+ NSData * validData= [characteristic subdataWithRange:NSMakeRange(4, characteristic.length-4)];
|
|
|
|
+ Byte * buff = (Byte*)[validData bytes];
|
|
|
|
+ game->GameProcessBuf(buff, (int)validData.length);
|
|
|
|
+
|
|
int length = 4;
|
|
int length = 4;
|
|
int result[length];
|
|
int result[length];
|
|
- [self.game getGameResult:result];
|
|
|
|
-// NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
|
|
|
|
|
|
+ game->getGameResult(result);
|
|
|
|
+ // NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
|
|
|
|
|
|
- /******************步频数据处理 + 回调*****************/
|
|
|
|
- int leftStepStatus = [self.game getStepStatus:LEFT_FOOT_OC];
|
|
|
|
- int leftStepFreq = [self.game getStepFreq:LEFT_FOOT_OC];
|
|
|
|
- int leftStepCount = [self.game getStepCount:LEFT_FOOT_OC];
|
|
|
|
- int rightStepStatus = [self.game getStepStatus:RIGHT_FOOT_OC];
|
|
|
|
- int rightStepFreq = [self.game getStepFreq:RIGHT_FOOT_OC];
|
|
|
|
- int rightStepCount = [self.game getStepCount:RIGHT_FOOT_OC];
|
|
|
|
|
|
+ NSString * aString = [NSString stringWithUTF8String:game->getGameDataStr().c_str()];
|
|
|
|
+// NSLog(@"aString == %@",aString);
|
|
|
|
+
|
|
|
|
+ self.tempStepString = [NSString stringWithFormat:@"%@\n",aString];
|
|
|
|
+ if (self.tempStepString!=nil && self.tempStepString.length>1){
|
|
|
|
+ [self writeFileToplist];
|
|
|
|
+ }
|
|
|
|
|
|
- /******************左右脚动作数据处理 + 回调*****************/
|
|
|
|
|
|
+ /******************步频数据处理 + 回调*****************/
|
|
|
|
+ int leftStepStatus = game->getStepStatus(LEFT_FOOT);
|
|
|
|
+ int leftStepFreq = game->getStepFreq(LEFT_FOOT);
|
|
|
|
+ int leftStepCount = game->getStepCount(LEFT_FOOT);
|
|
|
|
+ int rightStepStatus = game->getStepStatus(RIGHT_FOOT);
|
|
|
|
+ int rightStepFreq = game->getStepFreq(RIGHT_FOOT);
|
|
|
|
+ int rightStepCount = game->getStepCount(RIGHT_FOOT);
|
|
|
|
+
|
|
|
|
+// *****************左右脚动作数据处理 + 回调****************
|
|
int motionLeft = result[0];//左脚的动作
|
|
int motionLeft = result[0];//左脚的动作
|
|
int motionRight = result[1];//右脚的动作
|
|
int motionRight = result[1];//右脚的动作
|
|
int motionJump = result[2];//jump
|
|
int motionJump = result[2];//jump
|
|
@@ -714,50 +728,39 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
self.step_count = leftStepCount+rightStepCount;
|
|
self.step_count = leftStepCount+rightStepCount;
|
|
self.allMotionCountBLock(self.jump_count, self.crouch_count, leftStepCount+rightStepCount);
|
|
self.allMotionCountBLock(self.jump_count, self.crouch_count, leftStepCount+rightStepCount);
|
|
}
|
|
}
|
|
-
|
|
|
|
- //ios call unity
|
|
|
|
- if (self.gameModel==YES){//当前是游戏模式
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+// ios call unity
|
|
|
|
+// if (self.gameModel==YES){//当前是游戏模式
|
|
|
|
+
|
|
//跑酷才需要回调
|
|
//跑酷才需要回调
|
|
if (self.game_id == GAME_TYPE_RUN){
|
|
if (self.game_id == GAME_TYPE_RUN){
|
|
[self.sdk bridgingStepAction:DEVICETYPE_MAIN leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];//左右脚速度 步频
|
|
[self.sdk bridgingStepAction:DEVICETYPE_MAIN leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];//左右脚速度 步频
|
|
}
|
|
}
|
|
-
|
|
|
|
-// NSLog(@"主设备 当前是开启游戏模式 ===== >> %d",self.gameModel);
|
|
|
|
[self.sdk bridgingMotionAction:DEVICETYPE_MAIN left:motionLeft right:motionRight];//左右脚动作
|
|
[self.sdk bridgingMotionAction:DEVICETYPE_MAIN left:motionLeft right:motionRight];//左右脚动作
|
|
-
|
|
|
|
- }else{//当前是交互模式
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+// }else{//当前是交互模式
|
|
|
|
+
|
|
// int interaction = [self.game getInteractionCMD];
|
|
// int interaction = [self.game getInteractionCMD];
|
|
//// NSLog(@"主设备 当前的脚步交互动作 ===== >> %d",interaction);
|
|
//// NSLog(@"主设备 当前的脚步交互动作 ===== >> %d",interaction);
|
|
// [self.sdk bridgingInteraction:DEVICETYPE_MAIN code:interaction];
|
|
// [self.sdk bridgingInteraction:DEVICETYPE_MAIN code:interaction];
|
|
// if (self.getInteractionBlock){
|
|
// if (self.getInteractionBlock){
|
|
// self.getInteractionBlock(interaction);
|
|
// self.getInteractionBlock(interaction);
|
|
// }
|
|
// }
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
+
|
|
//
|
|
//
|
|
NSArray *aArray = [self.tempStepString componentsSeparatedByString:@","];
|
|
NSArray *aArray = [self.tempStepString componentsSeparatedByString:@","];
|
|
- self.testLabel.text = [NSString stringWithFormat:@"right:[%d,%d,%d] [%d,%d,%d] [%d,%d,%d] \nleft:[%d,%d,%d] [%d,%d,%d] [%d,%d,%d] \nZupt:[%d,%d] press:[%d,%d] \nj&d[%d %d] rssi:%d ts:%d \n脚步: %@ %@ \n步频: %d %d ",right_pos[0],right_pos[1],right_pos[2],right_att[0],right_att[1],right_att[2],right_acc[0],right_acc[1],right_acc[2],left_pos[0],left_pos[1],left_pos[2],left_att[0],left_att[1],left_att[2],left_acc[0],left_acc[1],left_acc[2],rightZupt,leftZupt,right_press,left_press,jump,down,rssi,ts,aArray[aArray.count-2],aArray.lastObject,leftStepFreq,rightStepFreq];
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // /******************测试丢包*****************/
|
|
|
|
- // int difference = abs(ts) - abs(self.tempTs);
|
|
|
|
- // //当前丢包数>2算作丢包
|
|
|
|
- // if (abs(difference)>=2){
|
|
|
|
- // self.loss = self.loss + abs(difference)-1;
|
|
|
|
- // self.totalPackages = self.totalPackages+abs(difference);
|
|
|
|
- //// NSLog(@"总数据包 1== >> self.totalPackages %d",self.totalPackages);
|
|
|
|
- // }else{
|
|
|
|
- // self.totalPackages++;
|
|
|
|
- //// NSLog(@"总数据包 2== >> self.totalPackages %d",self.totalPackages);
|
|
|
|
- // }
|
|
|
|
- // self.tempTs = abs(ts);
|
|
|
|
- //// NSLog(@"收到数据包 ===================>> ts: %d 当前包LOSS: %d 总包数: %d 总LOSS: %d",ts,abs(difference),self.totalPackages,self.loss);
|
|
|
|
|
|
+ self.testLabel.text = [NSString stringWithFormat:@"right:[%d,%d,%d] [%d,%d,%d] [%d,%d,%d] \nleft:[%d,%d,%d] [%d,%d,%d] [%d,%d,%d] \nZupt:[%d,%d] press:[%d,%d] \nj&d[%d %d] rssi:[%d %@] ts:%d \n脚步: %@ %@ \n步频: %d %d ",right_pos[0],right_pos[1],right_pos[2],right_att[0],right_att[1],right_att[2],right_acc[0],right_acc[1],right_acc[2],left_pos[0],left_pos[1],left_pos[2],left_att[0],left_att[1],left_att[2],left_acc[0],left_acc[1],left_acc[2],rightZupt,leftZupt,right_press,left_press,jump,down,rssi,self.RSSI,ts,aArray[aArray.count-2],aArray.lastObject,leftStepFreq,rightStepFreq];
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//
|
|
|
|
+////读取剑波sdk返回字符串数据
|
|
|
|
+//-(void)ocGetGameDataStr:(NSData*)characteristic{
|
|
|
|
+//
|
|
|
|
+//}
|
|
|
|
+
|
|
#pragma mark ===============================================>>副设备 报文数据解析后 -- 调用蓝牙鞋子SDK装换数据 -- ios call unity 更新游戏动作
|
|
#pragma mark ===============================================>>副设备 报文数据解析后 -- 调用蓝牙鞋子SDK装换数据 -- ios call unity 更新游戏动作
|
|
-(void)viceShoseSDKRight_pos:(int[3])right_pos
|
|
-(void)viceShoseSDKRight_pos:(int[3])right_pos
|
|
Right_att:(int[3])right_att
|
|
Right_att:(int[3])right_att
|
|
@@ -774,64 +777,64 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
girlShoes:(int)girlShoes
|
|
girlShoes:(int)girlShoes
|
|
right_press:(int)right_press
|
|
right_press:(int)right_press
|
|
left_press:(int)left_press{
|
|
left_press:(int)left_press{
|
|
-
|
|
|
|
- /********************初始化 运动轨迹算法 SDK *****************/
|
|
|
|
- [self.viceDeviceGame gameProcess:ts
|
|
|
|
- rightPos:right_pos
|
|
|
|
- rightAtt:right_att
|
|
|
|
- rightAcc:right_acc
|
|
|
|
- rightZupt:rightZupt
|
|
|
|
- right_press:right_press
|
|
|
|
- leftPos:left_pos
|
|
|
|
- leftAtt:left_att
|
|
|
|
- leftAcc:left_acc
|
|
|
|
- leftZupt:leftZupt
|
|
|
|
- left_press:left_press
|
|
|
|
- jump:jump
|
|
|
|
- down:down
|
|
|
|
- rssi:rssi
|
|
|
|
- girl_shoes:girlShoes];
|
|
|
|
- int length = 4;
|
|
|
|
- int result[length];
|
|
|
|
- [self.viceDeviceGame getGameResult:result];
|
|
|
|
-// NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
|
|
|
|
-
|
|
|
|
- /********************蓝牙sdk返回的鞋子 状态 步频 步数*****************/
|
|
|
|
- int leftStepStatus = [self.viceDeviceGame getStepStatus:LEFT_FOOT_OC];
|
|
|
|
- int leftStepFreq = [self.viceDeviceGame getStepFreq:LEFT_FOOT_OC];
|
|
|
|
-// int leftStepCount = [self.viceDeviceGame getStepCount:LEFT_FOOT_OC];
|
|
|
|
- int rightStepStatus = [self.viceDeviceGame getStepStatus:RIGHT_FOOT_OC];
|
|
|
|
- int rightStepFreq = [self.viceDeviceGame getStepFreq:RIGHT_FOOT_OC];
|
|
|
|
-// int rightStepCount = [self.viceDeviceGame getStepCount:RIGHT_FOOT_OC];
|
|
|
|
- //ios call unity
|
|
|
|
-// if (self.game_id == GAME_TYPE_RUN){//跑酷才需要回调
|
|
|
|
- [self.sdk bridgingStepAction:DEVICETYPE_VICE leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];//副设备左右脚速度 步频
|
|
|
|
|
|
+//
|
|
|
|
+// /********************初始化 运动轨迹算法 SDK *****************/
|
|
|
|
+// [self.viceDeviceGame gameProcess:ts
|
|
|
|
+// rightPos:right_pos
|
|
|
|
+// rightAtt:right_att
|
|
|
|
+// rightAcc:right_acc
|
|
|
|
+// rightZupt:rightZupt
|
|
|
|
+// right_press:right_press
|
|
|
|
+// leftPos:left_pos
|
|
|
|
+// leftAtt:left_att
|
|
|
|
+// leftAcc:left_acc
|
|
|
|
+// leftZupt:leftZupt
|
|
|
|
+// left_press:left_press
|
|
|
|
+// jump:jump
|
|
|
|
+// down:down
|
|
|
|
+// rssi:rssi
|
|
|
|
+// girl_shoes:girlShoes];
|
|
|
|
+// int length = 4;
|
|
|
|
+// int result[length];
|
|
|
|
+// [self.viceDeviceGame getGameResult:result];
|
|
|
|
+//// NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
|
|
|
|
+//
|
|
|
|
+// /********************蓝牙sdk返回的鞋子 状态 步频 步数*****************/
|
|
|
|
+// int leftStepStatus = [self.viceDeviceGame getStepStatus:LEFT_FOOT_OC];
|
|
|
|
+// int leftStepFreq = [self.viceDeviceGame getStepFreq:LEFT_FOOT_OC];
|
|
|
|
+//// int leftStepCount = [self.viceDeviceGame getStepCount:LEFT_FOOT_OC];
|
|
|
|
+// int rightStepStatus = [self.viceDeviceGame getStepStatus:RIGHT_FOOT_OC];
|
|
|
|
+// int rightStepFreq = [self.viceDeviceGame getStepFreq:RIGHT_FOOT_OC];
|
|
|
|
+//// int rightStepCount = [self.viceDeviceGame getStepCount:RIGHT_FOOT_OC];
|
|
|
|
+// //ios call unity
|
|
|
|
+//// if (self.game_id == GAME_TYPE_RUN){//跑酷才需要回调
|
|
|
|
+// [self.sdk bridgingStepAction:DEVICETYPE_VICE leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];//副设备左右脚速度 步频
|
|
|
|
+//// }
|
|
|
|
+//
|
|
|
|
+// /********************蓝牙sdk返回的鞋子 动作*****************/
|
|
|
|
+// int motionLeft = result[0];//左脚的动作
|
|
|
|
+// int motionRight = result[1];//右脚的动作
|
|
|
|
+// int ivce_motionJump = result[2];//jump
|
|
|
|
+// int ivce_motionDown = result[3];//down
|
|
|
|
+// if (motionLeft==-1 && motionRight == -1&& ivce_motionJump == -1&& ivce_motionDown == -1){//无效动作
|
|
|
|
+// return;
|
|
|
|
+// }else{
|
|
|
|
+// //跳跃和蹲下的动作 双脚是同步的
|
|
|
|
+// if (ivce_motionJump == MOTION_JUMP){
|
|
|
|
+// motionLeft = ivce_motionJump;
|
|
|
|
+// motionRight = ivce_motionJump;
|
|
|
|
+// NSLog(@"副设备 ======================================== 跳起来 jump_count = %d ",self.jump_count);
|
|
|
|
+// }
|
|
|
|
+// if (ivce_motionDown == MOTION_DOWN){
|
|
|
|
+// motionLeft = ivce_motionDown;
|
|
|
|
+// motionRight = ivce_motionDown;
|
|
|
|
+// NSLog(@"副设备 ========================================= 蹲下去 crouch_count = %d ",self.crouch_count);
|
|
|
|
+// }
|
|
|
|
+// //ios call unity as相互NX你·
|
|
|
|
+// [self.sdk bridgingMotionAction:DEVICETYPE_VICE left:motionLeft right:motionRight];//副设备左右脚动作
|
|
|
|
+//
|
|
// }
|
|
// }
|
|
-
|
|
|
|
- /********************蓝牙sdk返回的鞋子 动作*****************/
|
|
|
|
- int motionLeft = result[0];//左脚的动作
|
|
|
|
- int motionRight = result[1];//右脚的动作
|
|
|
|
- int ivce_motionJump = result[2];//jump
|
|
|
|
- int ivce_motionDown = result[3];//down
|
|
|
|
- if (motionLeft==-1 && motionRight == -1&& ivce_motionJump == -1&& ivce_motionDown == -1){//无效动作
|
|
|
|
- return;
|
|
|
|
- }else{
|
|
|
|
- //跳跃和蹲下的动作 双脚是同步的
|
|
|
|
- if (ivce_motionJump == MOTION_JUMP){
|
|
|
|
- motionLeft = ivce_motionJump;
|
|
|
|
- motionRight = ivce_motionJump;
|
|
|
|
- NSLog(@"副设备 ======================================== 跳起来 jump_count = %d ",self.jump_count);
|
|
|
|
- }
|
|
|
|
- if (ivce_motionDown == MOTION_DOWN){
|
|
|
|
- motionLeft = ivce_motionDown;
|
|
|
|
- motionRight = ivce_motionDown;
|
|
|
|
- NSLog(@"副设备 ========================================= 蹲下去 crouch_count = %d ",self.crouch_count);
|
|
|
|
- }
|
|
|
|
- //ios call unity as相互NX你·
|
|
|
|
- [self.sdk bridgingMotionAction:DEVICETYPE_VICE left:motionLeft right:motionRight];//副设备左右脚动作
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+//
|
|
}
|
|
}
|
|
|
|
|
|
#pragma mark ===============================================>> 蓝牙发送各类数据
|
|
#pragma mark ===============================================>> 蓝牙发送各类数据
|
|
@@ -1023,28 +1026,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
}
|
|
}
|
|
|
|
|
|
#pragma mark ===============================================>> 存储和上传数据
|
|
#pragma mark ===============================================>> 存储和上传数据
|
|
-//读取剑波sdk返回字符串数据
|
|
|
|
--(void)ocGetGameDataStr:(NSData*)characteristic{
|
|
|
|
-
|
|
|
|
- //剑波数据测试组
|
|
|
|
- NSData * validData= [characteristic subdataWithRange:NSMakeRange(4, characteristic.length-4)];
|
|
|
|
- Byte * buff = (Byte*)[validData bytes];
|
|
|
|
- [self.game GameProcessBuf:buff length:(int)validData.length];
|
|
|
|
-// self.tempStepString = [self.game getGameDataStr];
|
|
|
|
- self.tempStepString = [NSString stringWithFormat:@"%@\n",[self.game getGameDataStr]];
|
|
|
|
-
|
|
|
|
-// if (self.dataString.length<2){
|
|
|
|
-// self.dataString = [self.game getGameDataStr];
|
|
|
|
-// }else{
|
|
|
|
-// self.dataString = [NSString stringWithFormat:@"%@\n%@",self.dataString,[self.game getGameDataStr]];
|
|
|
|
-// }
|
|
|
|
-// NSLog(@"剑波需要的 ===================>> %@",self.dataString);
|
|
|
|
-
|
|
|
|
- if (self.tempStepString!=nil && self.tempStepString.length>1){
|
|
|
|
- [self writeFileToplist];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-}
|
|
|
|
|
|
|
|
- (void)clearCacheWithFilePath{
|
|
- (void)clearCacheWithFilePath{
|
|
|
|
|