88
99def discover (timeout = None ):
1010 s = socket .socket (socket .AF_INET , socket .SOCK_DGRAM )
11- s .connect (('8.8.8.8' , 0 )) # connecting to a UDP address doesn't send packets
11+ s .connect (('8.8.8.8' , 53 )) # connecting to a UDP address doesn't send packets
1212 local_ip_address = s .getsockname ()[0 ]
1313 address = local_ip_address .split ('.' )
1414 cs = socket .socket (socket .AF_INET , socket .SOCK_DGRAM )
@@ -140,9 +140,9 @@ def send_packet(self, command, payload):
140140 packet [0x07 ] = 0x55
141141 packet [0x24 ] = 0x2a
142142 packet [0x25 ] = 0x27
143- packet [0x26 ] = command
144- packet [0x28 ] = self .count & 0xff
145- packet [0x29 ] = self .count >> 8
143+ packet [0x26 ] = command
144+ packet [0x28 ] = self .count & 0xff
145+ packet [0x29 ] = self .count >> 8
146146 packet [0x2a ] = self .mac [0 ]
147147 packet [0x2b ] = self .mac [1 ]
148148 packet [0x2c ] = self .mac [2 ]
@@ -167,7 +167,7 @@ def send_packet(self, command, payload):
167167
168168 for i in range (len (payload )):
169169 packet .append (payload [i ])
170-
170+
171171 checksum = 0xbeaf
172172 for i in range (len (packet )):
173173 checksum += packet [i ]
@@ -182,13 +182,13 @@ def send_packet(self, command, payload):
182182 def send_data (self , data ):
183183 packet = bytearray ([0x02 , 0x00 , 0x00 , 0x00 ])
184184 packet += data
185- self .send_packet (0x6a , packet )
185+ self .send_packet (0x6a , packet )
186186
187187 def enter_learning (self ):
188188 packet = bytearray (16 )
189189 packet [0 ] = 3
190- self .send_packet (0x6a , packet )
191-
190+ self .send_packet (0x6a , packet )
191+
192192 def check_sensors (self ):
193193 packet = bytearray (16 )
194194 packet [0 ] = 1
0 commit comments