Kumar
Kumar

Reputation: 11

How to send AT commands to BT Headset

I want to develop an application that controll BT headset, not manually. For example, when I have incoming call, I want to send AT command to BT headset to reject or accept incoming call. Here is my code to gain that goal.

Here is my code based on How to send AT commands based on BT Hands-Free profile in android?

private UUID MY_UUID_SECURE = UUID.fromString("00001108-0000-1000-8000-00805f9b34fb"); // It's my headset's uuid
...
tmp = device.createRfcommSocketToServiceRecord(MY_UUID_SECURE); // Connect to my headset's profile(HSP)
...
// Here is rfcomm success
mmInStream = mmSocket.getInputStream();
mmOutStream = mmSocket.getOutputStream();
...

Connection is success and I can write any bytes to HSP.

mmOutStream.write("AT+CHUP\r".getBytes());

Above code is running correctly but my headset does not work on any commands. What does it mean? "AT+CHUP" is AT command to reject incoming call, isn't it? But it does not work on my headset. Headset could not reject/accept incoming call now. If anybody has expirences on that problem, please help me. I am also glad to see somebody's full source in github. Please and thank you all.

Upvotes: 1

Views: 356

Answers (0)

Related Questions