--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <bth_fce_out.h>
+#include <bth_inface.h>
+#include <stdio.h>
+
+/* #include <cmd_proc.h> */
+/* #include "cmd_bth.h" */
+/* #include "cmd_pxmc.h" */
+#include <bth_h8s2638.h>
+
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/hci.h>
+#include <bluetooth/hci_lib.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+static int open_socket(int dev, unsigned long flags)
+{
+ struct sockaddr_hci addr;
+ struct hci_filter flt;
+ struct hci_dev_info di;
+ int sk, dd, opt;
+
+ if (dev != HCI_DEV_NONE) {
+ dd = hci_open_dev(dev);
+ if (dd < 0) {
+ perror("Can't open device");
+ exit(1);
+ }
+
+ if (hci_devinfo(dev, &di) < 0) {
+ perror("Can't get device info");
+ exit(1);
+ }
+
+ opt = hci_test_bit(HCI_RAW, &di.flags);
+ if (ioctl(dd, HCISETRAW, opt) < 0) {
+ if (errno == EACCES) {
+ perror("Can't access device");
+ exit(1);
+ }
+ }
+
+ hci_close_dev(dd);
+ }
+
+ /* Create HCI socket */
+ sk = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
+ if (sk < 0) {
+ perror("Can't create raw socket");
+ exit(1);
+ }
+
+ opt = 1;
+ if (setsockopt(sk, SOL_HCI, HCI_DATA_DIR, &opt, sizeof(opt)) < 0) {
+ perror("Can't enable data direction info");
+ exit(1);
+ }
+
+ opt = 1;
+ if (setsockopt(sk, SOL_HCI, HCI_TIME_STAMP, &opt, sizeof(opt)) < 0) {
+ perror("Can't enable time stamp");
+ exit(1);
+ }
+
+ /* Setup filter */
+ hci_filter_clear(&flt);
+ hci_filter_all_ptypes(&flt);
+ hci_filter_all_events(&flt);
+ if (setsockopt(sk, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) {
+ perror("Can't set filter");
+ exit(1);
+ }
+
+ /* Bind socket to the HCI device */
+ addr.hci_family = AF_BLUETOOTH;
+ addr.hci_dev = dev;
+ if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+ printf("Can't attach to device hci%d. %s(%d)\n",
+ dev, strerror(errno), errno);
+ exit(1);
+ }
+
+ return sk;
+}
+
+
+int main()
+{
+ int zn_bth;
+
+ printf("I'm here\n");
+
+ extern int hci_socket;
+ //hci_socket = open_socket(0, 0);
+ hci_socket = 1;
+
+ bth_init(); /* bluetooth initialization */
+
+ /*inicializace komunikacnich datovych I/O bufferu */
+ bth_inface_setup(0);
+
+ /*TPU channel 1 - inicialize (kontrola paketu + pocatecni zpozdeni)*/
+ bth_init_pkt_controll();
+
+ /*nastaveni zarizeni Bth do slave role*/
+ bth_parametr_slave();
+
+ /*kratka cas. pouza pro bth zarizeni - mazani zasilanych dat*/
+ sleep(1);
+// bth_start_TPU_counter();
+ bth_start();
+
+ /*nekonecna smycka obsluhujici bth, pc ...*/
+ do {
+ int ret;
+ ret = read(hci_socket, &zn_bth, sizeof(zn_bth));
+ if(ret > 0)
+ {
+ bth_recieve_packet(zn_bth);
+ };
+
+ l2cap_send_data(0, 0);
+ bth_send_queue(); /* send built packets if there are any */
+ } while(1);
+ return 0;
+};