1. 程式人生 > >藍芽學習 (8)配對raspberryPi和SensorTag CC2650

藍芽學習 (8)配對raspberryPi和SensorTag CC2650

這裡我們利用gatttool來配對。

[email protected]:~ $ gatttool --help
Usage:
  gatttool [OPTION...]

Application Options:
  -i, --adapter=hciX                        Specify local adapter interface
  -b, --device=MAC                          Specify remote Bluetooth address
  -t, --addr-type=[public | random]         Set LE address type. Default: public
  -m, --mtu=MTU                             Specify the MTU size
  -p, --psm=PSM                             Specify the PSM for GATT/ATT over BR/EDR
  -l, --sec-level=[low | medium | high]     Set security level. Default: low
  -I, --interactive                         Use interactive mode
[email protected]:~ $ sudo gatttool -b 54:6C:0E:80:B4:86 --interactive 
[54:6C:0E:80:B4:86][LE]> help
help                                           Show this help
exit                                           Exit interactive mode
quit                                           Exit interactive mode
connect         [address [address type]]       Connect to a remote device
disconnect                                     Disconnect from a remote device
primary         [UUID]                         Primary Service Discovery
included        [start hnd [end hnd]]          Find Included Services
characteristics [start hnd [end hnd [UUID]]]   Characteristics Discovery
char-desc       [start hnd] [end hnd]          Characteristics Descriptor Discovery
char-read-hnd   <handle>                       Characteristics Value/Descriptor Read by handle
char-read-uuid  <UUID> [start hnd] [end hnd]   Characteristics Value/Descriptor Read by UUID
char-write-req  <handle> <new value>           Characteristic Value Write (Write Request)
char-write-cmd  <handle> <new value>           Characteristic Value Write (No response)
sec-level       [low | medium | high]          Set security level. Default: low
mtu             <value>                        Exchange MTU for GATT/ATT
[54:6C:0E:80:B4:86][LE]> 

建立Interactive Session, 讀取溫度值

[54:6C:0E:80:B4:86][LE]> connect
Attempting to connect to 54:6C:0E:80:B4:86
Connection successful
[54:6C:0E:80:B4:86][LE]> char-read-hnd 0x21
Characteristic value/descriptor: 04 00 ad 27 01 11 31 
[54:6C:0E:80:B4:86][LE]> disconnect