Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tools:bluetooth [2023/12/06 06:02] – [Development] darron | tools:bluetooth [2023/12/15 07:48] (current) – [Python] darron | ||
---|---|---|---|
Line 1: | Line 1: | ||
====Bluetooth==== | ====Bluetooth==== | ||
- | |||
- | There are two standards in use known as BT classic and BT low energy. | ||
- | |||
- | Anything other than BLE is considered obsolete now. | ||
- | |||
- | ^HCI / LMP^Version^ | ||
- | |0| 1.0b| | ||
- | |1| 1.1| | ||
- | |2| 1.2| | ||
- | |3| 2.0+EDR| | ||
- | |4| 2.1+EDR| | ||
- | |5| 3.0+HS| | ||
- | |6| 4.0| | ||
- | |7| 4.1| | ||
- | |8| 4.2| | ||
- | |9| 5.0| | ||
- | |10| 5.1| | ||
- | |11| 5.2| | ||
- | |12| 5.3| | ||
- | |||
- | BT 3.0+HS utilises WiFi. BT 4.0 onward is BLE, anything prior is BDR/EDR. | ||
See [[interfaces: | See [[interfaces: | ||
Line 26: | Line 5: | ||
===Services=== | ===Services=== | ||
- | Development has two services | + | Development has two service |
==DBUS== | ==DBUS== | ||
Line 75: | Line 54: | ||
===C development=== | ===C development=== | ||
+ | |||
+ | Development in C is mostly about reading the code examples. | ||
==Headers== | ==Headers== | ||
Line 103: | Line 84: | ||
</ | </ | ||
- | === Test=== | + | == Test== |
- | Test [[: | + | Test [[: |
< | < | ||
Line 134: | Line 115: | ||
</ | </ | ||
+ | LED on/off for demo connection above. | ||
+ | |||
+ | < | ||
+ | [GATT client]# write-value -w 0x000E 0x01 0x01 | ||
+ | Write command sent | ||
+ | [GATT client]# write-value -w 0x000E 0x01 0x00 | ||
+ | Write command sent | ||
+ | [GATT client]# | ||
+ | </ | ||
===Python=== | ===Python=== | ||
+ | |||
+ | It's certainly a lot easier to write code to access BLE devices | ||
+ | in Python and preferred for demo purposes and maybe even | ||
+ | end use cases. | ||
< | < | ||
apt install python3-gattlib | apt install python3-gattlib | ||
</ | </ | ||
+ | |||
+ | Example for the [[: | ||
+ | |||
+ | < | ||
+ | import sys, time | ||
+ | |||
+ | from gattlib import GATTRequester | ||
+ | |||
+ | req = GATTRequester(" | ||
+ | |||
+ | req.connect(True) | ||
+ | |||
+ | for n in range(10): | ||
+ | req.write_cmd(0x000E, | ||
+ | time.sleep(1) | ||
+ | req.write_cmd(0x000E, | ||
+ | time.sleep(1) | ||
+ | |||
+ | req.disconnect() | ||
+ | </ | ||
+ |