gopro / OpenGoPro

An open source interface specification to communicate with a GoPro camera with accompanying demos and tutorials.
https://gopro.github.io/OpenGoPro/
MIT License
690 stars 151 forks source link

List index out of range error when using more than one WiFi #286

Open hhackbarth opened 1 year ago

hhackbarth commented 1 year ago

Component Python SDK

Describe the bug When a second WiFi adapter is attached to the system (in my case Ubuntu 22.04 on RasPi), the procedure to discover the desired WiFi AP terminates with Error while opening: list index out of range (gopro_wireless.py:326) This even happens, when the adapter to be used, is given as command line parameter.

To Reproduce Prerequisite: You need two activated WiFi network adapters (the built-in as 'wlan0' and another one attached via USB). Steps to reproduce the behavior:

  1. Start gopro-wifi using 'gopro-wifi --wifi_interface wlan0'
  2. See error "IndexError: list index out of range"

Expected behavior System should be connected via WiFi adapter wlan0 to GoPro AP.

Hardware

Additional context Current workaround is to unplug the USB WiFi adapter, start the gopro-wifi procedure and after successful connection, plug in the USB WiFi again. index_out_of_range_error.txt

tcamise-gpsw commented 1 year ago

Hello. I don't think the adapter is the problem. The log is showing a failure when searching for the network which indicates it is able to use the adapter.

Can you enable logging of the CLI interface, repeat, and send the log?

To do so, update the util.py logging level in open_gopro\util.py to DEBUG:

   self.modules = {
            "open_gopro.gopro_base": logging.DEBUG,  # TRACE for raw HTTP responses
            "open_gopro.gopro_wired": logging.DEBUG,  # TRACE for concurrency debugging
            "open_gopro.gopro_wireless": logging.DEBUG,  # TRACE for concurrency debugging
            "open_gopro.api.builders": logging.DEBUG,
            "open_gopro.api.http_commands": logging.DEBUG,
            "open_gopro.api.ble_commands": logging.DEBUG,
            "open_gopro.communication_client": logging.DEBUG,
            "open_gopro.ble.adapters.bleak_wrapper": logging.INFO,
            "open_gopro.ble.client": logging.DEBUG,
            "open_gopro.wifi.adapters.wireless": logging.DEBUG,
            "open_gopro.responses": logging.DEBUG,
            "open_gopro.util": logging.DEBUG,
            "bleak": logging.ERROR,
            "urllib3": logging.WARNING,
            "http.client": logging.WARNING,
        }
hhackbarth commented 1 year ago

Thanks for your quick answer. It is a problem with multiple adapters. The log only shows that it is searching for the SSID retrieved via BLE but during this search procedure it terminates, when there are multiple adapters.

I attached two logs taken with logging level DEBUG for util.py. The logfile "index_out_of_range.txt" shows the output, when two wifi network adapters are active. The other file "no_error.txt" shows the log output, when only one adapter (wlan0) is active. In that case everything goes fine and it proves that it is a problem with multiple wifi adapters.

I think it would be much easier for you to trace what happens, if you attach a second (USB) WiFi adapter to your test system as well. The console output of my first post also contained the stack trace so it may show you more details, where the error happens.

I definitely would prefer to use only one adapter and let the GoPro work in station mode (as wiFi client). It would be much easier to transcode and provide the stream to my other systems as desired, but as this is currently not supported by GoPro 11, we have to live with multiple adapters.

index_out_of_range_error.txt no_error.txt

tcamise-gpsw commented 1 year ago

The error log is not actually showing the debug logging. I can't say why this...maybe you didn't install the package in editable mode. Anyway, I will try to replicate at some point on my ubuntu machine

hhackbarth commented 1 year ago

I edited the util.py and ran afterwards from the OpenGoPro/demos/python/sdk_wireless_camera_control folder: python3 open_gopro/demos/connect_wifi.py --wifi_interface wlan0 So I assumed, that the modified util.py was used. Otherwise, perhaps a new installation like "pip3 install ." is required to make use of the modified util.py?

Anyway, I think it makes much more sense, if you test that with a second USB WiFi adapter by yourself. With my description it should be easily reproducable.

tcamise-gpsw commented 10 months ago

I do not have a setup to test this functionally. I'll try writing unit tests with multiple adapters to see if I can replicate.