IanHarvey / bluepy

Python interface to Bluetooth LE on Linux
Other
1.61k stars 490 forks source link

Raspberry Pi Camera and BTLE Conflict #353

Open hteng1995 opened 5 years ago

hteng1995 commented 5 years ago

Hello

I am having an issue when implementing bluepy while also taking photos using the Raspberry Pi Camera (using the python library picamera) on my Raspberry Pi 3B+. In my code, I first scan and connect to a designated bluetooth device, after which I take a photo. After I take this photo, the Raspberry Pi seems to be no longer able to receive messages/notifications from the previously connected peripheral. In addition, when that program completes and returns, I cannot re-scan for more devices when I restart the program, with this error resulting:

rpi_camera_ble_error

I am then able to eliminate this error by power-cycling the Raspberry Pi. However, then the same issue then arises when I run the program. FYI, I am using python's Threading module to create a daemon that runs BLE in a separate thread while the main thread does other tasks like taking photos.

Any feedback or insight into this problem would be very helpful.

Firefox2005 commented 5 years ago

Did you find a solution for that? I am trying to use the camera while doing bluetooth work and am experiencing exactly the same.

Scanning without having started the camera looks like this:

  <  HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7
         Type: Active (0x01)
         Interval: 10.000 msec (0x0010)
         Window: 10.000 msec (0x0010)
         Own address type: Public (0x00)
         Filter policy: Accept all advertisement (0x00)
  >  HCI Event: Command Complete (0x0e) plen 4
         LE Set Scan Parameters (0x08|0x000b) ncmd 1
         Status: Success (0x00)
  <  HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
         Scanning: Enabled (0x01)
         Filter duplicates: Enabled (0x01)
  >  HCI Event: Command Complete (0x0e) plen 4
         LE Set Scan Enable (0x08|0x000c) ncmd 1
         Status: Success (0x00)`

While scanning when the camera was once active looks like this:

 <  HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2                                                                                                                                                                   
         Scanning: Disabled (0x00)
         Filter duplicates: Disabled (0x00)
 <   HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7                                                                                                                                                               
         Type: Passive (0x00)
         Interval: 10.000 msec (0x0010)
         Window: 10.000 msec (0x0010)
         Own address type: Public (0x00)
         Filter policy: Accept all advertisement (0x00)`
Firefox2005 commented 5 years ago

Can be closed. It works fine with an external bluetooth adapter - so this seems to be a hardware related topic.