def call_requester_node(): username = pwd.getpwuid(os.getuid()).pw_name fqdn = socket.getfqdn() my_sip_address = "sip:" + username + "@" + fqdn rospy.init_node('call_requester') audio_device_id = rospy.get_param('audio_device', 'ALSA: default device') phone = Linphone( audio_dev_id = audio_device_id, termination_condition = rospy.is_shutdown ) phone.autoanswer() try: while not rospy.is_shutdown(): request_call( my_sip_address ) if phone.in_a_call(): print "Call started." rospy.sleep(.1) while phone.in_a_call() and not rospy.is_shutdown(): rospy.sleep(.1) print "Call ended." except rospy.ROSInterruptException: print "Interrupt!" except IOError as ioerr: if ioerr.errno == errno.EINTR: print "Interrupt!" else: raise
def __init__(self): path = roslib.packages.get_pkg_dir("qbo_linphone") rospy.init_node('autocaller') audio_device_id = rospy.get_param('audio_device', 'ALSA: default device') host = rospy.get_param('linphone_host', '127.0.0.1') #host = "192.168.1.35" botName = rospy.get_param('linphone_botName', 'default_botName_linphone') print "LINPHONE " + botName + "@" + host #reconfiguramos el fichero de configuracion /config/linphonc.in part2 = open(path + "/config/linphonerc_part2.in", 'r') shutil.copyfile(path + "/config/linphonerc_part1.in", path + "/config/linphonerc.in") configFile = open(path + "/config/linphonerc.in", 'a') configFile.write("reg_identity=sip:" + botName + "@" + host + "\n") for line in part2: configFile.write(line) part2.close configFile.close self.phone = Linphone(audio_dev_id=audio_device_id, termination_condition=rospy.is_shutdown, _host=host, _botName=botName) call_service = rospy.Service('autocaller', CallMe, self.handle_call_me) print "Ready to call."