如题,有大虾做过相关应用吗? 话说网上都说gamekit只支持iphone,ipod touch,ipad间通讯; 目前又一个信息采集器,想通过蓝牙把采集到的信号传送到iphone去,不知道是否可行。 iBluetooth这个应用,据说是不使用苹果的SDK,直接使用底层(FreeBSD?)去进行蓝牙通讯,有没有人有所了解? 希望能指点一二。 |
|
90分 |
gamekit如你所说,只支持apple的
如果要第三方,那只能使用底层的 |
// // BluetoothSampleAppDelegate.h // BluetoothSample // #import "EAGLView.h" #import <GameKit/GameKit.h> @interface BluetoothSampleAppDelegate : NSObject { UIWindow *window; EAGLView *glView; GKPeerPickerController *picker; GKSession *session; int myNumber; NSData *myData; UILabel *textView; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet EAGLView *glView; @property (nonatomic, retain) GKPeerPickerController *picker; @property (nonatomic, retain) GKSession *session; - (void)mySendData; @end |
|
// // BluetoothSampleAppDelegate.m // BluetoothSample // #import "BluetoothSampleAppDelegate.h" @implementation BluetoothSampleAppDelegate @synthesize picker; @synthesize session; @synthesize window; @synthesize glView; - (void)applicationDidFinishLaunching:(UIApplication *)application { // setup the text view myNumber = 0; textView = [[UILabel alloc] initWithFrame:CGRectMake(10.0f, 10.0f, 640.0f, 12.0f)]; textView.text = [NSString stringWithFormat:@"myNumber: %i\n", myNumber]; [window addSubview:textView]; [window bringSubviewToFront:textView]; // start the EAGLView glView.animationInterval = 1.0 / 60.0; [glView startAnimation]; // allocate the NSData myData = [[NSData alloc] initWithBytes:&myNumber length:sizeof(int)]; // allocate and setup the peer picker controller picker = [[GKPeerPickerController alloc] init]; picker.delegate = self; picker.connectionTypesMask = GKPeerPickerConnectionTypeNearby | GKPeerPickerConnectionTypeOnline; [picker show]; } - (void)applicationWillResignActive:(UIApplication *)application { glView.animationInterval = 1.0 / 5.0; } - (void)applicationDidBecomeActive:(UIApplication *)application { glView.animationInterval = 1.0 / 60.0; } - (void)peerPickerController:(GKPeerPickerController *)picker didSelectConnectionType:(GKPeerPickerConnectionType)type { if(type == GKPeerPickerConnectionTypeOnline) { [self.picker dismiss]; [self.picker release]; self.picker = nil; // Display your own UI here. } } - (GKSession *) peerPickerController:(GKPeerPickerController *)picker sessionForConnectionType:(GKPeerPickerConnectionType)type { session = [[GKSession alloc] initWithSessionID:@"FR" displayName:nil sessionMode:GKSessionModePeer]; session.delegate = self; return session; } - (void)session:(GKSession *)session peer:(NSString *)peerID didChangeState:(GKPeerConnectionState)state { switch (state) { case GKPeerStateConnected: [self.session setDataReceiveHandler :self withContext:nil]; [self mySendData]; // start off by sending data upon connection break; case GKPeerStateDisconnected: break; } } - (void)peerPickerController:(GKPeerPickerController *)picker didConnectToPeer:(NSString *)peerID { printf("connection was successful! start the game.\n"); } - (void)peerPickerControllerDidCancel:(GKPeerPickerController *)picker { printf("connection attempt was canceled\n"); } - (void)mySendData { // allocate the NSData myNumber++; myData = [[NSData alloc] initWithBytes:&myNumber length:sizeof(int)]; [session sendDataToAllPeers :myData withDataMode:GKSendDataReliable error:nil]; printf("send data: %i\n", myNumber); textView.text = [NSString stringWithFormat:@"myNumber: %i\n", myNumber]; } - (void) receiveData:(NSData *)data fromPeer:(NSString *)peer inSession: (GKSession *)session context:(void *)context { // Read the bytes in data and perform an application-specific action, then free the NSData object [data getBytes:&myNumber length:sizeof(int)]; printf("received data: %i from: %s\n", myNumber, [peer UTF8String]); textView.text = [NSString stringWithFormat:@"myNumber: %i\n", myNumber]; [self mySendData]; } - (void)dealloc { [picker release]; [session release]; [textView release]; [glView release]; [window release]; [super dealloc]; } @end 附上GameKit范例代码 |
|
有没有人在mac os x 10.6.7或8,MacOSX10.6.sdk环境下编译通过toolchain? 下载了一个代码,编译了一把,编译不通过: In file included from ../../../odcctools/include/libkern/OSByteOrder.h:70, 按照网上的修改: export INCPRIVEXT=”-isysroot /Developer/SDKs/MacOSX10.6.sdk” 再编译,错误依然。。。。。。 |
|
10分 |
ls说了,不支持,而且就算你底层的做了你也基本会碰到两种可能。要么就是没权限访问,要么就是app被拒。至少具体底层使用什么api倒不是很清楚,我只知道android用的是bluez。
至于你上面的那个编译问题就不得而知,应该是配置上的问题 |