obex.h File Reference

#include <guiddef.h>

Go to the source code of this file.

Data Structures

struct  _BluetoothAddress
struct  _TagLengthValue

Defines

#define DEFINE_OBEX_UUID(name, l)   DEFINE_GUID( name, l, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB );
#define OBEX_ERROR_AUTHENTICATION_FAILED   2
#define OBEX_ERROR_INVALID_PACKET   7
#define OBEX_ERROR_INVALID_PARAMETER   3
#define OBEX_ERROR_OUT_OF_MEMORY   4
#define OBEX_ERROR_PACKET_TOO_LARGE   6
#define OBEX_ERROR_SUCCESS   0
#define OBEX_ERROR_UNDEFINED   1
#define OBEX_ERROR_UNSUPPORTED   5
#define OBEX_PACKET_MAXIMUM_SIZE   65535

Typedefs

typedef int(*) AuthenticationResponseFunc (void *appData, byte *authResponse, word *authSize)
 Authentication response callback function.
typedef _BluetoothAddress BluetoothAddress
typedef _BTConnection BTConnection
typedef unsigned char byte
typedef unsigned int dword
typedef GUID OBEX_UUID
typedef _ObexPacket ObexPacket
typedef enum _ObexPacketHeader ObexPacketHeader
typedef enum _ObexPacketOperation ObexPacketOperation
typedef enum _ObexResponseCode ObexResponseCode
typedef _ObexSession ObexSession
typedef enum _ObexSessionFlags ObexSessionFlags
typedef _ObexTLVPacket ObexTLVPacket
typedef _TagLengthValue TLV
typedef unsigned short word

Enumerations

enum  _ObexPacketHeader {
  OBEX_PACKET_HEADER_UNKNOWN = 0, OBEX_PACKET_HEADER_NAME = 0x01, OBEX_PACKET_HEADER_DESCRIPTION = 0x05, OBEX_PACKET_HEADER_TYPE = 0x42,
  OBEX_PACKET_HEADER_TIME = 0x44, OBEX_PACKET_HEADER_TARGET = 0x46, OBEX_PACKET_HEADER_HTTP = 0x47, OBEX_PACKET_HEADER_BODY = 0x48,
  OBEX_PACKET_HEADER_EOF_BODY = 0x49, OBEX_PACKET_HEADER_WHO = 0x4A, OBEX_PACKET_HEADER_APP_PARAMS = 0x4C, OBEX_PACKET_HEADER_AUTH_CHG = 0x4D,
  OBEX_PACKET_HEADER_AUTH_RES = 0x4E, OBEX_PACKET_HEADER_WAN_UUID = 0x50, OBEX_PACKET_HEADER_CLASS = 0x51, OBEX_PACKET_HEADER_SESSION_PARAM = 0x52,
  OBEX_PACKET_HEADER_SESSION_SEG = 0x93, OBEX_PACKET_HEADER_COUNT = 0xC0, OBEX_PACKET_HEADER_LENGTH = 0xC3, OBEX_PACKET_HEADER_TIME2 = 0xC4,
  OBEX_PACKET_HEADER_CONNECTION_ID = 0xCB, OBEX_PACKET_HEADER_CREATOR = 0xCF
}
enum  _ObexPacketOperation {
  OBEX_PACKET_OPERATION_UNKNOWN = 0, OBEX_PACKET_OPERATION_CONNECT = 0x80, OBEX_PACKET_OPERATION_DISCONNECT = 0x81, OBEX_PACKET_OPERATION_PUT = 0x02,
  OBEX_PACKET_OPERATION_PUT_FINAL = 0x82, OBEX_PACKET_OPERATION_GET = 0x03, OBEX_PACKET_OPERATION_GET_FINAL = 0x83, OBEX_PACKET_OPERATION_SET_PATH = 0x85,
  OBEX_PACKET_OPERATION_SESSION = 0x87, OBEX_PACKET_OPERATION_ABORT = 0xFF
}
enum  _ObexResponseCode {
  OBEX_RESPONSE_CODE_UNKNOWN = 0, OBEX_RESPONSE_CODE_CONTINUE = 0x10, OBEX_RESPONSE_CODE_SUCCESS = 0x20, OBEX_RESPONSE_CODE_BAD_REQUEST = 0x40,
  OBEX_RESPONSE_CODE_UNAUTHORIZED = 0x41, OBEX_RESPONSE_CODE_PAYREQ = 0x42, OBEX_RESPONSE_CODE_FORBIDDEN = 0x43, OBEX_RESPONSE_CODE_NOTFOUND = 0x44,
  OBEX_RESPONSE_CODE_BAD_METHOD = 0x45, OBEX_RESPONSE_CODE_UNACCEPTABLE = 0x46, OBEX_RESPONSE_CODE_PROXY_AUTH_REQ = 0x47, OBEX_RESPONSE_CODE_REQ_TIMEOUT = 0x48,
  OBEX_RESPONSE_CODE_CONFLICT = 0x49, OBEX_RESPONSE_CODE_GONE = 0x4A, OBEX_RESPONSE_CODE_LENGTH_REQ = 0x4B, OBEX_RESPONSE_CODE_PRECON_FAILED = 0x4C,
  OBEX_RESPONSE_CODE_ENTITY_TOO_LARGE = 0x4D, OBEX_RESPONSE_CODE_URL_TOO_LARGE = 0x4E, OBEX_RESPONSE_CODE_UNSUPPORTED_MEDIA_TYPE = 0x4F, OBEX_RESPONSE_CODE_INTERNAL_SERVER_ERROR = 0x50,
  OBEX_RESPONSE_CODE_NOT_IMPLEMENTED = 0x51, OBEX_RESPONSE_CODE_BAD_GATEWAY = 0x52, OBEX_RESPONSE_CODE_SERVICE_UNAVAILABLE = 0x53, OBEX_RESPONSE_CODE_GATEWAY_TIMEOUT = 0x54,
  OBEX_RESPONSE_CODE_HTTP_VERSION_UNSUPPORTED = 0x55, OBEX_RESPONSE_CODE_DATABASE_FULL = 0x60, OBEX_RESPONSE_CODE_DATABASE_LOCKED = 0x61
}
enum  _ObexSessionFlags { OBEX_SESSION_FLAGS_UNKNOWN = 0, OBEX_SESSION_FLAGS_AUTHENTICATE = 1 }

