Client Operations

First of all you must connect the transport using OBEX_TransportConnect or IrOBEX_TransportConnect. When the transport is connected you shall most likely also send an OBEX Connect, to let the library negotiate MTU etc. OBEX Connect is sent as any other OBEX command.

When you are done sending your requests you shall end by sending an OBEX Disconnect request and then call OBEX_TransportDisconnect.

To send a request to you must first create an OBEX Object by calling OBEX_ObjectCreate with the command opcode as argument. Next you add headers to it using OBEX_ObjectAddHeader. Finally you send away the request using OBEX_Request.

When the request has finished you'll get an OBEX_EV_REQDONE event. You can get any headers sent in response (like in a OBEX Get) by calling OBEX_ObjectGetNextHeader.

A Put would look something like this:

Example 1. OBEX Put example

	
	obex_object_t *object;
	obex_headerdata_t hd;
	
	object = OBEX_ObjectNew(handle, OBEX_CMD_PUT);
	if(object == NULL) {
		/* Error */
	}
	
	/* Add length header */
	hd.bq4 = body_size;
	OBEX_ObjectAddHeader(handle, object,
                OBEX_HDR_LENGTH, hd, 4, 0);
	
	/* Add unicode name header*/
	hdd.bs = unicodename;
	OBEX_ObjectAddHeader(handle, object,
                OBEX_HDR_NAME, hd, name_size, 0);

	/* Add body header*/
	hd.bs = body;
	OBEX_ObjectAddHeader(handle, object,
                OBEX_HDR_BODY, hd, body_size, 0);

	if(OBEX_Request(handle, object) < 0) {
		/* Error */
	}