mitxela.com forum
Welcome. Please log in or register.

Bluetooth HID Gamepad - CTS and RTS
lepond Posted: 8 Jun 2017, 12:55 AM
Avatar


Member
Posts: 7
Joined: 8-June 17
Hello, mit!

First of all, I must thank you for this incredible tutorial. I managed to do everything on your tutorial about the firmware dumping, flashing and editing on PSTool.

I'm trying to make the Frankenstein-RN42 to talk with Android over Arduino, but I'm having trouble sending scan reports over bluetooth. Already tried to send every kind of scan reports, but the "best" result that I've got is just random clicks.

I found something in the User Manual (ver. 1.0r) about keeping the CTS and RTS ports low or tied together.

The Bluetooth device power, ground, RX, and TX signals must be connected and CTS should be held low or tied to RTS.
Page 45, Item 3.3

Did you made any modification on this ports, cause as far as I can see on your pictures, they're floating.

-------------
[top]
mit Posted: 8 Jun 2017, 01:17 PM
Avatar
yeah whatever

Admin
Posts: 538
Joined: 4-May 16
Hi, I never had to do anything to the RTS or CTS pins. It's possible there are different versions of the module but I doubt that's the problem.

Were you able to configure the RN42 as a HID device OK? Sending the "$$$" command and setting the device name etc.

By clicks, do you mean mouse-clicks? If it's sending random data it might be that the baud rate or other UART settings are wrong. Depending on what you're trying to do it might be easier to test it using a laptop rather than Android device because android bluetooth drivers can sometimes be a bit funny.

-------------
[top]
lepond Posted: 8 Jun 2017, 01:58 PM
Avatar


Member
Posts: 7
Joined: 8-June 17
I'm able to send commands like $$$ and I'm getting responses correctly. So I thinks there's nothing wrong with the BAUD rates. Or maybe Android's Bluetooth has a specific BAUD different than the RN42's default 115200.

Probably my version requires CTS and RTS to be shorted. Later today I'll try this and report back the results.

-------------
[top]
lepond Posted: 8 Jun 2017, 08:15 PM
Avatar


Member
Posts: 7
Joined: 8-June 17
I've tried to short CTS and RTS, but no difference what so ever. I'm really lost right now. Maybe I'll try to flash another version of the firmware. ):

-------------
[top]
mit Posted: 8 Jun 2017, 08:38 PM
Avatar
yeah whatever

Admin
Posts: 538
Joined: 4-May 16
Hmm. Could you provide an example of one of the scan reports you're sending to it? And how is it configured, as a gamepad?

-------------
[top]
lepond Posted: 9 Jun 2017, 03:23 PM
Avatar


Member
Posts: 7
Joined: 8-June 17
The HC05/RN42 is set as:
SH,0240 (Gamepad)
SM,4 (DNR mode)
S~,6 (HID mode)
SU,9600 (BAUD rate 9600)

And I'm trying to send the following
QUOTE
BTserial.write((byte)0xFD); //Start HID Report
BTserial.write((byte)0x6); //Length byte

// 1. X/Y-Axis
BTserial.write(45); //First X coordinate
BTserial.write(-33); //First Y coordinate

// 2. X/Y-Axis
BTserial.write(45); //Second X coordinate
BTserial.write(-33); //Second Y coordinate

// Buttons
BTserial.write(B10000001); // Second Byte (Buttons 1-8)
BTserial.write(B10000000); // Second Byte (Buttons 9-16)

But or I got a random response, or I get none.

I activated ECHO ON with command "+", and when I send the message, I read some random character, just like when there's a mismatching BAUD rate.

-------------
[top]
mit Posted: 9 Jun 2017, 11:18 PM
Avatar
yeah whatever

Admin
Posts: 538
Joined: 4-May 16
That's interesting. What made you want to change the baud to 9600 ? I'd have thought it would be easier to start the arduino serial at 115200.

I don't think I tried changing the baud rate on the module, it might be that you have to send the save & reset command (R,1) again.

-------------
[top]
lepond Posted: 9 Jun 2017, 11:34 PM
Avatar


Member
Posts: 7
Joined: 8-June 17
QUOTE (mit)
That's interesting. What made you want to change the baud to 9600 ? I'd have thought it would be easier to start the arduino serial at 115200.

I changed to 9600 because Arduino's Serial Monitor it's a bit dull when dealing with higher BAUD rates.

QUOTE (mit)
I don't think I tried changing the baud rate on the module, it might be that you have to send the save & reset command (R,1) again.

Did lots of resets since I changed. hahaha


Today I made some progress. I managed to make it work flawless on a old tablet (Samsung Galaxy Tab 10.1 P7500), but not on a Moto X Play nor on a Xiaomi RedMi 2 Pro. It seems that the problem is on the Android side. Maybe there's a Bluetooth HID profile that needs to be activated, or something.

I'm doing some research about that.
Thank you very much for your help, Mit!

-------------
[top]
lepond Posted: 12 Jun 2017, 02:26 PM
Avatar


Member
Posts: 7
Joined: 8-June 17
Finally, I made it work!

On my wife's Moto X Play, I solved like this:
Setting" -> "Location" -> "Three dots at the top right" -> Disable bluetooth scanning.

After that, the phone was started receiving scan reports normally!

On my phone (Xiaomi Redmi 2 Pro), I disabled contacts sharing on the RN42's bluetooth configuration.

I hope this helps someone on the future.
Thanks for your attention and tutorial, Mit! Keep doing this great work!

-------------
[top]
mit Posted: 12 Jun 2017, 11:06 PM
Avatar
yeah whatever

Admin
Posts: 538
Joined: 4-May 16
Ah, not the first time I've seen weird problems getting Android bluetooth to work properly. Glad you got it working, thanks for the update.

-------------
[top]

Sign in to post a reply.