Functions

int closeBTConnection (BTConnection *connection)
 Close bluetooth connection.
int createBTConnection (BTConnection **connection, const BluetoothAddress *device, const BluetoothAddress *address, const OBEX_UUID *service, byte channel)
 Create Bluetooth connection.
 DEFINE_GUID (SERVICE_TARGET_SYNCML_SYNC, 0x53594e43, 0x4d4c, 0x2d53, 0x59, 0x4e, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00)
 DEFINE_GUID (SERVICE_TARGET_IRMC_SYNC, 0x49524D43, 0x2D53, 0x594E, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
 DEFINE_GUID (SERVICE_TARGET_FOLDER_BROWSING, 0xF9EC7BC4, 0x953C, 0x11D2, 0x98, 0x4E, 0x52, 0x54, 0x00, 0xDC, 0x9E, 0x09)
int obexPacketAddHeader (ObexPacket *packet, ObexPacketHeader header, word size, void *data)
 Add header to obex packet.
int obexPacketAddHeaderAscii (ObexPacket *packet, ObexPacketHeader header, const char *string)
 Add ascii string type header to obex packet.
int obexPacketAddHeaderBin (ObexPacket *packet, ObexPacketHeader header, word size, byte *bytes)
 Add binary byte sequence to packet.
int obexPacketAddHeaderByte (ObexPacket *packet, ObexPacketHeader header, byte value)
 Add 1 byte unsigned integer to packet.
int obexPacketAddHeaderInt (ObexPacket *packet, ObexPacketHeader header, dword value)
 Add 4 byte unsigned integer to packet.
int obexPacketAddHeaderTLV (ObexPacket *packet, ObexPacketHeader header, ObexTLVPacket *tlvPacket)
 Add TLV packet to obex packet.
int obexPacketAddHeaderUnicode (ObexPacket *packet, ObexPacketHeader header, const wchar_t *string)
 Add unicode string type header to obex packet.
int obexPacketAddHeaderUUID (ObexPacket *packet, ObexPacketHeader header, OBEX_UUID value)
 Add UUID to packet.
int obexPacketClear (ObexPacket *packet, ObexPacketOperation operation, byte flags)
 Clear obex packet.
int obexPacketCreate (ObexPacket **packet, ObexPacketOperation operation, byte flags)
 Create obex packet.
int obexPacketDestroy (ObexPacket *packet)
 Destroy packet.
int obexPacketGetHeaderAscii (ObexPacket *packet, ObexPacketHeader header, char *string, int size)
 Get ascii string type header to obex packet.
int obexPacketGetHeaderBin (ObexPacket *packet, ObexPacketHeader header, word *size, byte *bytes)
 Get binary byte sequence from packet.
int obexPacketGetHeaderByte (ObexPacket *packet, ObexPacketHeader header, byte *value)
 Get 1 byte unsigned int from packet.
int obexPacketGetHeaderData (ObexPacket *packet, ObexPacketHeader header, void *outData)
 Get header data.
int obexPacketGetHeaderInt (ObexPacket *packet, ObexPacketHeader header, dword *value)
 Get 4 byte unsigned int from packet.
int obexPacketGetHeaderTLV (ObexPacket *packet, ObexPacketHeader header, ObexTLVPacket **tlvPacket)
 Get TLV packet from obex packet.
int obexPacketGetHeaderUnicode (ObexPacket *packet, ObexPacketHeader header, wchar_t *string, int size)
 Get unicode string type header to obex packet.
int obexPacketGetHeaderUUID (ObexPacket *packet, ObexPacketHeader header, OBEX_UUID *value)
 Get UUID from packet.
byte obexPacketGetId (ObexPacket *packet)
 Get obex packet id.
word obexPacketGetSize (ObexPacket *packet)
 Get obex packet size.
word obexPacketGetSizeLeft (ObexSession *session, ObexPacket *packet)
 Get size left in a packet supported by session.
int obexPacketHasHeader (ObexPacket *packet, ObexPacketHeader header, word *headerSize)
 Query packet headers.
ObexResponseCode obexResponseCode (byte packetId, int *finalBitSet)
 Convert response packet id to response code and final bit.
int obexSessionClose (ObexSession *session)
 Close obex session.
dword obexSessionGetConnectionId (ObexSession *session)
 Get the connection id from session.
int obexSessionGetConnectionTarget (ObexSession *session, OBEX_UUID *uuid)
 Get the connection target.
word obexSessionGetMaximumRequestSize (ObexSession *session)
 Get the maximum packet size supported by session.
int obexSessionOpen (ObexSession **session, BTConnection *connection, ObexPacket *request, ObexPacket **response, const OBEX_UUID *target, AuthenticationResponseFunc authFunc, void *appData, ObexSessionFlags flags)
 Open obex session to the obex server.
int obexSessionSend (ObexSession *session, ObexPacket *request, ObexPacket **response)
 Send obex packet and receive the response.
int obexTLVAddValue (ObexTLVPacket *tlvPacket, TLV *tlv)
 Add new triplet to packet.
int obexTLVCreate (ObexTLVPacket **tlvPacket)
 Create new Tag-Length-Value triplet packet.
int obexTLVDestroy (ObexTLVPacket *tlvPacket)
 Destroy Tag-Length-Value triplet packet.
byte obexTLVGetCount (ObexTLVPacket *tlvPacket)
 Get the number of triplets in packet.
word obexTLVGetSize (ObexTLVPacket *tlvPacket)
 Get the size of the TLV packet in bytes.
int obexTLVGetValue (ObexTLVPacket *tlvPacket, byte index, TLV *tlv)
 Get the TLV from a packet.
int peekBTConnection (BTConnection *connection, dword *available)
 Peek available data in connection.
int readBTConnection (BTConnection *connection, dword *size, void *data)
 Read data from connection.
int writeBTConnection (BTConnection *connection, dword *size, void *data)
 Write data to connection.


Define Documentation

#define DEFINE_OBEX_UUID ( name,
 )     DEFINE_GUID( name, l, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB );

