Linux側に戻る。
スキャンは出来たので、今度はLinux側のサーバと、Android側のクライアントで、SPP通信をする。
サーバ側はBlueZでRFCOMM通信をするわけなので、BTPROTO_RFCOMMを指定する。
./bluetooth/rfcomm.txt
http://people.csail.mit.edu/albert/bluez-intro/x502.html
BTPROTO_RFCOMM.cで、
socketにAF_BLUETOOTHとBTPROTO_RFCOMMを指定。
まずはsocが出来ればいい。
$ pwd /home/bg1/project/cloud/github.com/Sample/bluez/BTPROTO_RFCOMM/BTPROTO_RFCOMM/src/BTPROTO_RFCOMM $ vi BTPROTO_RFCOMM.c $ ls BTPROTO_RFCOMM.c $ gcc -o BTPROTO_RFCOMM BTPROTO_RFCOMM.c -lbluetooth $ ls BTPROTO_RFCOMM BTPROTO_RFCOMM.c $ ./BTPROTO_RFCOMM soc = 3 $
socは3。
とりあえずソケットは作成できた。
Sample/bluez/BTPROTO_RFCOMM/BTPROTO_RFCOMM/src/BTPROTO_RFCOMM at master · bg1bgst333/Sample · GitHub