Beispiel #1
0
 def dtmf_received(self, core, call, digits):
     logging.debug('on_dtmf_digit (%s)', str(digits))
     print("#\n" * 10)
     print("OPEN DOOR!")
     print("#\n" * 10)
     os.system('aplay /home/pi/sounds/OPEN_DOOR.wav')
     pulse_relay()
Beispiel #2
0
    def run(self):
        while not self.quit:
            # Check the push buttons
            button_call_pressed = False
            button_select_pressed = False
            button_door_pressed = False

            if 0 != CALL_BUTTON_PIN:
                button_call_pressed = not GPIO.input(CALL_BUTTON_PIN)

            if 0 != DOOR_BUTTON_PIN:
                button_door_pressed = not GPIO.input(DOOR_BUTTON_PIN)

            if button_door_pressed:
                os.system('aplay /home/pi/sounds/OPEN_DOOR.wav')
                pulse_relay()

            if button_call_pressed and self.core.current_call is None:
                pulse_relay(DOORBELL_PIN, delay=0.2, invert=True)
                # 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.
                print('Call button pressed!')

                try:
                    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)
                    self.core.play_local(doorBellSoundWav)
                    self.current_call = self.core.invite_address_with_params(
                        address, params)
                    flash_led(delay=0.2, stay_on=True)

                    if None is self.current_call:
                        logging.error(
                            'Error creating call and inviting with params... outgoing call aborted.'
                        )

                except KeyboardInterrupt:
                    self.quit = True
                    break

            # Iterate
            self.core.iterate()
            time.sleep(0.03)
Beispiel #3
0
def main():

    try:
        reader = ReaderMFRC522()
        while True:
            uid = reader.read_with_block(
            )[:
              -2]  # Have to discard two last digits for this implementation purpose
            os.system('aplay /home/pi/sounds/RFID_DETECTED.wav')
            print(uid)
            status = request_unlock(uid)
            print(status)
            if (status == 0):
                print("Authorized")
                os.system('aplay /home/pi/sounds/OPEN_DOOR.wav')
                pulse_relay()
            else:
                os.system('aplay /home/pi/sounds/ERROR.wav')
                print("Auth error")
    except:
        print("RFID error")
def main():

    try:
        rdr = RFID()
        while True:
            rdr.wait_for_tag()
            (error, tag_type) = rdr.request()
            if not error:
                print("Tag detected")
                (error, uid_list) = rdr.anticoll()
                if not error:
                    uid = ''
                    for element in uid_list:
                        uid += str(hex(element)[2:]).upper()
                    print("UID: " + uid)
                    status = request_unlock(uid)
                    if status == 0:
                        print("Authorized")
                        pulse_relay()
                        time.sleep(3)
                    else:
                        print("Auth error")
    except:
        rdr.cleanup()
 def dtmf_received(self, core, call, digits):
     logging.debug('on_dtmf_digit (%s)', str(digits))
     print("OPEN DOOR!")
     pulse_relay()