Definition at line 297 of file obex.h.

#define OBEX_ERROR_AUTHENTICATION_FAILED   2

Definition at line 241 of file obex.h.

#define OBEX_ERROR_INVALID_PACKET   7

Definition at line 246 of file obex.h.

#define OBEX_ERROR_INVALID_PARAMETER   3

Definition at line 242 of file obex.h.

#define OBEX_ERROR_OUT_OF_MEMORY   4

Definition at line 243 of file obex.h.

#define OBEX_ERROR_PACKET_TOO_LARGE   6

Definition at line 245 of file obex.h.

#define OBEX_ERROR_SUCCESS   0

Definition at line 239 of file obex.h.

#define OBEX_ERROR_UNDEFINED   1

Definition at line 240 of file obex.h.

#define OBEX_ERROR_UNSUPPORTED   5

Definition at line 244 of file obex.h.

#define OBEX_PACKET_MAXIMUM_SIZE   65535

Obex packet maximum size

Definition at line 249 of file obex.h.


Typedef Documentation

typedef int(*) AuthenticationResponseFunc(void *appData, byte *authResponse, word *authSize)

Authentication response callback function.

This function is called by the obex client when client receives authentication challenge from server. The application then must respond by sending Authentication response. The response is passed to the obex using the authResponse and authSize parameters. The application must generate request-digest from the password and copy it to the buffer passed to the function. Obex then sends it to the server for authentication. See irOBEX specs 3.5, for more information.

Parameters:
appData - Application data passed to the callback function.
authResponse - The buffer where to copy the response-digest.
authSize - In: The size of the buffer. Out: The size of the response-digest.
Remarks:
The function propotype and/or functionality is subject to change when the authentication is implemented. This is just an axample.

Currently authentication is not supported and the function receiving the challenge returns OBEX_ERROR_UNSUPPORTED.

Returns:
The callback must return OBEX_ERROR_SUCCESS if it has succesfully generated the response.

The callback must return OBEX_ERROR_AUTHENTICATION_FAILED when it doesn't want the authentication to go on.

Definition at line 330 of file obex.h.

typedef struct _BluetoothAddress BluetoothAddress

Bluetooth address

typedef struct _BTConnection BTConnection

Bluetooth connection structure.

Definition at line 259 of file obex.h.

typedef unsigned char byte

Definition at line 254 of file obex.h.

typedef unsigned int dword

Definition at line 256 of file obex.h.

typedef GUID OBEX_UUID

Definition at line 294 of file obex.h.

typedef struct _ObexPacket ObexPacket

Obex packet.

Definition at line 262 of file obex.h.

typedef enum _ObexPacketHeader ObexPacketHeader

Obex packet headers.

Values between 0x14 to 0x2F are reserved for future use (with all combinations of the upper 2 bits) Values between 0x30 to 0x3F are User defined (with all combinations of the upper 2 bits)

Read irObex spec p.13 OBEX headers how the 2 msb affect the size of the header data. 0x00 => unicode text 0x40 => byte sequence/ascii text 0x80 => 1 byte 0xC0 => 4 byte

typedef enum _ObexPacketOperation ObexPacketOperation

Obex packet operations.

typedef enum _ObexResponseCode ObexResponseCode

Obex response codes. Codes with final bit set has another purpose.

typedef struct _ObexSession ObexSession

Obex session.

Definition at line 265 of file obex.h.

typedef enum _ObexSessionFlags ObexSessionFlags

Obex session flags.

typedef struct _ObexTLVPacket ObexTLVPacket

TLV(tag-length-value) encoded packet.

Definition at line 268 of file obex.h.

typedef struct _TagLengthValue TLV

Tag-Length-Value

typedef unsigned short word

Definition at line 255 of file obex.h.


