diff options
author | John Klug <john.klug@multitech.com> | 2018-06-11 17:01:35 -0500 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2018-06-11 17:01:35 -0500 |
commit | 8037537bc59c59aa8164da2c08598f43718dadf8 (patch) | |
tree | 4389210a4f0a5a1d95d616e089028554f3e421ff /recipes-connectivity/bluez | |
parent | 6809c6fb5c5e8e79d2c00a8fd618a759b86b9060 (diff) | |
download | meta-mlinux-8037537bc59c59aa8164da2c08598f43718dadf8.tar.gz meta-mlinux-8037537bc59c59aa8164da2c08598f43718dadf8.tar.bz2 meta-mlinux-8037537bc59c59aa8164da2c08598f43718dadf8.zip |
Fix up rfcomm daemon to log the name with the Bluetooth address
Diffstat (limited to 'recipes-connectivity/bluez')
-rw-r--r-- | recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py | 65 | ||||
-rw-r--r-- | recipes-connectivity/bluez/bluez5_%.bbappend | 2 |
2 files changed, 7 insertions, 60 deletions
diff --git a/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py b/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py index 360f5f4..e8f2554 100644 --- a/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py +++ b/recipes-connectivity/bluez/bluez5/rfcomm/rfcomm.py @@ -24,6 +24,7 @@ import fcntl import termios import signal import time +import bluetooth # Do we need stty onlcr???? @@ -42,11 +43,7 @@ global needpseudot # Login option and pseudoterminal option needpseudot = False global terminatenow terminatenow = False -# cgitb is in python-misc and requires python-pkgutil and python-pydoc -# It is very usefull for analyzing exceptions. -# import cgitb -# who am i myscript = os.path.basename(__file__) class dopidfile(object): pidPath = "/" @@ -298,68 +295,18 @@ class Profile(dbus.service.Object): self.fd = fd.take() # Extract File Descriptor from dbus UnixFD class. self.path = path - # Complete directory does not exist test + # Bluetooth address portion of the path address = os.path.basename(self.path) + + numaddr = address[address.find("_")+1:] + # Replace _ with : + Name = bluetooth.lookup_name(numaddr.replace("_",":")) - # Search for connected device by address - for localdir in os.listdir(BLUEZLIB): - fp_localdir = BLUEZLIB + '/' + localdir # Full path - lg.debug('Localdir: %s' % (fp_localdir)) - if os.path.isdir(fp_localdir) and localdir.count(':') == 5: - # TBD !!!!! - # Look for fp_localdir + address/info or - # fp_localdir + 'cache' + address - # or get this from bluez somehow using an unknown API. - lg.debug('Localdir is directory and 5 colons: %s' % (fp_localdir)) - # We have MAC address - for clientdir in os.listdir(fp_localdir): - lg.debug('Clientdir is directory: %s' % (clientdir)) - fp_clientdir = fp_localdir + '/' + clientdir - if os.path.isdir(fp_clientdir) and clientdir.count(':') == 5: - lg.debug('Clientdir is directory and 5 colons: %s' % (fp_clientdir)) - infofile = fp_clientdir + '/' + 'info' - lg.debug('infofile: %s' % (infofile)) - try: - file = open(infofile,'r') - lg.debug('Opened info file') - except: - continue - else: - continue - # Have an open file - s = mmap.mmap(file.fileno(),0,access=mmap.ACCESS_READ) - lg.debug('past mmap') - try: - cre = re.compile(br'[General][^[]*\nName=(?P<name>[^\n]*)') - except Exception as e: - lg.debug('Compile failed: %s' % (e)) - lg.debug('past compile') - mname = cre.search(s) - lg.debug('past search') - try: - Name = mname.group('name') - break - except: - Name = 'unknown' - print('NewConnection(%s, %s, %s:%d)' % (path,Name,type(fd).__name__,self.fd)) lg.info('NewConnection(%s, %s, %s:%d)' % (path,Name,type(fd).__name__,self.fd)) atexit.register(self.RequestDisconnection,self.path) lg.debug('Past atexit.register') - # Following code shows noting (why?) - lg.debug('Look for a key len(properties): %d',len(properties)) - for key in properties.keys(): - lg.debug('found a key!!!!!') - lg.debug(' %s = %s' % (key, properties[key])) - if key == 'Version' or key == 'Features': - lg.debug(' %s = 0x%04x' % (key, properties[key])) - lg.debug(' %s = 0x%04x' % (key, properties[key])) - else: - lg.debug(' %s = %s' % (key, properties[key])) - lg.info(' %s = %s' % (key, properties[key])) - lg.debug('Past keys, needpseudot: %s' % (needpseudot)) - # Get a pseudoterminal to provide an I/O driver for # a program that needs a TTY. if needpseudot: diff --git a/recipes-connectivity/bluez/bluez5_%.bbappend b/recipes-connectivity/bluez/bluez5_%.bbappend index c99f5c8..ab89900 100644 --- a/recipes-connectivity/bluez/bluez5_%.bbappend +++ b/recipes-connectivity/bluez/bluez5_%.bbappend @@ -1,4 +1,4 @@ EXTRA_OECONF += "--enable-deprecated --enable-experimental" - +RDEPENDS_${PN}-rfcomm += "python-pybluez" |