def run(self):
while not self.quit:
button_pressed = False
if 0 != BUTTONPIN:
button_pressed = not GPIO.input(BUTTONPIN)
if button_pressed and self.core.current_call is None:
# We do not check the time here. They can keep "ringing" the doorbell if they want
# but it won't matter once a call is initiated.
if self.doorbell_sound:
self.doorbell_sound.play()
try:
if time.time() - self.lastMessageTicks > WAITSECONDS:
self.notify_chat_contacts(message_template="Doorbell ring on %s at %s")
params = self.core.create_call_params(None)
params.audio_enabled = True
params.video_enabled = True
params.audio_multicast_enabled = False # Set these = True if you want multiple
params.video_multicast_enabled = False # people to connect at once.
address = linphone.Address.new(doorbellToAddress)
logging.info('address = {address}, used_video_codec = {codec}'.format(
address=address,
codec=params.used_video_codec))
self.current_call = self.core.invite_address_with_params(address, params)
if None is self.current_call:
logging.error("Error creating call and inviting with params... outgoing call aborted.")
if time.time() - self.lastEmailTicks >= WAITEMAILSECONDS:
if LEDPINDOORBELL:
self.flash_led(ledpin=LEDPINDOORBELL, stay_on=True,
blink_cam_led=False, delay=0.25, blink_count=8)
else:
self.flash_led()
self.notify_email_contacts()
except KeyboardInterrupt:
self.quit = True
break
elif detectMotion and self.core.current_call is None:
motion_detected = False
# Incoming calls have been handled, so check the motion detector:
if 0 != PIRPIN:
# motion_detected = GPIO.wait_for_edge(PIRPIN,GPIO.RISING)
# motion_detected = GPIO.event_detected(PIRPIN)
motion_detected = GPIO.input(PIRPIN)
logging.debug("\rmotion_detected = %s, GPIO.input(PIRPIN) = %s" % (
str(motion_detected), str(GPIO.input(PIRPIN))))
elif 0 != MDPIN:
motion_detected = GPIO.input(MDPIN) == 0
if motion_detected:
self.motion_detected()
# else:
# time.sleep(0.01) #
self.core.iterate()
security_camera.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录