Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error from Bluetooth stack #2

Open
adrianmoisey opened this issue Apr 24, 2016 · 4 comments
Open

Error from Bluetooth stack #2

adrianmoisey opened this issue Apr 24, 2016 · 4 comments

Comments

@adrianmoisey
Copy link

Hi

I'm attempting to get igrill setup to monitor my iGrill Mini.
I've setup a virtualenv with all the required libraries, I've also edited main.py with my device's address, but I get this error when running:

# python main.py 
Creating Scanner
Connecting to InfluxDB server
Scanning...
Authenticating...
Traceback (most recent call last):
  File "main.py", line 36, in <module>
    scanner.scan(30)
  File "/home/pi/igrill/virtualenv/src/bluepy/bluepy/btle.py", line 632, in scan
    self.process(timeout)
  File "/home/pi/igrill/virtualenv/src/bluepy/bluepy/btle.py", line 621, in process
    self.delegate.handleDiscovery(dev, (dev.updateCount <= 1), isNewData)
  File "/home/pi/igrill/scan.py", line 10, in handleDiscovery
    handler.handleDiscovery(scanEntry, isNewDev, isNewData)
  File "/home/pi/igrill/igrill.py", line 43, in handleDiscovery
    dev = IGrillMiniPeripheral(scanEntry.addr)
  File "/home/pi/igrill/igrill.py", line 147, in __init__
    IDevicePeripheral.__init__(self, address)
  File "/home/pi/igrill/igrill.py", line 92, in __init__
    if not self.authenticate():
  File "/home/pi/igrill/igrill.py", line 114, in authenticate
    self.characteristic(UUIDS.APP_CHALLENGE).write(challenge, True)
  File "/home/pi/igrill/virtualenv/src/bluepy/bluepy/btle.py", line 148, in write
    self.peripheral.writeCharacteristic(self.valHandle, val, withResponse)
  File "/home/pi/igrill/virtualenv/src/bluepy/bluepy/btle.py", line 459, in writeCharacteristic
    return self._getResp('wr')
  File "/home/pi/igrill/virtualenv/src/bluepy/bluepy/btle.py", line 334, in _getResp
    resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
  File "/home/pi/igrill/virtualenv/src/bluepy/bluepy/btle.py", line 296, in _waitResp
    raise BTLEException(BTLEException.COMM_ERROR, "Error from Bluetooth stack (%s)" % errcode)
bluepy.btle.BTLEException: Error from Bluetooth stack (comerr)

Any idea what I'm doing wrong?
Thanks

@kvantetore
Copy link
Owner