Enumeration Type Documentation

enum _ObexPacketHeader

Obex packet headers.

Values between 0x14 to 0x2F are reserved for future use (with all combinations of the upper 2 bits) Values between 0x30 to 0x3F are User defined (with all combinations of the upper 2 bits)

Read irObex spec p.13 OBEX headers how the 2 msb affect the size of the header data. 0x00 => unicode text 0x40 => byte sequence/ascii text 0x80 => 1 byte 0xC0 => 4 byte

Enumerator:
OBEX_PACKET_HEADER_UNKNOWN  NULL terminating UNICODE string. For example filename(file.txt). OPTIONAL
OBEX_PACKET_HEADER_NAME  Text description of the object. Null terminating UNICODE string. OPTIONAL
OBEX_PACKET_HEADER_DESCRIPTION 
OBEX_PACKET_HEADER_TYPE  Type of the object. Null terminating ASCII string. Corrensponds to content-type in HTTP. OPTIONAL
OBEX_PACKET_HEADER_TIME 
OBEX_PACKET_HEADER_TARGET 
OBEX_PACKET_HEADER_HTTP  HTTP 1.x header. OPTIONAL
OBEX_PACKET_HEADER_BODY  Body and End-Of-Body. The content of the object being sent. For example the file of the FTP send. To send file in multiple chunks add multiple BODY headers. EOF_BODY marks the end of the object and is send only once for each object.
OBEX_PACKET_HEADER_EOF_BODY 
OBEX_PACKET_HEADER_WHO  Who. Read 2.2.10 in OBEX specs. OPTIONAL.
OBEX_PACKET_HEADER_APP_PARAMS  n * TLV triplets. Application parameters. Extended applicaton request&response information.
OBEX_PACKET_HEADER_AUTH_CHG  n * TLV triplets. Authentication challenge.
OBEX_PACKET_HEADER_AUTH_RES  Authentication responce.
OBEX_PACKET_HEADER_WAN_UUID  WAN UUID.
OBEX_PACKET_HEADER_CLASS  Object class.
OBEX_PACKET_HEADER_SESSION_PARAM  n * TLV triplets. Session parameter.
OBEX_PACKET_HEADER_SESSION_SEG  1 byte quantity. Session sequence number. Running sequence number in sequence to syncronize and for reliability. Must be first header in a packet. Read 2.2.19.
OBEX_PACKET_HEADER_COUNT  4 byte unsigned integer. Number of objects. Used by CONNECT. Read CONNECT(3.3.1) from specs.
OBEX_PACKET_HEADER_LENGTH  4 byte unsigned integer. Length of the object in bytes. End-Of-Body overrides the length. Use HTTP content-length for files greater than 4GB. OPTIONAL.
OBEX_PACKET_HEADER_TIME2  4 byte version of time. Seconds since Jan-01-1970. Not recommended.
OBEX_PACKET_HEADER_CONNECTION_ID  4 byte value. Returned in CONNECT responce. Cannot be used in CONNECT request. Cannot be used with TARGET header in request. OPTIONAL.
OBEX_PACKET_HEADER_CREATOR  4 byte unsigned integer. Creator ID. Indicates the creator of the object. OPTIONAL.

Definition at line 100 of file obex.h.

enum _ObexPacketOperation

Obex packet operations.

Enumerator:
OBEX_PACKET_OPERATION_UNKNOWN 
OBEX_PACKET_OPERATION_CONNECT 
OBEX_PACKET_OPERATION_DISCONNECT 
OBEX_PACKET_OPERATION_PUT 
OBEX_PACKET_OPERATION_PUT_FINAL 
OBEX_PACKET_OPERATION_GET 
OBEX_PACKET_OPERATION_GET_FINAL 
OBEX_PACKET_OPERATION_SET_PATH 
OBEX_PACKET_OPERATION_SESSION 
OBEX_PACKET_OPERATION_ABORT 

Definition at line 174 of file obex.h.

enum _ObexResponseCode

Obex response codes. Codes with final bit set has another purpose.

Enumerator:
OBEX_RESPONSE_CODE_UNKNOWN 
OBEX_RESPONSE_CODE_CONTINUE  Continue.
OBEX_RESPONSE_CODE_SUCCESS  Succcess.
OBEX_RESPONSE_CODE_BAD_REQUEST  Bad request.
OBEX_RESPONSE_CODE_UNAUTHORIZED  Unauthorized.
OBEX_RESPONSE_CODE_PAYREQ  Payment required.
OBEX_RESPONSE_CODE_FORBIDDEN  Forbidden.
OBEX_RESPONSE_CODE_NOTFOUND  The thing was not found.
OBEX_RESPONSE_CODE_BAD_METHOD  Method not alowed.
OBEX_RESPONSE_CODE_UNACCEPTABLE  Not acceptable.
OBEX_RESPONSE_CODE_PROXY_AUTH_REQ  Proxy authentication required.
OBEX_RESPONSE_CODE_REQ_TIMEOUT  Request time out.
OBEX_RESPONSE_CODE_CONFLICT  conflict
OBEX_RESPONSE_CODE_GONE  gone
OBEX_RESPONSE_CODE_LENGTH_REQ  length reuired
OBEX_RESPONSE_CODE_PRECON_FAILED  precondition failed
OBEX_RESPONSE_CODE_ENTITY_TOO_LARGE  requested entity too large
OBEX_RESPONSE_CODE_URL_TOO_LARGE  requested URL too large
OBEX_RESPONSE_CODE_UNSUPPORTED_MEDIA_TYPE  unsupported media type
OBEX_RESPONSE_CODE_INTERNAL_SERVER_ERROR  Internal server error.
OBEX_RESPONSE_CODE_NOT_IMPLEMENTED  Not implemented.
OBEX_RESPONSE_CODE_BAD_GATEWAY  bad gateway
OBEX_RESPONSE_CODE_SERVICE_UNAVAILABLE  service unavailable
OBEX_RESPONSE_CODE_GATEWAY_TIMEOUT  gateway timeout
OBEX_RESPONSE_CODE_HTTP_VERSION_UNSUPPORTED  HTTP version not supported.
OBEX_RESPONSE_CODE_DATABASE_FULL  database is full
OBEX_RESPONSE_CODE_DATABASE_LOCKED  database is locked

