Skip to content

Commit

Permalink
Merge pull request #61 from svvitale/delay-beep-until-on-connect-comp…
Browse files Browse the repository at this point in the history
…letes

Perform the on-connect callback prior to beeping and flashing the LED…
  • Loading branch information
nehpetsde committed May 2, 2017
2 parents 3d7721f + c662c62 commit bf5aba1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/nfc/clf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,10 @@ def connect(self, **options):
beer.
'beep-on-connect': boolean
If the device supports beeping or flashing an LED, automatically
perform this functionality when a tag is successfully detected.
Defaults to True.
If the device supports beeping or flashing an LED,
automatically perform this functionality when a tag is
successfully detected AND the 'on-connect' function
returns a true value. Defaults to True.
.. sourcecode:: python
Expand Down Expand Up @@ -607,15 +608,14 @@ def _rdwr_connect(self, options, terminate):
tag = nfc.tag.activate(self, target)
if tag is not None:
log.debug("connected to {0}".format(tag))
if options['beep-on-connect']:
self.device.turn_on_led_and_buzzer()
if options['on-connect'](tag):
if options['beep-on-connect']:
self.device.turn_on_led_and_buzzer()
while not terminate() and tag.is_present:
time.sleep(0.1)
self.device.turn_off_led_and_buzzer()
return options['on-release'](tag)
else:
self.device.turn_off_led_and_buzzer()
return tag

def _llcp_connect(self, options, terminate):
Expand Down

0 comments on commit bf5aba1

Please sign in to comment.