Unfortunately, no. Perhaps wrong version of bluez? The linux bluetooth stack is in a pretty sad state. The bluez team hasn't prioritized libraries much, and much of the needed bits are private. So most of the bluetooth stuff I've found have copied the pertinent parts of bluez into the project, which makes everything quite brittle :(

@bjoernhoefer
Copy link

bjoernhoefer commented Apr 6, 2017

Hi,

I'm getting almost the same thing on an raspberrypi

Creating Scanner
Connecting to InfluxDB server
Scanning...

Message from syslogd@rpi01 at Apr  6 20:23:58 ...
 kernel:[  386.883576] Internal error: Oops: 17 [#1] PREEMPT SMP ARM
Traceback (most recent call last):
  File "main.py", line 41, in <module>
    scanner.scan(30)
  File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 632, in scan

Message from syslogd@rpi01 at Apr  6 20:23:58 ...
 kernel:[  386.998979] Process bluepy-helper (pid: 1103, stack limit = 0xaf106210)

Message from syslogd@rpi01 at Apr  6 20:23:58 ...
 kernel:[  387.005579] Stack: (0xaf107ee8 to 0xaf108000)

Message from syslogd@rpi01 at Apr  6 20:23:58 ...
 kernel:[  387.009930] 7ee0:                   b90588cc b69f8800 af107f34 af107f00 7f1e2c18 8054a328

Message from syslogd@rpi01 at Apr  6 20:23:58 ...
 kernel:[  387.018094] 7f00: af106000 b69fac00 b69fac58 00000004 af107f34 b69fac00 b69fb800 00000004

Message from syslogd@rpi01 at Apr  6 20:23:58 ...
 kernel:[  387.026258] 7f20: 7efd8988 7efd8988 af107f6c af107f38 7f1de5d0 7f1e2ba4 af107f54 af100002

Message from syslogd@rpi01 at Apr  6 20:23:58 ...
 kernel:[  387.034422] 7f40: 8015b4f4 8015b464 af107f6c 00000002 00000112 b622e900 00000004 7efd8988

Message from syslogd@rpi01 at Apr  6 20:23:58 ...
 kernel:[  387.042587] 7f60: af107fa4 af107f70 80455aac 7f1ddfac 00000002 7efd89ec 00000000 00000000

Message from syslogd@rpi01 at Apr  6 20:23:58 ...
 kernel:[  387.050751] 7f80: 00000000 00000002 7efd8a84 00000000 00000126 8000ece8 00000000 af107fa8
    self.process(timeout)
  File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 621, in process

Message from syslogd@rpi01 at Apr  6 20:23:58 ...
 kernel:[  387.058915] 7fa0: 8000eae0 80455a48 00000002 7efd8a84 00000005 00000112 00000004 7efd8988

Message from syslogd@rpi01 at Apr  6 20:23:58 ...
 kernel:[  387.067078] 7fc0: 00000002 7efd8a84 00000000 00000126 00000000 00000000 00000000 00000000
    self.delegate.handleDiscovery(dev, (dev.updateCount <= 1), isNewData)
  File "/usr/src/igrill-master/scan.py", line 10, in handleDiscovery

Message from syslogd@rpi01 at Apr  6 20:23:58 ...
 kernel:[  387.075243] 7fe0: 00040234 7efd8978 000243e0 76d45500 80000010 00000005 00000000 00000000

Message from syslogd@rpi01 at Apr  6 20:23:58 ...
 kernel:[  387.121183] Code: e8bd4000 e1a04000 f57ff05b f590f000 (e1903f9f) 
    handler.handleDiscovery(scanEntry, isNewDev, isNewData)
  File "/usr/src/igrill-master/igrill.py", line 43, in handleDiscovery
    dev = IGrillMiniPeripheral(scanEntry.addr)
  File "/usr/src/igrill-master/igrill.py", line 147, in __init__
    IDevicePeripheral.__init__(self, address)
  File "/usr/src/igrill-master/igrill.py", line 86, in __init__
    self.setSecurityLevel("medium")
  File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 463, in setSecurityLevel
    return self._getResp('stat')
  File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 334, in _getResp
    resp = self._waitResp(wantType + ['ntfy', 'ind'], timeout)
  File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 281, in _waitResp
    resp = BluepyHelper.parseResp(rv)
  File "/usr/local/lib/python2.7/dist-packages/bluepy/btle.py", line 246, in parseResp
    (tag, tval) = item.split('=')
ValueError: need more than 1 value to unpack
Exception IOError: (32, 'Broken pipe') in <bound method IGrillMiniPeripheral.__del__ of <igrill.IGrillMiniPeripheral instance at 0x763e9418>> ignored

I've made some minor changes in code - as I have an iGrill v2:

in tokencube.py - line 15 - if len(data) < 7 or data[0] != 0x75 or data[1] != 0x0:
in periphals.py - line 34 - if name == "iGrill_V2":
in igrill.py - line 34 - if name != "iGrill_V2" or not isNewDev:

Which version of bluez did you use - maybe it can be solved by "downgrading"

@bjoernhoefer
Copy link

After the initial - error everything works "fine" now... reboot fixed it...

@ghost
Copy link

ghost commented Apr 12, 2017

What version of bluez did you end up using to get this working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants