ネトサバ日記

インフラに関する投稿をしていきます

pythonでBLE

自宅車が今駐車場にあるかどうかをBLEタグを使って検知しようと思う
とりあえず今回はRaspberry Piに BLE環境を整えるまでを

PythonでBLE使うためには、Boost Pythonとglibが必要みたいでそれがややこしかった

apt installパッケージ


pip installするパッケージ
  • pybluez
  • pybluez[ble]
pybluez[ble]はpybluezのエクステンション

[{'end': 7, 'start': 1, 'uuid': '00001800-0000-1000-8000-00805f9b34fb'},
 {'end': 10, 'start': 8, 'uuid': '00001803-0000-1000-8000-00805f9b34fb'},
 {'end': 13, 'start': 11, 'uuid': '00001802-0000-1000-8000-00805f9b34fb'},
 {'end': 16, 'start': 14, 'uuid': '00001804-0000-1000-8000-00805f9b34fb'},
 {'end': 65535, 'start': 17, 'uuid': '0000180f-0000-1000-8000-00805f9b34fb'}]
[{'handle': 2,
  'properties': 2,
  'uuid': '00002a00-0000-1000-8000-00805f9b34fb',
  'value_handle': 3},
 {'handle': 4,
  'properties': 2,
  'uuid': '00002a01-0000-1000-8000-00805f9b34fb',
  'value_handle': 5},
 {'handle': 6,
  'properties': 2,
  'uuid': '00002a04-0000-1000-8000-00805f9b34fb',
  'value_handle': 7},
 {'handle': 9,
  'properties': 10,
  'uuid': '00002a06-0000-1000-8000-00805f9b34fb',
  'value_handle': 10},
 {'handle': 12,
  'properties': 4,
  'uuid': '00002a06-0000-1000-8000-00805f9b34fb',
  'value_handle': 13},
 {'handle': 15,
  'properties': 2,
  'uuid': '00002a07-0000-1000-8000-00805f9b34fb',
  'value_handle': 16},
 {'handle': 18,
  'properties': 2,
  'uuid': '00002a19-0000-1000-8000-00805f9b34fb',
  'value_handle': 19},
 {'handle': 20,
  'properties': 2,
  'uuid': '00002a1a-0000-1000-8000-00805f9b34fb',
  'value_handle': 21},
 {'handle': 22,
  'properties': 18,
  'uuid': '00002a1b-0000-1000-8000-00805f9b34fb',
  'value_handle': 23},
 {'handle': 25,
  'properties': 2,
  'uuid': '00002a3a-0000-1000-8000-00805f9b34fb',
  'value_handle': 26}]

00002a00-0000-1000-8000-00805f9b34fb ['BSBT4PT02BK']
00002a01-0000-1000-8000-00805f9b34fb ['\x00\x02']
00002a04-0000-1000-8000-00805f9b34fb ['\n\x00\n\x00\xc0\x00\xe8\x03']
00002a06-0000-1000-8000-00805f9b34fb ['\x00']
00002a06-0000-1000-8000-00805f9b34fb ['\x00']
00002a07-0000-1000-8000-00805f9b34fb ['\x04']
00002a19-0000-1000-8000-00805f9b34fb ['R']
00002a1a-0000-1000-8000-00805f9b34fb ['\x9f']
00002a1b-0000-1000-8000-00805f9b34fb ['R\x9f']
00002a3a-0000-1000-8000-00805f9b34fb ['\x02']