Definition at line 195 of file obex.h.

enum _ObexSessionFlags

Obex session flags.

Enumerator:
OBEX_SESSION_FLAGS_UNKNOWN 
OBEX_SESSION_FLAGS_AUTHENTICATE  initiate obex authentication

Definition at line 232 of file obex.h.


Function Documentation

int closeBTConnection ( BTConnection connection  ) 

Close bluetooth connection.

Closes bluetooth connection. Calls WSACleanup.

Parameters:
connection - Bluetooth connection to close.
Returns:
OBEX_ERROR_SUCCESS if function succeeds.

OBEX_ERROR_INVALID_PARAMETER if connection parameter is NULL.

int createBTConnection ( BTConnection **  connection,
const BluetoothAddress device,
const BluetoothAddress address,
const OBEX_UUID service,
byte  channel 
)

Create Bluetooth connection.

Open bluetooth connection to remote device specified by bluetooth address and to specific channel or service. Uses windows sockets.

Parameters:
connection - Out: Pointer to the created bluetooth connection.
device - Address of local device/radio to be used with connection. Currently windows supports only one bluetooth radio. Must be set to NULL.
address - Address of the remote device.
service - Unique identifier specifying the service in whitch to connect to.
channel - Channel to connect to. Valid channels range from 1 to 32. Zero if not used.
Remarks:
The channel parameter overriders service parameter.

Calls WSAStartup.

Returns:
OBEX_ERROR_SUCCESS if function succeeds.

OBEX_INVALID_PARAMETER if one of the parameters is not valid. Connection must not be NULL. Device must be NULL. Either address or channel must be specified.

WSAGetLastError() if some other error occurs.

DEFINE_GUID ( SERVICE_TARGET_SYNCML_SYNC  ,
0x53594e43  ,
0x4d4c  ,
0x2d53  ,
0x59  ,
0x4e  ,
0x43  ,
0x00  ,
0x00  ,
0x00  ,
0x00  ,
0x00   
)

DEFINE_GUID ( SERVICE_TARGET_IRMC_SYNC  ,
0x49524D43  ,
0x2D53  ,
0x594E  ,
0x43  ,
0x00  ,
0x00  ,
0x00  ,
0x00  ,
0x00  ,
0x00  ,
0x00   
)

DEFINE_GUID ( SERVICE_TARGET_FOLDER_BROWSING  ,
0xF9EC7BC4  ,
0x953C  ,
0x11D2  ,
0x98  ,
0x4E  ,
0x52  ,
0x54  ,
0x00  ,
0xDC  ,
0x9E  ,
0x09   
)

int obexPacketAddHeader ( ObexPacket packet,
ObexPacketHeader  header,
word  size,
void *  data 
)

Add header to obex packet.

This function adds header and it's data to the packet. The size that the header needs depends on the ObexPacketHeader. Headers starting with 0x00 and 0x40 are 2 byte length prefixed headers and need 1 byte for header + 2 bytes for the size and n bytes for the data. The 2 byte size contain the size of the whole header(1+2+n). This function appends the header id,size and the data to the packet. Headers starting with 0x80 and 0xC0 need 2 or 5 bytes(header + 1byte or 4 bytes).

Parameters:
packet - Packet where the heaeder is added to.
header - Packet operation.
size - Size of the header data in bytes.
data - Pointer to the data.
Remarks:
If one wants to add maximum sized BODY header to packet one must subtract 3 bytes from the value obexPacketGetSizeLeft returns. Similarly with other headers.

The data in the headers is in it's raw format(network byte order). One must convert it to the network byte order before using the function. obexPacketAddHeaderXXX functions and obexPacketGetHeaderXXX functions convert the data for the user.

The maximum size for the packet is 64K. It is possible to create bigger packets than session supports.

User defined headers are not supported. The function returns OBEX_ERROR_INVALID_PARAMETER.

Returns:
OBEX_ERROR_SUCCESS if function succeeds.

OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function, or if parameter combination is not valid according to specifications or packet already contains same header.

OBEX_ERROR_PACKET_TOO_LARGE if the header doesn't fit to the packet.

OBEX_ERROR_OUT_OF_MEMORY if out of memory.

int obexPacketAddHeaderAscii ( ObexPacket packet,
ObexPacketHeader  header,
const char *  string 
)

Add ascii string type header to obex packet.

Parameters:
packet - The packet to add the header.
header - Header to be added.
string - Null terminating ascii string.
Returns:
Returns same error codes as obexPacketAddHeader.

