検索
検索
Sakakibara Hiroshi / 榊󠄀原 寛
文書の表示
以前のリビジョン
トレース:
この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。
[[freebsd-bluetooth]] ---- FreeBSD 7 Release において。\\ usb bluetooth を利用。利用可能なデバイスは Release note 参照。ただし、usb bluetooth はリストに載っていなくても利用できた。チップが rel note に載っているものを利用しているのかもしれない。未調査。 ====== インストール ====== ===== カーネルモジュールをロードする。 ===== * /boot/loader.conf に以下の記述。ブート時に必要なモジュールがロードされるようになる。 <code> ng_ubt_load="YES" </code> * コマンドでやる場合は、次のようにやる。 <code> # kldload ng_ubt </code> ===== いろんなものの起動 ===== <code> # /etc/rc.d/bluetooth start </code> * この後に usb bluetooth を刺す。 ===== hcsecd の準備 ===== * /boot/rc.conf に追加 <code> hcsecd_enable="YES" </code> * pin コードを使うデバイスのために必要なデーモン ===== sdpd の準備 ===== * サービス発見のためのデーモン.後述の obexapp -s でサーバをあげる場合には、これが動いていないと、obexapp は起動しない. * /etc/rc.conf に追加 <code> sdpd_enable="YES" </code> * 自分でデーモンを起動するなら、以下のコマンド <code> # /etc/rc.d/sdpd start </code> ====== スタック ====== ===== HCI ===== * host controller interface * 周辺機器の捜索、自分のアドレス管理、bdアドレスに対応した名前の取得など、デバイスに近いことを司るレイヤー。 ===== l2cap ===== * logical link control and adaptation protocol * アドレスの管理、パケットのセグメンテーション、リアセンブリなど、アドレスとデータグラムの操作を司るレイヤー。 * Maximum Transfer Unit(MTU) サイズはデフォルトで 672bytes. * 最小:48 bytes, 最大:65535 bytes ====== プロファイル ====== * ハンズフリーとヘッドセットは未対応.(2008/07現在) ====== コマンドとか ====== ===== hccontrol ===== * HCI レイヤーに対して命令するためのコマンド ==== hccontrol -n ubt0hci read_bd_addr ==== * 自分の bluetooth address を表示。 ==== hccontrol -n ubt0hci inquiry ==== * 周辺機器を検索。 ==== hccontrol -n ubt0hci read_remote_name_request <bdaddr> ==== * 機器の名前を取得。 ===== obexapp ===== * comms/obexapp をインストール * ファイル転送を行うのに使われるプロトコル。 ==== サーバモード ==== * サーバを起動しておくと、obex でのファイル転送を受け付けられる. <code> # obexapp -s -C 1 -r /var/spool/obex/ </code> * -C <channel number> * -r <directory to store file> * -s : サーバモードであることを指定. ==== クライアントモード ==== * ファイル転送 <code> # obexapp -c -a <bd addr> -C <channel number> -n put <file name> </code> * -n 以下を省略すると、ftp のインタラクティブモードに類似したモードになる。そこで、put <filename> とするとファイル転送が可能となる. ====== プログラミング ====== ===== socket ===== * raw socket 利用 <code> socket(PF_BLUETOOTH, SOCK_RAW, BLUETOOTH_PROTO_HCI); </code> ===== inquiry ===== * 近隣 bluetooth ノードを検索する * デバイスに対して、inquiry することを伝える。 * デバイスが検索してきた結果を受け取る。 ===== 関数 ===== ==== bt_gethostbyaddr() ==== * /etc/bluetooth/hosts をルックアップする。 ===== データ構造 ===== ==== バイトオーダー ==== * bluetooth のバイトオーダは,little endian * (TCP/IP の場合は big endian) ==== 自分のホストのbdアドレスを取得する場合 ==== * socket へは以下のようなデータ構造 <code> +----------------+ |ng_hci_cmd_pkt_t| +----------------+ </code> * socket からは以下のようなデータ構造が返ってくる <code> +-----------------------+ |ng_hci_event_pkt_t | +-----------------------+ |ng_hci_command_compl_ep| +-----------------------+ |ng_hci_read_bdaddr_rp | +-----------------------+ </code> * ng_hci_read_bdaddr_rp <code> #define NG_HCI_OCF_READ_BDADDR 0x0009 typedef struct { u_int8_t status; /* 0x00 - success */ bdaddr_t bdaddr; /* unit address */ } __attribute__ ((packed)) ng_hci_read_bdaddr_rp; </code> ===== ドキュメント ===== * 基本 man とソースコード.freebsd 上での bluetooth programming の資料なんか web には転がってません。 ==== man ==== * man ng_btsocket * bluetooth socket に関するドキュメント
freebsd-bluetooth.txt
· 最終更新: 2012/11/14 14:00 by
127.0.0.1
文書の先頭へ