about summary refs log tree commit diff
path: root/broadlink
diff options
context:
space:
mode:
authorMatthew Garrett <mjg59@coreos.com>2016-11-04T22·33-0600
committerGitHub <noreply@github.com>2016-11-04T22·33-0600
commit0b9dd40921ae3f3e6b95d19a4a13e5060932831a (patch)
tree58e9a5f9990aa708c6084c09f99e85ef87d843cd /broadlink
parent925742768d6e84558fcb99b30ca448103392aeff (diff)
parentbd1c44488d1bc419ca98fe8a2bbdf9d299b9773d (diff)
Merge pull request #11 from kelvl/macos-cant-assign-address-fix
Fix for [Errno 49] Can't assign requested address
Diffstat (limited to 'broadlink')
-rwxr-xr-xbroadlink/__init__.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/broadlink/__init__.py b/broadlink/__init__.py
index edd5f24bfede..8e38c06df63f 100755
--- a/broadlink/__init__.py
+++ b/broadlink/__init__.py
@@ -8,7 +8,7 @@ import socket
 
 def discover(timeout=None):
   s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-  s.connect(('8.8.8.8', 0))  # connecting to a UDP address doesn't send packets
+  s.connect(('8.8.8.8', 53))  # connecting to a UDP address doesn't send packets
   local_ip_address = s.getsockname()[0]
   address = local_ip_address.split('.')
   cs = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@@ -140,9 +140,9 @@ class device:
     packet[0x07] = 0x55
     packet[0x24] = 0x2a
     packet[0x25] = 0x27
-    packet[0x26] = command 
-    packet[0x28] = self.count & 0xff 
-    packet[0x29] = self.count >> 8 
+    packet[0x26] = command
+    packet[0x28] = self.count & 0xff
+    packet[0x29] = self.count >> 8
     packet[0x2a] = self.mac[0]
     packet[0x2b] = self.mac[1]
     packet[0x2c] = self.mac[2]
@@ -167,7 +167,7 @@ class device:
 
     for i in range(len(payload)):
       packet.append(payload[i])
-    
+
     checksum = 0xbeaf
     for i in range(len(packet)):
       checksum += packet[i]
@@ -182,13 +182,13 @@ class device:
   def send_data(self, data):
     packet = bytearray([0x02, 0x00, 0x00, 0x00])
     packet += data
-    self.send_packet(0x6a, packet) 
+    self.send_packet(0x6a, packet)
 
   def enter_learning(self):
     packet = bytearray(16)
     packet[0] = 3
-    self.send_packet(0x6a, packet) 
-    
+    self.send_packet(0x6a, packet)
+
   def check_sensors(self):
     packet = bytearray(16)
     packet[0] = 1