OBEX_ERROR_INVALID_PARAMETER if the header being added is not ascii type.

int obexPacketAddHeaderBin ( ObexPacket packet,
ObexPacketHeader  header,
word  size,
byte bytes 
)

Add binary byte sequence to packet.

Parameters:
packet - The packet to add the header.
header - Header to be added.
size - The number of bytes in the byte sequence.
bytes - Pointer to the bytes.
Returns:
Returns same error codes as obexPacketAddHeader.

OBEX_ERROR_INVALID_PARAMETER if the header being added is not binary byte sequence type.

int obexPacketAddHeaderByte ( ObexPacket packet,
ObexPacketHeader  header,
byte  value 
)

Add 1 byte unsigned integer to packet.

Parameters:
packet - The packet to add the header.
header - Header to be added.
value - The integer value to be added.
Returns:
Returns same error codes as obexPacketAddHeader.

OBEX_ERROR_INVALID_PARAMETER if the header being added is not 1 byte unsigned integer type.

int obexPacketAddHeaderInt ( ObexPacket packet,
ObexPacketHeader  header,
dword  value 
)

Add 4 byte unsigned integer to packet.

Parameters:
packet - The packet to add the header.
header - Header to be added.
value - The integer value to be added.
Returns:
Returns same error codes as obexPacketAddHeader.

OBEX_ERROR_INVALID_PARAMETER if the header being added is not 4 byte unsigned integer type.

int obexPacketAddHeaderTLV ( ObexPacket packet,
ObexPacketHeader  header,
ObexTLVPacket tlvPacket 
)

Add TLV packet to obex packet.

Parameters:
packet - The packet to add the header.
header - Header to be added.
tlvPacket - TLV packet to be added.
Remarks:
The TLV functions are not implemented.
Returns:
OBEX_ERROR_UNSUPPORTED in all cases.

int obexPacketAddHeaderUnicode ( ObexPacket packet,
ObexPacketHeader  header,
const wchar_t *  string 
)

Add unicode string type header to obex packet.

Parameters:
packet - The packet to add the header.
header - Header to be added.
string - Null terminating unicode string.
Returns:
Returns same error codes as obexPacketAddHeader.

OBEX_ERROR_INVALID_PARAMETER if the header being added is not unicode type.

int obexPacketAddHeaderUUID ( ObexPacket packet,
ObexPacketHeader  header,
OBEX_UUID  value 
)

Add UUID to packet.

Parameters:
packet - The packet to add the header.
header - Header to be added.
value - The UUID value to be added.
Returns:
Returns same error codes as obexPacketAddHeader.

OBEX_ERROR_INVALID_PARAMETER if the header being added is not Unique identifier type.

int obexPacketClear ( ObexPacket packet,
ObexPacketOperation  operation,
byte  flags 
)

Clear obex packet.

Function clears used packet and initializes it for the given new operation.

Parameters:
packet - Packet to be cleared.
operation - New operation for the packet.
flags - New operation flags.
Returns:
OBEX_ERROR_SUCCESS if function succeeds.

OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.

OBEX_ERROR_OUT_OF_MEMORY if out of memory.

int obexPacketCreate ( ObexPacket **  packet,
ObexPacketOperation  operation,
byte  flags 
)

Create obex packet.

Create packet for certain operation. Flags depend on the operation. See irOBEX specs operations for valid flags.

Parameters:
packet - Out: Pointer to the created obex packet.
operation - Packet operation.
flags - Flags depending on the operation.
Returns:
OBEX_ERROR_SUCCESS if function succeeds.

OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.

OBEX_ERROR_OUT_OF_MEMORY if out of memory.

OBEX_ERROR_UNSUPPORTED if SESSION operation is passed to function.

int obexPacketDestroy ( ObexPacket packet  ) 

Destroy packet.

Parameters:
packet - Packet to be destroyed.
Returns:
OBEX_ERROR_SUCCESS if function succeeds.

OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.

int obexPacketGetHeaderAscii ( ObexPacket packet,
ObexPacketHeader  header,
char *  string,
int  size 
)

Get ascii string type header to obex packet.

Parameters:
packet - The packet to add the header.
header - Header to be added. Only supported headers are TYPE and HTTP.
string - Null terminating unicode string.
size - Maximum size of the string in bytes.
Returns:
Returns same error codes as obexPacketAddHeader.

OBEX_ERROR_INVALID_PARAMETER if the header being added is not ascii type.

int obexPacketGetHeaderBin ( ObexPacket packet,
ObexPacketHeader  header,
word size,
byte bytes 
)

Get binary byte sequence from packet.

Parameters:
packet - The packet to add the header.
header - Header to be added. BODY.
size - In: The size of the buffer. Out: The number of bytes copied.
bytes - Pointer to the bytes.
Returns:
Returns same error codes as obexPacketAddHeader.

OBEX_ERROR_INVALID_PARAMETER if the header being added is not binary byte sequence type.

int obexPacketGetHeaderByte ( ObexPacket packet,
ObexPacketHeader  header,
byte value 
)

Get 1 byte unsigned int from packet.

Parameters:
packet - The packet to add the header.
header - Header to be added.
value - The integer value to be added.
Returns:
Returns same error codes as obexPacketAddHeader.

OBEX_ERROR_INVALID_PARAMETER if the header being added is not 1 byte unsigned integer type.

