⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 btsend.c

📁 bluetooth 驱动
💻 C
字号:
/* * btsend.c --  Sends data over RFCOMM using AXIS Open BT Stack * * Copyright (C) 2000, 2001  Axis Communications AB * * Author: Mattias Agren <mattias.agren@axis.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * * Exceptionally, Axis Communications AB grants discretionary and * conditional permissions for additional use of the text contained * in the company's release of the AXIS OpenBT Stack under the * provisions set forth hereunder. * * Provided that, if you use the AXIS OpenBT Stack with other files, * that do not implement functionality as specified in the Bluetooth * System specification, to produce an executable, this does not by * itself cause the resulting executable to be covered by the GNU * General Public License. Your use of that executable is in no way * restricted on account of using the AXIS OpenBT Stack code with it. * * This exception does not however invalidate any other reasons why * the executable file might be covered by the provisions of the GNU * General Public License. * * $Id: btsend.c,v 1.6 2001/05/21 09:08:14 mattiasagren Exp $ * */#include <sys/types.h>#include <sys/ioctl.h>#include <sys/wait.h>#include <sys/time.h>#include <fcntl.h>#include <time.h>#include <stdio.h>#include <fcntl.h>#include <unistd.h>#include <termios.h>#include <stdlib.h>#include <string.h>#include <syslog.h>#include <errno.h>#include <stdarg.h>#include <signal.h>#include <getopt.h>#include <setjmp.h>#include "btd.h"#include "bt_conf.h"#include "bt_vendor.h"#include "bt_misc.h"#include "bt_if.h"#include "bt_ipa.h"/*  * Syntax: btsend -d <device> -s <length> -r <repeat> */intmain(int argc, char **argv){  char *btdev = NULL;  int line, bt_fd, opt, len = -1, repeat = 1;  /* First of all check that stack is running */  if (!bt_isinitiated(-1))  {    printf("Stack not initiated, exit\n");    exit(1);  }  /* now parse options */  while ((opt = getopt(argc, argv, "d:s:r:")) != -1)  {    switch(opt)    {     case 'd':      /* BT device */      btdev = optarg;      break;           case 's':      len = atoi(optarg);      break;           case 'r':       repeat = atoi(optarg);       break;     default:      break;    }  }  if (!btdev || (len == -1))  {    printf("Syntax: btsend -d <device> -s <length> -r <repeat>\n");    exit(1);  }  /* Open BT device */    printf("Opening %s\n", btdev);  if ((bt_fd = open(btdev, O_RDWR | O_NOCTTY)) < 0)  {    printf("could not open %s\n", btdev);    exit(1);  }      line = atoi((char*)(btdev+10));  /* Wait for an rfcomm connection */  bt_waitline(bt_fd, line);  /* Send the data */  bt_send(bt_fd, len, repeat);    close(bt_fd);  exit(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -