RN-42 Bluetooth HID Mouse

I just recieved a BlueSmrif in HID mode and trying to get it to act like a mouse

http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Wireless/Bluetooth/RN-HID-User%20Guidev0%2005.pdf

I don't quite understand what to send to send a mouse event.

I can get keyboard to work and send text and codes like backspace and volume up just fine. Just confused about the mouse part.

I have it in HID mouse mode now.

Thanks for any help.

Here is what it has for mouse

0xFD 5 bytes 0x2 Buttons X-stop Y-stop Wheel

I get the FD, the 5 bytes is for Length not sure so should it be 0x05? And then the rest I take it would be a hex value for each? I am not sure what the value would be for Buttons X, Y and Wheel

There is an example of a keyboard press and that is

0xFD 0x03 0x03 0x00 0x10 for keydown
0xFD 0x03 0x03 0x00 0x00 for keyup

In case anyone finds this and wants to know the solution.

I was using binary instead of the hex value. The manual needs to be more clear. So for mouse mode I used 0020 and it worked ;) Other stuff to figure out still, like what the range is for the cursor movement and how to map that to a absolute position.

like what the range is for the cursor movement and how to map that to a absolute position.

The range is, in theory, unbounded. Of course, the actual position is stored in a variable of some type that imposes limits. The absolute position must be determined by adding all the + movements and subtracting all the - movements.

Hello, I was wondering if you could tell me how you send the hid reports to the bluesmirf. I have been trying to send the report through the uart connection from a terminal window. Instead of the module interpreting the report it justs sends each character as a key press. I have sent 0xFD 0x9 0x1 0x0 0x04 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 to the module which the manual says will send an event that the "a" key has been pressed.

The terminal won't work, you need a terminal program that can send hex values. I use hterm http://www.der-hammer.info/terminal/

There are others like this one

http://realterm.sourceforge.net/

Let me know if you get it work or anything else you need. It was a pain but works great once you get it working.

Thanks, that worked nicely. I've got my arduino sending events to it now as well.

My only problem with it now is that it does not send back any feedback after sending it any commands. It goes into command mode with $$$ but it doesn't send back the CMD response. I changed the name of the module with the SN command but it does not send back AOK even though the name was successfully changed.

Anyway, at least I know how to send events to it now.

It should. I had to play with the CR and LF in the terminal app. Sometimes it wants it and others it whats no feed. really odd. Its picky.

I am still trying to figure out a way to translate x,y to be able to send absolute values or at least keep it in sync.

Should be nothing sent after $$$ but all other commands expect a new line. At least thats what it looks like since the commands are executed I just don't get any feedback. I've sent mouse x and y values from my arduino with byte( val ); I tested it out with this:

buffer[0] = 0xFD; buffer[1] = 0x05; buffer[2] = 0x02; buffer[3] = 0x00; //Buttons buffer[4] = byte( random( 1366 ) ); //X-stop buffer[5] = byte( random( 768 ) ); //Y-stop buffer[6] = 0x00; //Wheel

Serial.write( buffer, 7 );

Have you gotten your module to auto connect after a power cycle?

Really that works? I thought x and y were only distance to move. At least that is how it seems to work for me. What mode are you using for hid?

No and I thought it was supposed. I ended up having the Arduino send a connect command on startup.works well enough.

Your right, x and y seem to be relative distances. I think I was just moving it so far that it wrapped around maybe? I don't see any way to set an absolute position. I have it in mouse mode for now.

I am working on a way to translate absolute to relative. The mouse when connected to my phone starts in the middle so just have to track from there. I am testing using processing and just jumping to where I click the mouse. So far its not working so well. I think you can only move so far per command. So I tired to move in smaller jumps to the click location but still not working right.

I think mine is in combo mode. On my phone it won't wrap but I didn't try on a computer.

Haven't had a chance to get back to this project, really need to get this working so I can work on the touchscreen part.

You can only make small jumps since we only have a byte to store the position. Also my code "byte( random( 1366 ) )" doesn't make any sense since the maximum value would be 256, and since its signed the range is -127 to 127. And that would be why you can only move small distances at a time.

esgeroth: Have you gotten your module to auto connect after a power cycle?

HI guys! For autoconnect you need to put the device in pair mode. You can get that mode by sending the command "SM,6" on the uart. In this mode the module will pair up with the last device. Works well for me.

Hi! I am facing this problem with this module -

void setup()
{
   Serial.begin(19200);
}

void loop()
{
   Serial.println("aaaaaaaaa");
   Serial.println("bbbbbbbbb");
   Serial.println("cccccccccc");
}

Now when i try to see this on the serial window, I get aaaaaa bbbbbbbbb ccc aaaaaaaaa bb cccccccc and so on.. A lot of characters are lost When i do this with a SPP module by bluesmirf, I get all the characters. Any idea why this might be happening?

I am facing this problem with this module -

You are sending serial data out as fast as possible at that baud rate. Perhaps you need to consider that the other end can't keep up. Some reasonable delay after spamming the serial port may be necessary to allow the other end to keep up.

Hi, how did you get the HID module into mouse mode? I'm struggling to figure out how to connect it to my PC and get it into command mode. Can you post simple instructions?

Thanks!

Hello, Hope you will answer guys. I'm trying to use the RN-42 to control an Android tablette Nexus 7. I am using Tera Term terminal. I put the device in HID mode and I configured the RN42 to the Combo type. I connected my self to the Nexus 7 but i don't know how to send commands in Hexadecimal. I know that we have to send "0xfd 0x3 0x3 0x80 0x00" for example to play or pause a track but i don't know how to send it in Hex. Thank you for your help

Nabil. B ENSICAEN, France

Hi, somebody know how to receive an input report? I want to send data from my pc an receive it with RN42 using HID.

wgarrido: In case anyone finds this and wants to know the solution.

I was using binary instead of the hex value. The manual needs to be more clear. So for mouse mode I used 0020 and it worked ;) Other stuff to figure out still, like what the range is for the cursor movement and how to map that to a absolute position.

Hello, I know this is an old post but I wanted to ask you how you sent the commands to change the RN-42 between keyboard and mouse modes. I have a RN-42 set as a keyboard. I used a terminal to send the commands to set it as so (it used a COM port). Now that the device is in HID, this method doens't seem to work :(