int obexPacketGetHeaderData ( ObexPacket packet,
ObexPacketHeader  header,
void *  outData 
)

Get header data.

Copy the header data from packet to user buffer. The buffer must be large enough to contain the whole header data. Use obexPacketHasHeader to get the size of the header.

Parameters:
packet - Packet to get the header data from.
header - The header to get the data from.
outData - Pointer to memory where the function copies the data.
Returns:
OBEX_ERROR_SUCCESS if function succeeds.

OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.

OBEX_ERROR_UNDEFINED if packet doesn't have the header.

int obexPacketGetHeaderInt ( ObexPacket packet,
ObexPacketHeader  header,
dword value 
)

Get 4 byte unsigned int from packet.

Parameters:
packet - The packet to add the header.
header - Header to be added.
value - The integer value to be added.
Returns:
Returns same error codes as obexPacketAddHeader.

OBEX_ERROR_INVALID_PARAMETER if the header being added is not 4 byte unsigned integer type.

int obexPacketGetHeaderTLV ( ObexPacket packet,
ObexPacketHeader  header,
ObexTLVPacket **  tlvPacket 
)

Get TLV packet from obex packet.

Parameters:
packet - The packet to add the header.
header - Header to be added.
tlvPacket - TLV packet to be added.
Remarks:
The TLV functions are not implemented.
Returns:
OBEX_ERROR_UNSUPPORTED in all cases.

int obexPacketGetHeaderUnicode ( ObexPacket packet,
ObexPacketHeader  header,
wchar_t *  string,
int  size 
)

Get unicode string type header to obex packet.

Parameters:
packet - The packet to add the header.
header - Header to be added. Only supported headers are NAME and DESCRIPTION.
string - Null terminating unicode string.
size - Maximum size of the string in bytes.
Returns:
Returns same error codes as obexPacketAddHeader.

OBEX_ERROR_INVALID_PARAMETER if the header being added is not unicode type.

int obexPacketGetHeaderUUID ( ObexPacket packet,
ObexPacketHeader  header,
OBEX_UUID value 
)

Get UUID from packet.

Parameters:
packet - The packet to add the header.
header - Header to be added.
value - The UUID value to be added.
Returns:
Returns same error codes as obexPacketAddHeader.

OBEX_ERROR_INVALID_PARAMETER if the header being added is not Unique identifier type.

byte obexPacketGetId ( ObexPacket packet  ) 

Get obex packet id.

Packet id is either operation code or full response code. To get ObexResponseCode from the id call obexResponseCode function.

Parameters:
packet - Packet to get the id from.
Returns:
Returns the one byte id of the packet. For request it's one of the ObexPacketOperation enumerations. For responce it's one of the response codes.

word obexPacketGetSize ( ObexPacket packet  ) 

Get obex packet size.

Parameters:
packet - Packet to get the size from.
Returns:
Returns the size of the packet or zero. OBEX specifications limit the size to 64K.

word obexPacketGetSizeLeft ( ObexSession session,
ObexPacket packet 
)

Get size left in a packet supported by session.

Same as obexSessionGetMaximumRequestSize(session) - obexPacketGetSize(packet).

Remarks:
One header takes 1-3 bytes of extra size than the data containing in it.
Parameters:
session - Session where the packet is supposed to be sent.
packet - Packet to get the size left from.
Returns:
Returns the size left in a packet.

int obexPacketHasHeader ( ObexPacket packet,
ObexPacketHeader  header,
word headerSize 
)

Query packet headers.

Parameters:
packet - Packet to be queried from.
header - Header to be queried.
headerSize - Out: Size of the header in bytes returned by the function. Can be NULL.
Returns:
Zero if packet does not contain the header and non-zero if it does.

ObexResponseCode obexResponseCode ( byte  packetId,
int *  finalBitSet 
)

Convert response packet id to response code and final bit.

Parameters:
packetId - Id from the response packet.
finalBitSet - Out: set to zero if final bit not set.
Returns:
Returns response code.

OBEX_RESPONCE_CODE_UNKNOWN if unknown response code.

int obexSessionClose ( ObexSession session  ) 

Close obex session.

Sends DISCONNECT to the server.

Parameters:
session - Session to be closed.
Returns:
OBEX_ERROR_SUCCESS if server responds to the request properly.

OBEX_ERROR_INVALID_PARAMETER if session parameter is NULL.

ObexResponseCode if the server returns something other that OBEX_RESPONCE_CODE_SUCCESS.

dword obexSessionGetConnectionId ( ObexSession session  ) 

Get the connection id from session.

The session id is assigned by server to session when using obexSessionOpen with target specified. Though not all sessions get assigned by session id. The session id must be the first header in a packet when it is used.

Parameters:
session - Session to ask the id from.
Returns:
Returns The connection id or zero if session doesn't have one.

int obexSessionGetConnectionTarget ( ObexSession session,
OBEX_UUID uuid 
)

Get the connection target.

Get the connection target returned by server. Should be the same as the target passed to obexSessionOpen.

Parameters:
session - Session to ask the target from.
uuid - Out: The connection target returned by server;
Returns:
OBEX_ERROR_SUCCESS if function succeeds. Succeed is returned even if session has no connection target.

OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.

word obexSessionGetMaximumRequestSize ( ObexSession session  ) 

Get the maximum packet size supported by session.

The maximum packet size is negotiated when calling obexSessionOpen function.

