Changeset 117

Show
Ignore:
Timestamp:
03/17/06 00:02:34 (3 years ago)
Author:
abauer
Message:

Added support for bluetooth (Thanks to Anders)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/development-branch/configure.ac

    r116 r117  
    7373fi 
    7474AM_CONDITIONAL(ENABLE_OBEX, test x$HAVE_OPENOBEX = xyes) 
     75 
     76#### Check for bluetooth #### 
     77AC_ARG_ENABLE(bluetooth, 
     78  AS_HELP_STRING([--enable-bluetooth], [enable obex over bluetooth transports]), 
     79  WANT_BLUETOOTH=$enableval) 
     80 
     81PKG_CHECK_MODULES(LIBBLUETOOTH, bluez, HAVE_BLUETOOTH=yes, HAVE_BLUETOOTH=no) 
     82if test "x${HAVE_BLUETOOTH}" = "xyes"; then 
     83        if test "x${WANT_BLUETOOTH}" = "xno"; then 
     84                ENABLE_BLUETOOTH=no 
     85        else 
     86                AC_SUBST(LIBBLUETOOTH_CFLAGS) 
     87                AC_SUBST(LIBBLUETOOTH_LIBS) 
     88                ENABLE_BLUETOOTH=yes 
     89                AC_SUBST(ENABLE_BLUETOOTH) 
     90                AC_DEFINE(ENABLE_BLUETOOTH,1,[Bluetooth Transport]) 
     91        fi 
     92else 
     93        if test "x${WANT_BLUETOOTH}" = "xyes"; then 
     94                AC_MSG_ERROR("Bluez not found") 
     95        else 
     96                ENABLE_BLUETOOTH=no 
     97        fi 
     98fi 
     99AM_CONDITIONAL(ENABLE_BLUETOOTH, test x$HAVE_BLUETOOTH = xyes) 
    75100 
    76101#### Ask if the tools are needed #### 
     
    156181AC_LIBSYNCML_ISENABLED([Obex Client], ENABLE_OBEX) 
    157182AC_LIBSYNCML_ISENABLED([Obex Server], ENABLE_OBEX) 
     183AC_LIBSYNCML_ISENABLED([Bluetooth], ENABLE_BLUETOOTH) 
    158184echo 
    159185echo "Done configuring." 
  • branches/development-branch/libsyncml/transports/obex_client.c

    r116 r117  
    2525#include <libsyncml/sml_error_internals.h> 
    2626#include <libsyncml/sml_transport_internals.h> 
     27 
     28#ifdef ENABLE_BLUETOOTH 
     29#include <bluetooth/bluetooth.h> 
     30#endif 
    2731 
    2832#include "obex_client.h" 
     
    338342                } 
    339343                smlTrace(TRACE_INTERNAL, "usb connect done"); 
    340         } else { 
     344        } else if (env->type == SML_OBEX_TYPE_BLUETOOTH) { 
     345#ifdef ENABLE_BLUETOOTH 
     346                smlTrace(TRACE_INTERNAL, "connecting to bluetooth device %s channel %i", env->path, env->port); 
     347 
     348                uint8_t channel = env->port; 
     349                bdaddr_t bdaddr; 
     350                str2ba(env->path, &bdaddr); 
     351 
     352                if (BtOBEX_TransportConnect(env->obexhandle, BDADDR_ANY, &bdaddr, channel) < 0) { 
     353                        smlErrorSet(&error, SML_ERROR_GENERIC, "Bluetooth connect error"); 
     354                        goto error; 
     355                } 
     356 
     357                smlTrace(TRACE_INTERNAL, "bluetooth connect done"); 
     358#else 
     359                smlErrorSet(&error, SML_ERROR_GENERIC, "Bluetooth not enabled"); 
     360                goto error; 
     361#endif 
     362        } else { 
    341363                struct termios tio; 
    342364            memset(&tio, 0, sizeof(tio)); 
     
    373395        } 
    374396         
    375         if (env->type != SML_OBEX_TYPE_USB) { 
     397        if (env->type != SML_OBEX_TYPE_USB && env->type != SML_OBEX_TYPE_BLUETOOTH) { 
    376398                /* Start the obex transport */ 
    377399                if (FdOBEX_TransportSetup(env->obexhandle, fd, fd, 4096) < 0) { 
  • branches/development-branch/tools/syncml-obex-client.c

    r116 r117  
    6161        fprintf (stderr, "[-u <id>]\t\t\tConnect to the given usb interface number\n"); 
    6262        fprintf (stderr, "\t\t\t\tIf you dont specify an id, all available interface will be listed\n\n"); 
     63        fprintf (stderr, "[-b <addr> <channel>]\t\tConnect to the given bluetooth device\n\n"); 
    6364        fprintf (stderr, "[--identifier <name>]\t\tUse the given identifier in the initial alert.\n"); 
    6465        fprintf (stderr, "\t\t\t\tSome devices require a special string here. Nokias for example require \"PC Suite\"\n\n"); 
     
    403404                        if (errno) 
    404405                                usage (argv[0], 1); 
    405                 } else if (!strcmp (arg, "--identifier")) { 
     406                } else if (!strcmp (arg, "-b")) { 
     407#ifdef ENABLE_BLUETOOTH 
     408                        config.type = SML_OBEX_TYPE_BLUETOOTH; 
     409 
     410                        i++; 
     411                        if (!argv[i]) 
     412                                usage (argv[0], 1); 
     413                        config.url = g_strdup(argv[i]); 
     414 
     415                        i++; 
     416                        if (!argv[i]) 
     417                                usage (argv[0], 1); 
     418                        errno = 0; 
     419                        config.port = strtol(argv[i], (char **)NULL, 10); 
     420                        if (errno) 
     421                                usage (argv[0], 1); 
     422#else 
     423                        printf("Bluetooth not available in this build\n"); 
     424                        return 1; 
     425#endif 
     426                } else if (!strcmp (arg, "--identifier")) { 
    406427                        i++; 
    407428                        if (!argv[i])