[iPhone] Bluetooth Multiplayer

Previous topic - Next topic

Crivens

#30
Finally got round to testing! Ok I must be doing something wrong. I took the .mm and .h files out of your zip file and put them in the classes directory (assume this from iAds thread) on XCode. I then completely removed the .a file from XCode and any reference to it. GLB code stayed the same but when I hit compile I get these errors (see attached image).

Obviously I'm doing something wrong here, but with my extremely limited knowledge of XCode (getting the .a to work in the first place was about the limit of what I know at the minute) I don't know where to go from here.

Cheers

Ps. What is even weirder is that I removed the bluetooth code from GLB but it still errored in XCode with references to the Bluetooth functions. Turns out that the libs I normally scp over (/XCode/GLBasic/Lib) are not being updated (specifically libPROGRAM.a). Infact libPROGRAM.a is now being updated in /XCode/Lib. Copy that manually over and it works again. Has the path changed then or something? Is the XCode/GLBasic directory now not needed, and everything is just in XCode?

[attachment deleted by admin]
Current fave quote: Cause you like musicians and I like people with boobs.

Moebius

QuoteIs the XCode/GLBasic directory now not needed, and everything is just in XCode?
That seems to be exactly what has happened.  I remember someone posting that the extra subfolder wasn't really necessary.
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

trucidare

#import <GameKit/GameKit.h>
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Crivens

Ok I sorted out all my folders and the like. Hmm, that's weird. My XCode project doesn't allow me anymore to add the existing ibluetooth.h file into the classes folder (like I have done for iAds with the AppViewController.h file), only the .mm file.... hmm, that will be a problem right? Also with the #import line you posted where does that go exactly? Is it in the .h file or the .mm file?

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

trucidare

right under Foundation/Foundation.h

if xcode strikes to add the file - the file exists in project folder. delete it or add it and uncheck the copy button.
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

matchy


trucidare

MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Leginus


Moebius

I couldn't compile the iBT code - I had to remove the "self"s from in front of iGotRecvData and connectState.  It seems to be working now though - with the exception of the "EXC_BAD_ACCESS" problem - although it takes a bit of time of constant messaging between the devices to invoke this...
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

Moebius

Now that we have the source code, the debugger highlights:
strcpy(gStrRev, [strTemp UTF8String]);

...in this block of code for the internal receive function:

Code (glbasic) Select
// GF: use global string buffer
char gStrRev[2048];
const char* GLB_iBT_Recv() {
NSString* strTemp = [myBluetooth _GLB_iBT_Recv];

gStrRev[0]='\0';
strcpy(gStrRev, [strTemp UTF8String]);
prevPost = strTemp;
return gStrRev;
}


when there is the memory access problem.

Specifically, it says that 'strTemp' is an invalid CFStringRef when I hover over it...
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

matchy

#40
The connection call pulses are controlled by the iOS and during debugging the connections are slow but usually, with the devices alone, connect quickly.

There were a couple of typos as mentioned although no big deal. The only time I got EXC_BAD_ACCESS is when trying to send data when not connected or something like that.

Although now it works fine and here is a non-tested GLB code sample of what I have so far:
Code (glbasic) Select


TYPE _data
connected
connected_last
data_recv$
data_send$
session_id$
peer_id$
self_id$
master
toggle
time
ENDTYPE

GLOBAL tooth AS _data

bluetooth_main()

FUNCTION bluetooth_main:
LOCAL time$

tooth.session_id$ = "01"
GLB_iBT_Init()
GLB_iBT_Start(tooth.session_id$)
tooth.connected = GLB_iBT_Connected()
WHILE NOT tooth.connected
PRINT "Connecting", 1, 1
SHOWSCREEN
tooth.connected = GLB_iBT_Connected()
WEND
tooth.peer_id$ = GLB_iBT_PeerID()
tooth.data_send$ = "PEERID:" + tooth.peer_id$
GLB_iBT_Send(tooth.data_send$)
time$ = MID$(PLATFORMINFO$("TIME"),11,8)
WHILE tooth.connected
tooth.data_recv$ = GLB_iBT_Recv()
tooth.data_send$ = "TIME:" + time$
GLB_iBT_Send(tooth.data_send$)
recv_data()
PRINT "LOCAL TIME:" + time$, 1, 1
PRINT "REMOTE TIME:" + tooth.time$, 1, 20
SHOWSCREEN
WEND
GLB_iBT_Close()
ENDFUNCTION

FUNCTION recv_data:
LOCAL match$

tooth.connected = GLB_iBT_Connected()
IF tooth.connected
tooth.data_recv$ = GLB_iBT_Recv()
IF tooth.data_recv$ <> "NO_DATA"
match$ = left_match$(tooth.data_recv$, "PEERID:")
IF match$ <> ""
tooth.self_id$ = match$
IF tooth.self_id$ < tooth.peer_id$
tooth.master = MASTER_LOCAL
ELSE
tooth.master = MASTER_REMOTE
ENDIF
ENDIF
match$ = left_match$(tooth.data_recv$, "TIME:")
IF match$ <> ""
tooth.time$ = time$
ENDIF
ENDIF
tooth.data_recv$ = "NO_DATA"
ENDIF
ENDFUNCTION

FUNCTION left_match$: word_data$, match$
LOCAL length1 = LEN(word_data$)
LOCAL length2 = LEN(match$)
LOCAL result$

IF LEFT$(word_data$, length2) = match$
result$ = RIGHT$(word_data$, length1 - length2)
ELSE
result$ = ""
ENDIF
RETURN result$
ENDFUNCTION


Moebius

Do you really have no problems at all?  It's strange - even running your code I have the same problem with the same line...
We can't tell who's the odd-one-out unless others test as well...  Anyway I've only updated the two devices I'm using to 4.0 and 4.1 - what are yours using?  There must be some reason why we have different results...
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

matchy

I've updated my sig with spec for my devices.

Maybe it could be an issue with version but you should really post you code also.

Moebius

I'll post the version of the iBluetooth code I'm using soon - I don't really have time ATM.  I'll see if updating to a later OS version makes a difference as well - I've been meaning to update for a while...
Endless Loop: n., see Loop, Endless.
Loop, Endless: n., see Endless Loop.
- Random Shack Data Processing Dictionary

michael

i'm missing the declaration of the GLB_iBT_PeerID() in the .h or .mm file, can someone post the code with this declartion,
Thanks