Pages: [1] 2   Go Down
Author Topic: RN-42 Bluetooth HID Mouse  (Read 4645 times)
0 Members and 1 Guest are viewing this topic.
Monterey CA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 321
Addicted to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

« Last Edit: February 02, 2012, 02:44:04 am by MobileWill » Logged

Current Projects:                    Arduinos:
Security Robot Tank               Uno
Security Robot II 4WD            Mega2560

http://mobilewill.blogspot.com

Monterey CA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 321
Addicted to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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







Logged

Current Projects:                    Arduinos:
Security Robot Tank               Uno
Security Robot II 4WD            Mega2560

http://mobilewill.blogspot.com

Monterey CA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 321
Addicted to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-wink Other stuff to figure out still, like what the range is for the cursor movement and how to map that to a absolute position.
Logged

Current Projects:                    Arduinos:
Security Robot Tank               Uno
Security Robot II 4WD            Mega2560

http://mobilewill.blogspot.com

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46240
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Monterey CA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 321
Addicted to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Current Projects:                    Arduinos:
Security Robot Tank               Uno
Security Robot II 4WD            Mega2560

http://mobilewill.blogspot.com

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Monterey CA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 321
Addicted to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Current Projects:                    Arduinos:
Security Robot Tank               Uno
Security Robot II 4WD            Mega2560

http://mobilewill.blogspot.com

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Monterey CA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 321
Addicted to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Current Projects:                    Arduinos:
Security Robot Tank               Uno
Security Robot II 4WD            Mega2560

http://mobilewill.blogspot.com

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Monterey CA
Offline Offline
Sr. Member
****
Karma: 0
Posts: 321
Addicted to Arduino
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Current Projects:                    Arduinos:
Security Robot Tank               Uno
Security Robot II 4WD            Mega2560

http://mobilewill.blogspot.com

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!
I am facing this problem with this module -
Code:
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?
Logged

Pages: [1] 2   Go Up
Jump to: