トップ 差分 一覧 ソース 検索 ヘルプ RSS ログイン

LN-bluetooth

bluez のインストール

zypper install bluez bluez-devel

https://git.kernel.org/pub/scm/bluetooth/bluez.git

python モデュールのインストール

zypper install pybluez boot_python3
pip3 install gattlib 
 ## pip3 install pybluez[ble]  // どっちが正しい??
( boot_python-py34 がないとエラーが出るので
  cd /usr/lib64/ 以下で探す
  boot_python-py3 を
  ln -s boot_python-py3 boot_python-py34 )

Wii Remote

linux is 
https://github.com/RaphaelWimmer/wiimote.py

https://wiibrew.org/wiki/Wiimote

open-suse leap で HC-06 を使う

# hcitool scan
Scanning ...
	00:15:83:35:xx:xx	HC-06
# rfcomm bind rfcomm0 00:15:83:35:xx:xx
###### rfcomm release rfcomm0 
## もしかすると
/etc/bluetooth/rfcomm.conf

が必要かも
内容は

rfcomm0 {
       # Automatically bind the device at startup
       #bind yes;
       bind no;

       # Bluetooth address of the device
       # device 01:23:45:67:89:AB;
       device 00:15:83:35:xx:xx;

       # RFCOMM channel for the connection
       channel 1;
       # channel 3;

       # Description of the connection
       comment "as you like comment";
}
となる
# kermit
set line /dev/rfcomm0 
set speed 9600
connect

#  Kermit の代わりに / screen /dev/rfcomm0 9600
screen /dev/rfcomm0 9600
 (終了 C-a k (Ctrl+aを押した後に k) )

  APENDIX

BluetoothCtl の使い方

# bluetoothctl 
[NEW] Controller 00:15:83:2B:xx:xx linux-crcd [default]
[NEW] Device 00:15:83:35:XX:XX HC-06
[bluetooth]# scan on
Discovery started
[CHG] Controller 00:15:83:2B:xx:xxx Discovering: yes
[CHG] Device 00:15:83:35:xx:xx RSSI: -66
[bluetooth]# pair 00:15:83:35:xx:xx
Attempting to pair with 00:15:83:35:xx:xx
Failed to pair: org.bluez.Error.AlreadyExists
[bluetooth]# trust 00:15:83:35:xx:xx
Changing 00:15:83:35:xx:xx trust succeeded
[bluetooth]# connect 00:15:83:35:xx:xx
Attempting to connect to 00:15:83:35:xx:xx
[CHG] Device 00:15:83:35:xx:xx Connected: yes
Failed to connect: org.bluez.Error.NotAvailable
[CHG] Device 00:15:83:35:xx:xx Connected: no
[bluetooth]# info 00:15:83:35:xx:xx 
Device 00:15:83:35:xx:xx
	Name: HC-06
	Alias: HC-06
	Class: 0x001f00
	Paired: yes
	Trusted: yes
	Blocked: no
	Connected: no
	LegacyPairing: yes
	UUID: Serial Port               (00001101-0000-1000-8000-00xxxxxxxxxxxx)
	RSSI: -66
[bluetooth]# quit

hciconfig の使い方

> hciconfig 
hci0:   Type: Primary  Bus: USB
       BD Address: 00:15:83:2B:XX:XX  ACL MTU: 310:10  SCO MTU: 64:8
       UP RUNNING 
       RX bytes:546 acl:0 sco:0 events:29 errors:0
       TX bytes:379 acl:0 sco:0 commands:29 errors:0

BT2_Classic ??
> hciconfig hci0 version 
hci0:   Type: Primary  Bus: USB
       BD Address: 00:15:83:2B:XX:XX  ACL MTU: 310:10  SCO MTU: 64:8
       HCI Version: 2.0 (0x3)  Revision: 0xc5c
       LMP Version: 2.0 (0x3)  Subversion: 0xc5c
       Manufacturer: Cambridge Silicon Radio (10)

> hciconfig hci0 features 
hci0:   Type: Primary  Bus: USB
       BD Address: 00:15:83:2B:XX:XX  ACL MTU: 310:10  SCO MTU: 64:8
       Features: 0xff 0xff 0x8f 0xfe 0x9b 0xf9 0x00 0x80
               <3-slot packets> <5-slot packets> <encryption> <slot offset> 
               <timing accuracy> <role switch> <hold mode> <sniff mode> 
               <park state> <RSSI> <channel quality> <SCO link> <HV2 packets> 
               <HV3 packets> <u-law log> <A-law log> <CVSD> <paging scheme> 
               <power control> <transparent SCO> <broadcast encrypt> 
               <EDR ACL 2 Mbps> <EDR ACL 3 Mbps> <enhanced iscan> 
               <interlaced iscan> <interlaced pscan> <inquiry with RSSI> 
               <extended SCO> <EV4 packets> <EV5 packets> <AFH cap. slave> 
               <AFH class. slave> <3-slot EDR ACL> <5-slot EDR ACL> 
               <AFH cap. master> <AFH class. master> <EDR eSCO 2 Mbps> 
               <EDR eSCO 3 Mbps> <3-slot EDR eSCO> <extended features> 
BLE の場合
> hciconfig hci0 version 
hci0:   Type: Primary  Bus: USB
       BD Address: 00:09:DD:40:D4:32  ACL MTU: 310:10  SCO MTU: 64:8
       HCI Version: 4.0 (0x6)  Revision: 0x22bb
       LMP Version: 4.0 (0x6)  Subversion: 0x22bb
       Manufacturer: Cambridge Silicon Radio (10)
> hciconfig hci0 features 
hci0:   Type: Primary  Bus: USB
       BD Address: 00:09:DD:40:XX:XX  ACL MTU: 310:10  SCO MTU: 64:8
       Features page 0: 0xff 0xff 0x8f 0xfe 0xdb 0xff 0x5b 0x87
               <3-slot packets> <5-slot packets> <encryption> <slot offset> 
               <timing accuracy> <role switch> <hold mode> <sniff mode> 
               <park state> <RSSI> <channel quality> <SCO link> <HV2 packets> 
               <HV3 packets> <u-law log> <A-law log> <CVSD> <paging scheme> 
               <power control> <transparent SCO> <broadcast encrypt> 
               <EDR ACL 2 Mbps> <EDR ACL 3 Mbps> <enhanced iscan> 
               <interlaced iscan> <interlaced pscan> <inquiry with RSSI> 
               <extended SCO> <EV4 packets> <EV5 packets> <AFH cap. slave> 
               <AFH class. slave> <LE support> <3-slot EDR ACL> 
               <5-slot EDR ACL> <sniff subrating> <pause encryption> 
               <AFH cap. master> <AFH class. master> <EDR eSCO 2 Mbps> 
               <EDR eSCO 3 Mbps> <3-slot EDR eSCO> <extended inquiry> 
               <LE and BR/EDR> <simple pairing> <encapsulated PDU> 
               <non-flush flag> <LSTO> <inquiry TX power> <EPC> 
               <extended features> 
       Features page 1: 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00