Parameters:
session - Session to ask the maximum packet size from.
Returns:
Returns The size of the maximum request packet size or zero.

int obexSessionOpen ( ObexSession **  session,
BTConnection connection,
ObexPacket request,
ObexPacket **  response,
const OBEX_UUID target,
AuthenticationResponseFunc  authFunc,
void *  appData,
ObexSessionFlags  flags 
)

Open obex session to the obex server.

Sends CONNECT to the server and negotiate maximum packet size.

Parameters:
session - Out: Pointer to the opened session.
connection - Opened bluetooth connection to be used by session.
request - Optional request packet by user. If NULL the function uses default packet.
response - Handle to response packet returned by the server if not NULL.
target - UUID for target header or NULL.
authFunc - Application defined callback function for authentication response.
appData - Optional application data passed to authentication function.
flags - Session opening flags.
Remarks:
The request parameter is not supported and must be NULL.

The authentication function is called when server requests authentication.

The authentication function is also called if the OBEX_SESSION_FLAGS_AUTHENTICATE is passed to the function.

Returns:
OBEX_ERROR_SUCCESS if server responds to the request properly.

OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.

OBEX_ERROR_OUT_OF_MEMORY if out of memory.

OBEX_ERROR_UNSUPPORTED if server returned authentication response or request parameter is not NULL.

OBEX_ERROR_INVALID_PACKET if server returned garbage.

ObexResponseCode if the server returns something other that OBEX_RESPONCE_CODE_SUCCESS.

int obexSessionSend ( ObexSession session,
ObexPacket request,
ObexPacket **  response 
)

Send obex packet and receive the response.

Parameters:
session - Session handle to be used in the send.
request - Obex packet that contains the request.
response - Handle to obex packet containing the response.
Returns:
OBEX_ERROR_SUCCESS if server responds to the request properly.

OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.

OBEX_ERROR_INVALID_PACKET if server returned garbage.

OBEX_ERROR_OUT_OF_MEMORY if out of memory.

OBEX_ERROR_PACKET_TOO_LARGE if the packet passed to function exceeds session maximum packet size.

int obexTLVAddValue ( ObexTLVPacket tlvPacket,
TLV tlv 
)

Add new triplet to packet.

Parameters:
tlvPacket - Packet where the triplet is added to.
tlv - TLV triplet to be added to the packet.
Remarks:
The maximum size for packet is < 64K.
Returns:
OBEX_ERROR_SUCCESS if function succeeds.

OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.

OBEX_ERROR_OUT_OF_MEMORY if out of memory.

OBEX_ERROR_PACKET_TOO_LARGE if the triplet doesn't fit to the packet.

int obexTLVCreate ( ObexTLVPacket **  tlvPacket  ) 

Create new Tag-Length-Value triplet packet.

Parameters:
tlvPacket - Handle to the created packet.
Returns:
OBEX_ERROR_SUCCESS if function succeeds.

OBEX_ERROR_INVALID_PARAMETER if tlvPacket parameter is NULL.

OBEX_ERROR_OUT_OF_MEMORY if out of memory.

int obexTLVDestroy ( ObexTLVPacket tlvPacket  ) 

Destroy Tag-Length-Value triplet packet.

Parameters:
tlvPacket - Packet to be destroyed
Returns:
OBEX_ERROR_SUCCESS if function succeeds.

OBEX_ERROR_INVALID_PARAMETER if tlvPacket parameter is NULL.

byte obexTLVGetCount ( ObexTLVPacket tlvPacket  ) 

Get the number of triplets in packet.

Parameters:
tlvPacket - The packet to get the count from.
Returns:
Returns the number of triplets in the packet or zero.

word obexTLVGetSize ( ObexTLVPacket tlvPacket  ) 

Get the size of the TLV packet in bytes.

Parameters:
tlvPacket - The packet to get the size from.
Returns:
Returns the size of the packet in bytes or zero.

int obexTLVGetValue ( ObexTLVPacket tlvPacket,
byte  index,
TLV tlv 
)

Get the TLV from a packet.

Parameters:
tlvPacket - The packet to get the value from.
index - The zero based index of the triplet.
tlv - Returned tlv value.
Returns:
OBEX_ERROR_SUCCESS if function succeeds.

OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.

int peekBTConnection ( BTConnection connection,
dword available 
)

Peek available data in connection.

Parameters:
connection - Connection where to peek.
available - Amount of data available to be read from connection.
Returns:
OBEX_ERROR_SUCCESS if function succeeds.

OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.

WSAGetLastError() if some other error occurs.

int readBTConnection ( BTConnection connection,
dword size,
void *  data 
)

Read data from connection.

Parameters:
connection - Connection where to read the data from.
size - In: the amount of bytes to read. Out: The amount of bytes read.
data - Pointer to memory where the data is read.
Returns:
OBEX_ERROR_SUCCESS if function succeeds.

OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.

WSAGetLastError() if some other error occurs.

int writeBTConnection ( BTConnection connection,
dword size,
void *  data 
)

Write data to connection.

Parameters:
connection - Connection where to write the data to.
size - In: Amount of data in bytes to be written. Out: Amout of bytes written.
data - Pointer to memory where the data is red.
Returns:
OBEX_ERROR_SUCCESS if function succeeds.

OBEX_ERROR_INVALID_PARAMETER if invalid parameters are passed to function.

WSAGetLastError() if some other error occurs.

footer


 SourceForge.net Logo