The Affix provides a flexible API to implement OBEX server and OBEX client applications. The OBEX API is very simple. Any object is stored in a file before/after transfer. The Affix OBEX API provides easy way to deal with it.

3.5.1. Data structures

All data structure definitions are located in the <affix/obex.h> header file and they include: obexclt_t, obexsrv_t, obex_file_t.

3.5.2. OBEX file API

The main concept of the Affix OBEX API is that any object is stored in a file. Before object can be transferred it must be stored in a file. The Affix has a following function set for that:

3.5.3. Client API

The OBEX client API includes two sets of functions: general purpose and file transfer oriented.

Table 3-14. OBEX client API

obexclt_t *obex_connect(struct sockaddr_affix *addr, obex_target_t *target, int *err);Opens connection to OBEX server. Accepts sockaddr_affix address and target. Retuns OBEX client object.
int obex_disconnect(obexclt_t *clt);Closes connection to OBEX server.
int obex_get(obexclt_t *clt, char *local, char *remote, char *type);Receives object from the server. Target object specified by "remote" and "type" arguments. It is stored in the file "local".
int obex_put(obexclt_t *clt, char *local, char *remote, char *type);Sends object from a file "local" to the server. Target object identified by "remote" and "type".
obexclt_t *obex_connect_file(struct sockaddr_affix *addr, int *err);Opens connection to FTP service on the server.
int obex_get_file(obexclt_t *clt, char *local, char *remote);Receives file "remote" from the server and stores it to the file "local". If "local" is NULL then file is stored with the name "remote" to the current working directory.
int obex_put_file(obexclt_t *clt, char *local, char *remote);Sends file "local" to the server and stores it in the file "remote". If "remote" is NULL then file is stored with the name "local" to the server current working directory.
int obex_browse(obexclt_t *clt, char *local, char *name);Gets "name" folder listing from the server and stores it in the file local.
int obex_setpath(obexclt_t *clt, char *path);Changes working directory on the server to "path".
int obex_mkdir(obexclt_t *clt, char *path);Creates new directory with path "path" on the server.

3.5.4. Server API

The Affix provides a very simple API to implement OBEX servers also. OBEX server works in request-response way: waits for a request from client, processes it and sends response back.

The main idea behind API is "call-back" function. OBEX server exports certain functions, which are called by the Affix OBEX library when certain request arrives. Server implementation has to create a server object and initialize callback function pointers (see bellow) and to call btsrv_run() to start request processing loop.