[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnokii/common/devices unixbluetooth.c,1.10,1.11
From: |
BORBELY Zoltan <address@hidden> |
Subject: |
gnokii/common/devices unixbluetooth.c,1.10,1.11 |
Date: |
Sat, 22 Nov 2003 15:37:49 +0000 |
Update of /cvsroot/gnokii/gnokii/common/devices
In directory subversions:/tmp/cvs-serv11317/common/devices
Modified Files:
unixbluetooth.c
Log Message:
Bluetooth support on FreeBSD
Index: unixbluetooth.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/devices/unixbluetooth.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** unixbluetooth.c 20 Nov 2003 21:10:34 -0000 1.10
--- unixbluetooth.c 22 Nov 2003 15:37:46 -0000 1.11
***************
*** 37,43 ****
--- 37,90 ----
#include <sys/socket.h>
+ #ifdef HAVE_BLUETOOTH_NETGRAPH /* FreeBSD / netgraph */
+
+ #include <bitstring.h>
+ #include <netgraph/bluetooth/include/ng_hci.h>
+ #include <netgraph/bluetooth/include/ng_l2cap.h>
+ #include <netgraph/bluetooth/include/ng_btsocket.h>
+
+ #define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM
+ #define BDADDR_ANY NG_HCI_BDADDR_ANY
+ #define sockaddr_rc sockaddr_rfcomm
+ #define rc_family rfcomm_family
+ #define rc_bdaddr rfcomm_bdaddr
+ #define rc_channel rfcomm_channel
+ #define bacpy(dst, src) memcpy((dst), (src), sizeof(bdaddr_t))
+
+ #ifndef HAVE_BT_ATON
+
+ static int bt_aton(const char *str, bdaddr_t *ba)
+ {
+ char ch;
+ unsigned int b[6];
+
+ memset(ba, 0, sizeof(*ba));
+ if (sscanf(str, "%x:%x:%x:%x:%x:%x%c", b + 0, b + 1, b + 2, b + 3, b +
4, b + 5, &ch) != 6) return 0;
+ if ((b[0] | b[1] | b[2] | b[3] | b[4] | b[5]) > 0xff) return 0;
+
+ ba->b[0] = b[0];
+ ba->b[1] = b[1];
+ ba->b[2] = b[2];
+ ba->b[3] = b[3];
+ ba->b[4] = b[4];
+ ba->b[5] = b[5];
+
+ return 1;
+ }
+
+ #endif
+
+ static int str2ba(const char *str, bdaddr_t *ba)
+ {
+ return !bt_aton(str, ba);
+ }
+
+ #else /* Linux / BlueZ support */
+
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
+ #endif
+
int bluetooth_open(const char *addr, uint8_t channel, struct gn_statemachine
*state)
{
***************
*** 46,50 ****
int fd;
! str2ba((char *)addr, &bdaddr);
if ((fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0) {
--- 93,100 ----
int fd;
! if (str2ba((char *)addr, &bdaddr)) {
! fprintf(stderr, "Invalid bluetooth address \"%s\"\n", addr);
! return -1;
! }
if ((fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnokii/common/devices unixbluetooth.c,1.10,1.11,
BORBELY Zoltan <address@hidden> <=
- Prev by Date:
gnokii/include/devices osxbluetooth.h, NONE, 1.1 unixbluetooth.h, 1.5, 1.6
- Next by Date:
gnokii ChangeLog,1.713,1.714 configure.in,1.121,1.122
- Previous by thread:
gnokii/include/devices osxbluetooth.h, NONE, 1.1 unixbluetooth.h, 1.5, 1.6
- Next by thread:
gnokii ChangeLog,1.713,1.714 configure.in,1.121,1.122
- Index(es):