Mercurial > code > home > repos > homeauto
view service/bluetoothButtons/bluetooth_buttons.py @ 1513:c829df2b0dd5
new graph output for browsers, with autorefresh
Ignore-this: e4ff4dbed311b238d90988a1891ef640
darcs-hash:ba19d0d8975104ec6a3580e50cf8b7ca7745abdc
author | drewp <drewp@bigasterisk.com> |
---|---|
date | Mon, 03 Feb 2020 23:47:23 -0800 |
parents | 80397afd5b52 |
children |
line wrap: on
line source
import hidraw import os import requests import json fileno = os.open('/dev/hidraw0', os.O_RDWR) h = hidraw.HIDRaw(fileno) keys = { b'\x02\xb6\x00': 'left', b'\x02\xe9\x00': 'top', b'\x02\xb5\x00': 'right', b'\x02\xcd\x00': 'middle', } while True: buf = os.read(fileno, 16) print('got %r' % buf) addr = h.getPhysicalAddress().decode('ascii') if buf in keys: msg = {'addr': addr, 'key': keys[buf]} print(msg) requests.post('http://bang6:10011/bluetoothButton', data=json.dumps(msg)) # to use port 10014