Path: blob/main/comms/bluegps/files/patch-bluegps.c
16461 views
--- bluegps.c 2006-06-26 20:28:31.000000000 +02001+++ bluegps.c 2007-07-29 18:54:17.000000000 +02002@@ -27,10 +27,21 @@3#include <stdarg.h>4#include <ctype.h>56+#ifdef __FreeBSD__7+#include <string.h>8+#include <sys/types.h>9+#include <sys/socket.h>10+#else11#include <netinet/ip.h>12+#endif1314+15+#ifdef __FreeBSD__16+#include <bluetooth.h>17+#else18#include <bluetooth/bluetooth.h>19#include <bluetooth/rfcomm.h>20+#endif2122#include "rbt3000.h"2324@@ -269,19 +280,44 @@25int26rbt3000_connect (char *device_addr)27{28-29+#ifdef __FreeBSD__30+ struct sockaddr_rfcomm rem_addr;31+ struct hostent * he;32+33+ memset(&rem_addr, 0, sizeof(rem_addr));34+ rem_addr.rfcomm_len = sizeof(rem_addr);35+ rem_addr.rfcomm_family = AF_BLUETOOTH;36+ rem_addr.rfcomm_channel = RFCOMM_CHANNEL;37+38+ if ((he = bt_gethostbyname(device_addr))) {39+ context->device = *(bdaddr_t *) he->h_addr_list[0];40+ if (context->messages == MSG_VERBOSE)41+ printf("Actual BT address for '%s': %s\n",42+ device_addr, bt_ntoa(&(context->device),NULL));43+ } else44+ if (!bt_aton(device_addr, &context->device)) {45+ perror("No such device address");46+ return 0;47+ }48+ rem_addr.rfcomm_bdaddr = context->device;49+#else50struct sockaddr_rc rem_addr;5152- baswap (&context->device, strtoba (device_addr));53-54rem_addr.rc_family = AF_BLUETOOTH;55- rem_addr.rc_bdaddr = context->device;56rem_addr.rc_channel = RFCOMM_CHANNEL;57+ baswap (&context->device, strtoba (device_addr));58+ rem_addr.rc_bdaddr = context->device;59+#endif6061/* bluez connects to BlueClient */62if ((context->device_fd = socket (PF_BLUETOOTH,63SOCK_STREAM,64- BTPROTO_RFCOMM)) < 0 )65+#ifdef __FreeBSD__66+ BLUETOOTH_PROTO_RFCOMM67+#else68+ BTPROTO_RFCOMM69+#endif70+ )) < 0 )71{72perror ("Can't create socket");73return 0;747576