I'm new to the entire IOKit stuff, so there might be some trivial solutions for my problems. I'm playing around with a Smartpen that does OBEX over USB. So far I got a subclass of OBEXSession
to Successfully connect to the Device.
OBEXAddTargetHeader("LivescribeService",
strlen("LivescribeService"),
header);
CFMutableDataRef headerData = OBEXHeadersToBytes(header);
OBEXError error = [session OBEXConnect:kOBEXConnectFlagNone
maxPacketLength:maxPacketLength
optionalHeaders:(void *)CFDataGetBytePtr(headerData)
optionalHeadersLength:CFDataGetLength(headerData)
eventSelector:@selector(openedConnection)
selectorTarget:target
refCon:NULL];
After that error
is 0 and the openedConnection message is sent to the target. The data that gets written and read to/from my USB pipe looks ok. Now I'd like to send a GET, but that somehow fails.
UInt32 connectionIDInt = 0x1;
const char *connectionID[4] = {0x0,0x0,0x0,0x0};
memcpy(connectionID, &connectionIDInt, 4);
OBEXAddConnectionIDHeader(connectionID, 4, header);
OBEXAddNameHeader(CFSTR("ppdata?key=pp0000"), header);
headerData = OBEXHeadersToBytes(header);
error = [session OBEXGet:YES
headers:(void *)CFDataGetBytePtr(headerData)
headersLength:CFDataGetLength(headerData)
eventSelector:@selector(OBEXGetHandler:)
selectorTarget:target
refCon:nil];
But that always results in a kOBEXBadArgumentError
and I have absolutely no idea what I'm doing wrong. I tried to play around with different headers, it's always the same, and as far as I know, this should be the correct header. Or what other argument could probably be wrong?
Might this have something to do with the maxPacketLength
I used for connecting? I used 1024 because I had no idea what to use. I tried to call -getMaxPacketLength but that returns just 0. Do I have to override that method? Or how do I have to deal with that packet length?