4 #include <bth_fce_out.h>
5 #include <bth_inface.h>
8 /* #include <cmd_proc.h> */
9 /* #include "cmd_bth.h" */
10 /* #include "cmd_pxmc.h" */
11 #include <bth_h8s2638.h>
13 #include <bluetooth/bluetooth.h>
14 #include <bluetooth/hci.h>
15 #include <bluetooth/hci_lib.h>
16 #include <sys/ioctl.h>
19 static int open_socket(int dev, unsigned long flags)
21 struct sockaddr_hci addr;
22 struct hci_filter flt;
23 struct hci_dev_info di;
26 if (dev != HCI_DEV_NONE) {
27 dd = hci_open_dev(dev);
29 perror("Can't open device");
33 if (hci_devinfo(dev, &di) < 0) {
34 perror("Can't get device info");
38 opt = hci_test_bit(HCI_RAW, &di.flags);
39 if (ioctl(dd, HCISETRAW, opt) < 0) {
40 if (errno == EACCES) {
41 perror("Can't access device");
49 /* Create HCI socket */
50 sk = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
52 perror("Can't create raw socket");
57 if (setsockopt(sk, SOL_HCI, HCI_DATA_DIR, &opt, sizeof(opt)) < 0) {
58 perror("Can't enable data direction info");
63 if (setsockopt(sk, SOL_HCI, HCI_TIME_STAMP, &opt, sizeof(opt)) < 0) {
64 perror("Can't enable time stamp");
69 hci_filter_clear(&flt);
70 hci_filter_all_ptypes(&flt);
71 hci_filter_all_events(&flt);
72 if (setsockopt(sk, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
73 perror("Can't set filter");
77 /* Bind socket to the HCI device */
78 addr.hci_family = AF_BLUETOOTH;
80 if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
81 printf("Can't attach to device hci%d. %s(%d)\n",
82 dev, strerror(errno), errno);
96 extern int hci_socket;
97 //hci_socket = open_socket(0, 0);
100 bth_init(); /* bluetooth initialization */
102 /*inicializace komunikacnich datovych I/O bufferu */
105 /*TPU channel 1 - inicialize (kontrola paketu + pocatecni zpozdeni)*/
106 bth_init_pkt_controll();
108 /*nastaveni zarizeni Bth do slave role*/
109 bth_parametr_slave();
111 /*kratka cas. pouza pro bth zarizeni - mazani zasilanych dat*/
113 // bth_start_TPU_counter();
116 /*nekonecna smycka obsluhujici bth, pc ...*/
119 ret = read(hci_socket, &zn_bth, sizeof(zn_bth));
122 bth_recieve_packet(zn_bth);
125 l2cap_send_data(0, 0);
126 bth_send_queue(); /* send built packets if there are any */