request device info

This commit is contained in:
Robert Martin
2020-01-28 23:27:32 +09:00
parent 60ad6298df
commit ed847601cf
7 changed files with 143 additions and 50 deletions
+14 -1
View File
@@ -1,5 +1,6 @@
import asyncio
import logging
import re
logger = logging.getLogger(__name__)
@@ -18,4 +19,16 @@ async def run_system_command(cmd):
if stderr:
logger.debug(f'[stderr]\n{stderr.decode()}')
return proc.returncode
return proc.returncode, stdout, stderr
"""
async def get_bt_mac_address(dev=0):
ret, stdout, stderr = await run_system_command(f'hciconfig hci{dev}')
# TODO: Process error handling
match = re.search(r'BD Address: (?P<mac>\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)', stdout.decode('UTF-8'))
if match:
return list(map(lambda x: int(x, 16), match.group('mac').split(':')))
else:
raise ValueError(f'BD Address not found in "{stdout}"')
"""