def serve(self, socket):
"""
This works a little differently from a normal server:
1. We tell the car that we support HFP over SDP
2. We wait for the car to connect to us to get its MAC address
the connection the car makes is not suitable for AT commands, even
though the car tries to send us AT commands over it. Any replies we
send to the car over RFCOMM are lost.
3. We query the car's MAC address over SDP for HFP (111e). Be aware that
some cars (like my Ford Focus) will refuse to list all services they
offer over SDP. However, you will receive a reply if you query for HFP
specifically. We will get the channel number to connect to over SDP.
4. We initiate an RFCOMM connection to the car on the correct port for it.
"""
while True:
connection, address = socket.accept()
connection.close()
connection = self._connect_hfp(address)
self.connected = True
while self.connected:
request = self.request_handler.decode(connection)
self.process_request(connection, request)
评论列表
文章目录