BlueZ

sockaddr_rc構造体

struct sockaddr_rcに値をセットしてbindに渡して、listenして、acceptするのを待つ。./bluetooth/rfcomm.txtacceptを抜けたら、acceptにも渡しておいたstruct sockaddr_rcにリモート側の情報が入っている。 struct_sockaddr_rc.cで、acceptを抜けたら、リモ…

AF_BLUETOOTH

AF_BLUETOOTHは、Bluetoothのアドレスファミリーということ。http://people.csail.mit.edu/albert/bluez-intro/x502.htmlbindする時もsockaddr_rcで使う。local_addr.rc_familyにもAF_BLUETOOTHを指定。 sockaddr_rcは、BluetoothというかRFCOMM用のsockaddr…

BTPROTO_RFCOMM

Linux側に戻る。 スキャンは出来たので、今度はLinux側のサーバと、Android側のクライアントで、SPP通信をする。 サーバ側はBlueZでRFCOMM通信をするわけなので、BTPROTO_RFCOMMを指定する。./bluetooth/rfcomm.txt http://people.csail.mit.edu/albert/blue…

hci_read_remote_name

hci_read_remote_nameで、Bluetooth機器名を取得する。http://people.csail.mit.edu/albert/bluez-intro/c404.htmlhci_read_remote_name.cで、device_nameにBluetooth機器名が格納。 機器名取れました機器名取れました。Sample/bluez/hci_read_remote_name/h…

ba2str

ba2strで、Bluetoothアドレスであるinquiry_infoのbdaddrを文字列に変換できる。http://people.csail.mit.edu/albert/bluez-intro/c404.htmlba2str.cで、num_rspの分だけ繰り返す。 bdaddr.bの各要素を出力する場合と、ba2strで一気に文字列に変換して出力す…

hci_inquiry

hci_inquiryで、接続先情報リストを取得する。http://people.csail.mit.edu/albert/bluez-intro/c404.htmlhci_inquiry.cで、mallocで255個分のinquiry_infoのリストのメモリを確保。 hci_inquiryに渡すと、中にinquiry_infoのリストが入ってる。 戻り値のnum…

hci_open_dev

hci_open_devで、デバイスIDからBluetoothソケットを開く。http://people.csail.mit.edu/albert/bluez-intro/c404.htmlhci_open_dev.cで、dev_idを取得し、hci_open_devに渡すと、socが返る。 これがBluetoothソケットファイルディスクリプタ。 $ vi hci_ope…

hci_get_route

ここから、LinuxでBluetooth通信をしてみる。 まず、Bluetoothを使えるように設定とか準備する。 FedoraがVirtualBoxなので、Windows側で、 検索などでBluetooth設定を出す検索などでBluetooth設定を出す。 まあ、オンになっていて発見可能なら良し。まあ、…