def run(self):
"""
Starts phony service which manages device pairing and setting
up of hands-free profile services. This function never returns.
"""
bus = phony.base.ipc.BusProvider()
# Find the first audio card that provides
# audio input and output mixers.
audio_card_index = -1
with phony.bluetooth.adapters.Bluez5(bus) as adapter, \
phony.bluetooth.profiles.handsfree.Ofono(bus) as hfp, \
phony.audio.alsa.Alsa(card_index=audio_card_index) as audio, \
phony.headset.HandsFreeHeadset(bus, adapter, hfp, audio) as hs:
# Register to receive some bluetooth events
hs.on_device_connected(self.device_connected)
hs.on_incoming_call(self.incoming_call)
hs.on_call_began(self.call_began)
hs.on_call_ended(self.call_ended)
hs.start('MyBluetoothHeadset', pincode='1234')
hs.enable_pairability(timeout=30)
self._hs = hs
# Wait forever
gobject.MainLoop().run()
#
# Call these from your event handlers
#
评论列表
文章目录