|
@@ -9,20 +9,22 @@
|
|
#import "BTDataProcess.h"
|
|
#import "BTDataProcess.h"
|
|
#import "IOSPlatformSDK.h"
|
|
#import "IOSPlatformSDK.h"
|
|
#include "Game.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])
|
|
|
|
-@interface BTDataProcess ()<NSURLSessionDataDelegate>
|
|
|
|
|
|
+#import "MainShoesAnalysis.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])
|
|
|
|
+@interface BTDataProcess ()<NSURLSessionDataDelegate>
|
|
{
|
|
{
|
|
@private
|
|
@private
|
|
- Game *game;
|
|
|
|
|
|
+Game *game;
|
|
|
|
+Game *viceDeviceGame;
|
|
}
|
|
}
|
|
|
|
|
|
@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 * game ;//主设备蓝牙算法sdk
|
|
-
|
|
|
|
//@property (nonatomic,strong)GameObjc * viceDeviceGame ;//副设备设备蓝牙算法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;//是否开启游戏模式
|
|
|
|
|
|
@@ -35,9 +37,11 @@
|
|
@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 * tempStepString;//缓存plist
|
|
|
|
|
|
+@property (nonatomic,strong)NSString * tempStepString;//剑波要的字符串数据 缓存plist
|
|
@property(nonatomic,assign) NSNumber *RSSI;//威严要的测试数据
|
|
@property(nonatomic,assign) NSNumber *RSSI;//威严要的测试数据
|
|
|
|
+//@property(nonatomic,weak)NSTimer * rssiTimer;//记录每秒的rssi峰值
|
|
|
|
+//@property(nonatomic,assign) NSNumber * currentPeakRSSI;//龙哥要的测试数据
|
|
|
|
+
|
|
/*****测试*******/
|
|
/*****测试*******/
|
|
|
|
|
|
@end
|
|
@end
|
|
@@ -111,14 +115,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
-(void)applicationWillEnterForeground{
|
|
-(void)applicationWillEnterForeground{
|
|
|
|
|
|
NSLog(@"BTDataProcess 收到程序从后台返回 peripheral.state = %ld",LEManager.peripheral.state);
|
|
NSLog(@"BTDataProcess 收到程序从后台返回 peripheral.state = %ld",LEManager.peripheral.state);
|
|
-// if (LEManager.peripheral!=nil&&LEManager.peripheral.state!= CBPeripheralStateConnected){//蓝牙不为空 且蓝牙断开链接(有三种情况)
|
|
|
|
-// [self connectPeripheral:LEManager.peripheral];//蓝牙重链接
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// if (LEManager.vicePeripheral!=nil&&LEManager.vicePeripheral.state != CBPeripheralStateConnected){//蓝牙不为空 且蓝牙断开链接
|
|
|
|
-// [self connectPeripheral:LEManager.vicePeripheral];//蓝牙重链接
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
[self initCBCentralManager];
|
|
[self initCBCentralManager];
|
|
|
|
|
|
}
|
|
}
|
|
@@ -319,9 +315,11 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
if (self.deviceType==DEVICETYPE_MAIN){
|
|
if (self.deviceType==DEVICETYPE_MAIN){
|
|
LEManager.peripheral = peripheral;
|
|
LEManager.peripheral = peripheral;
|
|
game = new Game(self.game_id);
|
|
game = new Game(self.game_id);
|
|
|
|
+// MainShoesAnalysis * instance = [MainShoesAnalysis sharedInstance];
|
|
|
|
+// instance->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];
|
|
|
|
|
|
+// viceDeviceGame = [[GameObjc alloc] initWithGametype:self.game_id];
|
|
}
|
|
}
|
|
|
|
|
|
//根据ios_sdk传入deviceType 链接 主/副 设备
|
|
//根据ios_sdk传入deviceType 链接 主/副 设备
|
|
@@ -395,10 +393,10 @@ 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){
|
|
};
|
|
};
|
|
|
|
|
|
- //
|
|
|
|
|
|
+ //蓝牙更新RSSI
|
|
LEManager.rssiBlock = ^(NSNumber * _Nonnull RSSI){
|
|
LEManager.rssiBlock = ^(NSNumber * _Nonnull RSSI){
|
|
self.RSSI = RSSI;
|
|
self.RSSI = RSSI;
|
|
-// NSLog(@"self.RSSI = %@",self.RSSI );
|
|
|
|
|
|
+// NSLog(@"self.RSSI = %@",self.RSSI);
|
|
};
|
|
};
|
|
|
|
|
|
//蓝牙连接成功
|
|
//蓝牙连接成功
|
|
@@ -410,9 +408,6 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
//蓝牙连接失败
|
|
//蓝牙连接失败
|
|
LEManager.connectFailureBlock = ^(NSError * _Nonnull error){
|
|
LEManager.connectFailureBlock = ^(NSError * _Nonnull error){
|
|
NSLog(@"蓝牙链接失败");
|
|
NSLog(@"蓝牙链接失败");
|
|
-// if (peripheral == LEManager.peripheral){
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
};
|
|
};
|
|
|
|
|
|
//蓝牙连接丢失
|
|
//蓝牙连接丢失
|
|
@@ -432,6 +427,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
electricity:0];
|
|
electricity:0];
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
if (LEManager.vicePeripheral!=nil){
|
|
if (LEManager.vicePeripheral!=nil){
|
|
|
|
|
|
[self.sdk bridgingDeviceAction:DEVICETYPE_VICE
|
|
[self.sdk bridgingDeviceAction:DEVICETYPE_VICE
|
|
@@ -451,9 +447,8 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
//初始化缓存动作数据
|
|
//初始化缓存动作数据
|
|
if (deviceType==DEVICETYPE_MAIN){
|
|
if (deviceType==DEVICETYPE_MAIN){
|
|
|
|
|
|
- self.jump_count = 0;
|
|
|
|
- self.crouch_count = 0;
|
|
|
|
- self.step_count = 0;
|
|
|
|
|
|
+ self.initial_down_count = 0;
|
|
|
|
+ self.initial_jump_count = 0;
|
|
|
|
|
|
//读写到特征后 添加测试弹窗
|
|
//读写到特征后 添加测试弹窗
|
|
[self inittestLabel];
|
|
[self inittestLabel];
|
|
@@ -467,11 +462,11 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
[self timingDataTransmission:@"dispatch_after"];
|
|
[self timingDataTransmission:@"dispatch_after"];
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ //定时开启游戏模式 & 查询设备信息 & 开启激光检测下蹲
|
|
if (self.timer!=nil){
|
|
if (self.timer!=nil){
|
|
[self.timer invalidate];
|
|
[self.timer invalidate];
|
|
self.timer = nil;
|
|
self.timer = nil;
|
|
}
|
|
}
|
|
- //定时开启游戏模式 & 查询设备信息 & 开启激光检测下蹲
|
|
|
|
self.timer = [NSTimer scheduledTimerWithTimeInterval:15 target:self selector:@selector(timingDataTransmission:) userInfo:nil repeats:YES];
|
|
self.timer = [NSTimer scheduledTimerWithTimeInterval:15 target:self selector:@selector(timingDataTransmission:) userInfo:nil repeats:YES];
|
|
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSDefaultRunLoopMode];
|
|
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSDefaultRunLoopMode];
|
|
|
|
|
|
@@ -492,6 +487,8 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
#pragma mark ===============================================>> 校验 & 报文数据解析
|
|
#pragma mark ===============================================>> 校验 & 报文数据解析
|
|
-(void)verifyData:(CBCharacteristic*)characteristic deviceType:(DEVICE_TYPE)deviceType{
|
|
-(void)verifyData:(CBCharacteristic*)characteristic deviceType:(DEVICE_TYPE)deviceType{
|
|
|
|
|
|
@@ -600,8 +597,8 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
}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 characteristic:characteristic];
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -683,14 +680,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
int result[length];
|
|
int result[length];
|
|
game->getGameResult(result);
|
|
game->getGameResult(result);
|
|
// NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
|
|
// NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
|
|
-
|
|
|
|
- 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 leftStepStatus = game->getStepStatus(LEFT_FOOT);
|
|
@@ -700,7 +690,7 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
int rightStepFreq = game->getStepFreq(RIGHT_FOOT);
|
|
int rightStepFreq = game->getStepFreq(RIGHT_FOOT);
|
|
int rightStepCount = game->getStepCount(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
|
|
@@ -712,44 +702,67 @@ void disConnectBle (CFNotificationCenterRef center, void *observer, CFStringRef
|
|
if (motionJump == MOTION_JUMP){
|
|
if (motionJump == MOTION_JUMP){
|
|
motionLeft = motionJump;
|
|
motionLeft = motionJump;
|
|
motionRight = motionJump;
|
|
motionRight = motionJump;
|
|
- self.jump_count++;
|
|
|
|
NSLog(@" 主设备 ================================== 跳起来 ");
|
|
NSLog(@" 主设备 ================================== 跳起来 ");
|
|
}
|
|
}
|
|
|
|
+
|
|
if (motionDown == MOTION_DOWN){
|
|
if (motionDown == MOTION_DOWN){
|
|
motionLeft = motionDown;
|
|
motionLeft = motionDown;
|
|
motionRight = motionDown;
|
|
motionRight = motionDown;
|
|
- self.crouch_count++;
|
|
|
|
NSLog(@" 主设备 =================================== 蹲下去 ");
|
|
NSLog(@" 主设备 =================================== 蹲下去 ");
|
|
}
|
|
}
|
|
// }
|
|
// }
|
|
|
|
+
|
|
|
|
+ /****************** ios call unity*****************/
|
|
|
|
+ if (self.gameModel==YES){//当前是游戏模式
|
|
|
|
|
|
- //数据回调缓存
|
|
|
|
- if (self.allMotionCountBLock){
|
|
|
|
- self.step_count = leftStepCount+rightStepCount;
|
|
|
|
- self.allMotionCountBLock(self.jump_count, self.crouch_count, leftStepCount+rightStepCount);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-// 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];
|
|
}
|
|
}
|
|
- [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];
|
|
|
|
-//// NSLog(@"主设备 当前的脚步交互动作 ===== >> %d",interaction);
|
|
|
|
-// [self.sdk bridgingInteraction:DEVICETYPE_MAIN code:interaction];
|
|
|
|
-// if (self.getInteractionBlock){
|
|
|
|
-// self.getInteractionBlock(interaction);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
|
|
+ int interaction = game->getInteractionCMD();
|
|
|
|
+// NSLog(@"主设备 当前的脚步交互动作 ===== >> %d",interaction);
|
|
|
|
+ [self.sdk bridgingInteraction:DEVICETYPE_MAIN code:interaction];
|
|
|
|
+ if (self.getInteractionBlock){
|
|
|
|
+ self.getInteractionBlock(interaction);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /******************数据回调缓存*****************/
|
|
|
|
+ //标记初始值
|
|
|
|
+ if (self.initial_jump_count==0){
|
|
|
|
+ self.initial_jump_count = game->getGameJumpCount();
|
|
|
|
+ }
|
|
|
|
+ if (self.initial_down_count==0) {
|
|
|
|
+ self.initial_down_count = game->getGameDownCount();
|
|
|
|
+ }
|
|
|
|
+ //总数
|
|
|
|
+ int total_jump_count = game->getGameJumpCount();
|
|
|
|
+ int total_dump_count = game->getGameDownCount();
|
|
|
|
+ //当局游戏次数
|
|
|
|
+ int current_jump_count = total_jump_count - self.initial_jump_count;
|
|
|
|
+ int current_dump_count = total_dump_count - self.initial_down_count;
|
|
|
|
+ //数据回调缓存
|
|
|
|
+ if (self.allMotionCountBLock){
|
|
|
|
+ self.allMotionCountBLock(current_jump_count, current_dump_count, leftStepCount + rightStepCount);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ /********************剑波要的图表数据 *****************/
|
|
|
|
+ NSString * aString = [NSString stringWithUTF8String:game->getGameDataStr().c_str()];
|
|
|
|
+ if (self.RSSI==nil){
|
|
|
|
+ self.RSSI = 0;
|
|
|
|
+ }
|
|
|
|
+ aString = [NSString stringWithFormat:@"%@,%@",aString,self.RSSI];
|
|
|
|
+ self.tempStepString = [NSString stringWithFormat:@"%@\n",aString];
|
|
|
|
+ if (self.tempStepString!=nil && self.tempStepString.length>1){
|
|
|
|
+ [self writeFileToplist];
|
|
|
|
+ }
|
|
|
|
|
|
- //
|
|
|
|
|
|
+ /********************调试窗数据 *****************/
|
|
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,self.RSSI,ts,aArray[aArray.count-2],aArray.lastObject,leftStepFreq,rightStepFreq];
|
|
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];
|
|
|
|
|
|
@@ -776,65 +789,60 @@ 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{
|
|
|
|
-//
|
|
|
|
-// /********************初始化 运动轨迹算法 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
|
|
|
|
|
|
+ left_press:(int)left_press
|
|
|
|
+ characteristic:(NSData*)characteristic{
|
|
|
|
+
|
|
|
|
+ /********************初始化 运动轨迹算法 SDK *****************/
|
|
|
|
+ //游戏数据
|
|
|
|
+ NSData * validData= [characteristic subdataWithRange:NSMakeRange(4, characteristic.length-4)];
|
|
|
|
+ Byte * buff = (Byte*)[validData bytes];
|
|
|
|
+ viceDeviceGame->GameProcessBuf(buff, (int)validData.length);
|
|
|
|
+
|
|
|
|
+ int length = 4;
|
|
|
|
+ int result[length];
|
|
|
|
+ viceDeviceGame->getGameResult(result);
|
|
|
|
+ // NSLog(@"result == %d %d %d %d \n",result[0],result[1],result[2],result[3]);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /********************蓝牙sdk返回的鞋子 状态 步频 步数*****************/
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /********************蓝牙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){//无效动作
|
|
// if (motionLeft==-1 && motionRight == -1&& ivce_motionJump == -1&& ivce_motionDown == -1){//无效动作
|
|
// return;
|
|
// return;
|
|
// }else{
|
|
// }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];//副设备左右脚动作
|
|
|
|
-//
|
|
|
|
|
|
+ //跳跃和蹲下的动作 双脚是同步的
|
|
|
|
+ if (ivce_motionJump == MOTION_JUMP){
|
|
|
|
+ motionLeft = ivce_motionJump;
|
|
|
|
+ motionRight = ivce_motionJump;
|
|
|
|
+ NSLog(@"副设备 ======================================== 跳起来");
|
|
|
|
+ }
|
|
|
|
+ if (ivce_motionDown == MOTION_DOWN){
|
|
|
|
+ motionLeft = ivce_motionDown;
|
|
|
|
+ motionRight = ivce_motionDown;
|
|
|
|
+ NSLog(@"副设备 ========================================= 蹲下去");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //ios call unity
|
|
|
|
+ if (self.game_id == GAME_TYPE_RUN){//跑酷才需要回调
|
|
|
|
+ [self.sdk bridgingStepAction:DEVICETYPE_VICE leftStatus:leftStepStatus rightStatus:rightStepStatus leftFrag:leftStepFreq rightFrag:rightStepFreq];//副设备左右脚速度 步频
|
|
|
|
+ }
|
|
|
|
+ //ios call unity as相互NX你·
|
|
|
|
+ [self.sdk bridgingMotionAction:DEVICETYPE_VICE left:motionLeft right:motionRight];//副设备左右脚动作
|
|
|
|
+
|
|
// }
|
|
// }
|
|
-//
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
#pragma mark ===============================================>> 蓝牙发送各类数据
|
|
#pragma mark ===============================================>> 蓝牙发送各类数据
|