@@ -225,14 +225,17 @@ async def _wait_for_bootup():
225225 except asyncio .TimeoutError :
226226 raise NmtError ("Timeout waiting for boot-up message" )
227227
228- def add_hearbeat_callback (self , callback : Callable [[int ], None ]):
228+ def add_heartbeat_callback (self , callback : Callable [[int ], None ]):
229229 """Add function to be called on heartbeat reception.
230230
231231 :param callback:
232232 Function that should accept an NMT state as only argument.
233233 """
234234 self ._callbacks .append (callback )
235235
236+ # Compatibility with previous typo
237+ add_hearbeat_callback = add_heartbeat_callback
238+
236239 def start_node_guarding (self , period : float ):
237240 """Starts the node guarding mechanism.
238241
@@ -289,29 +292,29 @@ def send_command(self, code: int) -> None:
289292
290293 def on_write (self , index , data , ** kwargs ):
291294 if index == 0x1017 :
292- hearbeat_time , = struct .unpack_from ("<H" , data )
293- if hearbeat_time == 0 :
295+ heartbeat_time , = struct .unpack_from ("<H" , data )
296+ if heartbeat_time == 0 :
294297 self .stop_heartbeat ()
295298 else :
296- self .start_heartbeat (hearbeat_time )
299+ self .start_heartbeat (heartbeat_time )
297300
298301 def start_heartbeat (self , heartbeat_time_ms : int ):
299- """Start the hearbeat service.
302+ """Start the heartbeat service.
300303
301- :param hearbeat_time
304+ :param heartbeat_time_ms
302305 The heartbeat time in ms. If the heartbeat time is 0
303306 the heartbeating will not start.
304307 """
305308 self ._heartbeat_time_ms = heartbeat_time_ms
306309
307310 self .stop_heartbeat ()
308311 if heartbeat_time_ms > 0 :
309- logger .info ("Start the hearbeat timer, interval is %d ms" , self ._heartbeat_time_ms )
312+ logger .info ("Start the heartbeat timer, interval is %d ms" , self ._heartbeat_time_ms )
310313 self ._send_task = self .network .send_periodic (
311314 0x700 + self .id , [self ._state ], heartbeat_time_ms / 1000.0 )
312315
313316 def stop_heartbeat (self ):
314- """Stop the hearbeat service."""
317+ """Stop the heartbeat service."""
315318 if self ._send_task is not None :
316319 logger .info ("Stop the heartbeat timer" )
317320 self ._send_task .stop ()
0 commit comments