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

Possible to choose which interface to search on? #31

Open
MarekRzewuski opened this issue Apr 6, 2017 · 3 comments
Open

Possible to choose which interface to search on? #31

MarekRzewuski opened this issue Apr 6, 2017 · 3 comments

Comments

@MarekRzewuski
Copy link

Hello,
I'm running VirtualBox sharing USB WIFI-dongle as Bridged Adapter from Windows. My virtualbox seems to have two network cards.

Also when running on Raspberry PI I have 3 network cards (1 wired and 2 WIFI).

By default dump_camera_capabilities.py does not find any camera. I need to modify __bind_sockets() and add .bind() to choose which interface should be searched. Like this:

    self.__udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    self.__udp_socket.bind(('192.168.122.178',0))
    self.__udp_socket.settimeout(0.1)

192.168.122.178 is IP which I get from camera.

Is there a way to search all interfaces and select which camera should be used?
I guess there may be several cameras found on different interfaces.

@Bloodevil
Copy link
Owner

I never tried on VM but I think you can connect manually. and searching is not working properly (There are many issues on camera side. even if you didn't use VM

@mungewell
Copy link
Contributor

You could try the attached patch, attempts do a discovery on each interface in turn.

For me (Xubuntu) this doesn't work as it return all the interfaces with the same IP. This 'glitch' is noted here:
https://groups.google.com/forum/#!topic/comp.lang.python/tF-SXWvBVjk

Netdisco (https://github.com/home-assistant/netdisco) finds all camera attached on multiple interfaces, using 'netifaces'. But not sure we want to put added requirements on the code.
patch.txt

@nurupo
Copy link

nurupo commented May 5, 2020

Had the same issue. pysony wasn't able to find the camera until I told it to broadcast on the right network interface with the bind():

diff --git a/src/pysony.py b/src/pysony.py
index 6e7d845..931e812 100755
--- a/src/pysony.py
+++ b/src/pysony.py
@@ -44,6 +44,7 @@ class ControlPoint(object):
         sock.settimeout(0.1)
         # Set the socket to broadcast mode.
         sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)
+        sock.bind(('10.0.1.1', 0))
         self._udp_socket = sock
 
     def close(self):

10.0.1.1 is the address assigned to my machine by camera's access point.

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

4 participants