about summary refs log tree commit diff
path: root/broadlink
diff options
context:
space:
mode:
authorKelvin Law <calvin18@gmail.com>2016-11-03T03·34-0700
committerKelvin Law <calvin18@gmail.com>2016-11-03T03·34-0700
commitbd1c44488d1bc419ca98fe8a2bbdf9d299b9773d (patch)
tree58e9a5f9990aa708c6084c09f99e85ef87d843cd /broadlink
parent925742768d6e84558fcb99b30ca448103392aeff (diff)
Fix for [Errno 49] Can't assign requested address
Fixes #3 on macOS
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