Wednesday, December 25, 2013

iPhone SDK supports Bluetooth development associated with non-Apple devices iPhone Bluetooth communication?


As stated, there are prawns related applications done it?

Talk online say gamekit only supports iphone, ipod touch, ipad communication between;

Currently has an information collector, wanted to put the collected via Bluetooth signal to the iphone go, I do not know if it works.

iBluetooth this application, is said not to use Apple's SDK, the direct use of the underlying (FreeBSD?) to Bluetooth communication, does anyone understand?

Hoping pointing 12.
Reply:
gamekit as you said, only supports apple's
If you want a third party, it can only use the underlying
Reply:
 / / 
/ / BluetoothSampleAppDelegate.h
/ / BluetoothSample
/ /

# Import "EAGLView.h"
# Import

@ 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

Reply:
 
/ /
/ / 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

Attach sample code GameKit
Reply:

Has anyone in mac os x 10.6.7 or 8, under MacOSX10.6.sdk environment compile toolchain?

Download the code, compile a compiler does not pass:

In file included from .. / / / odcctools / include / libkern / OSByteOrder.h:.... 70,
from .. / / / odcctools / include / mach / ndr.h:.... 94,
.... from .. / / / odcctools / include / mach / clock_priv.h: 7,
.... from .. / / / odcctools / include / mach / mach_interface.h: 37,
from .. / / / odcctools / include / mach / mach.h:.... 62,
.... from .. / / / odcctools / libstuff / execute.c: 25:
.. / / / Odcctools / include / libkern / machine / OSByteOrder.h:.... 45: error: redefinition of
'_OSSwapInt16'
/ Usr/include/libkern/i386/_OSByteOrder.h: 49: error: previous definition of '_OSSwapInt16' was
here
.. / / / Odcctools / include / libkern / machine / OSByteOrder.h:.... 54: error: redefinition of
'_OSSwapInt32'
/ Usr/include/libkern/i386/_OSByteOrder.h: 58: error: previous definition of '_OSSwapInt32' was
here
...... / / / Odcctools / include / libkern / machine / OSByteOrder.h: 63: error: redefinition of
'_OSSwapInt64'
/ Usr/include/libkern/i386/_OSByteOrder.h: 69: error: previous definition of '_OSSwapInt64' was
here
make [1]: *** [execute.o] Error 1
make: *** [libstuff] Error 2


Modified in accordance with the Internet:

export INCPRIVEXT = "-isysroot / Developer/SDKs/MacOSX10.6.sdk"

Then compile error still. . . . . .
Reply:
ls to say, does not support, and even if you do the bottom you will encounter are basically two possibilities. Access to or is not, or is app rejected. What specific underlying api at least it's not very clear, I only know android using bluez.
As you compile the above that the problem is not known, it should be configured on the issue

No comments:

Post a Comment