site_archiver@lists.apple.com Delivered-To: bluetooth-dev@lists.apple.com User-agent: Microsoft-Entourage/11.0.0.040405
Hey List,
I'm stuck and dumbstruck on what seems like it should be a fairly simple code chunk.
I'm making an app that sits waiting for a file transfer from another device, like a cellphone, and can handle the 'OBEX Command Connect' request, fire up a session, get the file and then use it with itself.
At the moment my code moves as such:
+ registerForChannelOpenNotification on all channels (though i'm really hoping for ch10) + upon open channel i set my class as delegate of the passed channel + when I get my rfcommChannelData call, check to see if it's an OBEX Command Connect a la 0x80 and instantiate an IOBluetoothOBEXSession withIncomingRFCOMMChannel.
After that i'm stuck. I've got the packetLogger open so I know what sequence of happenings i'd like to emulate, and I'm wondering if anyone had any hints on where to go from here. I've got some clues... OBEXConnectResponse in the OBEXSession.h and working out the whole structure on my own, but i'd love some help if y'alls willing.
thanks in advance... mark.
You are really close - now you just need to parse the event and send back the proper command response, something like below. You should parse the headers use OBEXGetHeaders() to make sure they are valid before responding success. Let me know if you need more help. jason -(void)sessionEventDispatch:(const OBEXSessionEvent *)inEvent { switch( inEvent->type ) { case( kOBEXSessionEventTypeConnectCommandReceived ): { [self handleConnectCommand:inEvent]; break; } case( kOBEXSessionEventTypeDisconnectCommandReceived ): { [self handleDisconnectCommand:inEvent]; break; } case( kOBEXSessionEventTypePutCommandReceived ): { // They are giving us a file, probably in multiple chunks. Pass it on. break; } case( kOBEXSessionEventTypeGetCommandReceived ): { // They want a file from us. Too bad. break; } case( kOBEXSessionEventTypeError ): { if( inEvent->u.errorData.error == kOBEXSessionTransportDiedError ) { [self transportConnectionDied]; } break; } default: break; } } -(void)handleConnectCommand:(const OBEXSessionEvent *)inEvent { OBEXError status; // Are we happy with the headers? If so, send a successful connect response. status = [mOBEXSession OBEXConnectResponse:(OBEXOpCode)kOBEXResponseCodeSuccessWithFinalBit flags:(OBEXFlags)kOBEXConnectFlagNone maxPacketLength:(OBEXMaxPacketLength)inEvent->u.connectCommandData.maxPacket Size optionalHeaders:(void*)NULL optionalHeadersLength:(size_t)0 eventSelector:(SEL) @selector( sessionEventDispatch: ) selectorTarget:(id)self refCon:(void *)NULL]; if( status != kOBEXSuccess ) { } else { mConnectedToClient = TRUE; } return; } _______________________________________________ Do not post admin requests to the list. They will be ignored. Bluetooth-dev mailing list (Bluetooth-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/bluetooth-dev/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com