1. Mark your agenda for JavaPolis 2006
December 11th till 15th
JAVAPOLIS
2006
December 11th till 15th
2. Bluetooth remote interface for
JAVA ME
Breaking digital barriers!
Stefano Sanna
Researcher
CRS4
www.javapolis.com
3. Who I am...
• Stefano Sanna is Researcher at CRS4,
Network Distributed Applications group,
Mobile Computing team
• Stefano Sanna is technical writer for
computer magazines “DEV”, “Computer
Programming” and “Free Software
Magazine”
• Finally, he is active member of the Java
Mobile Developers Forum and JUG
Sardegna
www.javapolis.com
4. Bluetooth in the Java ME world...
• JCP released the “J2ME API for
Bluetooth” (JSR-82)
• JSR-82 provides:
– Basic services: discovering, rfcomm
connection, security
– OBEX support (optional)
• However...
– JSR-82 is general purpose (as Socket for
networking)
www.javapolis.com
5. Blix: the fast way to Bluetooth
interface
• Blix provides a simple API:
– Client side: set of methods to send events
related to keyboard, mouse, clipboard, other
custom commands
– Server side: well-known observer pattern to
receive notifications about UI events and
process custom commands
• Blix is built on top of standard JSR-82
www.javapolis.com
7. Blix requirements
• Java ME SDK with Bluetooth API support
• Mobile:
– Java ME device JSR-82 implementation
• Workstation:
– Any JSR-82 implementation for Java SE
• Avetana provides free GPL-based version of their
protocol stack (http://www.avetana.de)
www.javapolis.com
8. Receiving remote controller events
Create the server endpoint
// service number and name
int service = 12;
String name = “My Controller”;
// setup endpoint
BlixEndPoint ep
= BlixEndPoint.createServer(service, name);
// be ready to listen for events! :-)
ep.setEndPointListener(myListener);
// you are ready to communicate!
www.javapolis.com
9. The EndPointListener interface
public interface EndPointListener {
public void connectionEstablished();
public void connectionLost();
public void keyPressed(int keycode);
public void keyReleased(int keycode);
public void keyTyped(int keycode);
public void keyRepeated(int keycode);
...
public void snapshotRequested();
...
public void messageReceived(Message message);
}
www.javapolis.com
10. Sending remote controller events
Create the client endpoint
// address of server endpoint
String BD_ADDR = “00:11:22:AA:BB:CC”;
// service number assigned to your service
int service = 12;
BlixEndPoint ep;
ep = BlixEndPoint.createClient(BD_ADDR, service);
// you are ready to communicate!
www.javapolis.com
11. BlixEndPoint methods
Invoke them to dispatch event to the
remote device
public void sendKeyPressed(int keycode) {...}
public void sendKeyReleased(int keycode) {...}
public void sendKeyTyped(int keycode) {...}
public void sendKeyRepeated(int keycode) {...}
...
public void sendSnapshot(byte[] image) {...}
// for custom messages:
public void sendMessage(Message message) {...}
www.javapolis.com
13. AWT strikes back!
• The java.awt.Robot provides methods to
generate UI events on host machine:
– Key press & release
– Mouse move, click and wheel scroll
• We can map mobile phone events to PC
keyboard:
– 7 --> PAGE UP
– 9 --> PAGE DOWN
www.javapolis.com
14. This is the keyTyped method defined by
Using the Robot the EndPointListener interface
public void keyTyped(int keycode) {
switch(keycode) {
// key 7 on Java ME
case 55:
robot.keyPress(KeyEvent.VK_PAGE_UP);
robot.keyRelease(KeyEvent.VK_PAGE_UP);
break;
// key 9 on Java ME
case 57:
robot.keyPress(KeyEvent.VK_PAGE_DOWN);
robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
break;
}
}
www.javapolis.com
15. Blix applications
• Support for users with disabilities
• Remote controller for CarPC applications
• Configuration and management for
embedded devices without UI (vending
machines, routers...)
• Security controllers: you can hide server
endpoint and address it directly from your
remote controller
www.javapolis.com
16. Blix is open source!
• Source code will be available in Jan 2006.
Check:
– https://blix.dev.java.net/
• We provide the communication library and
some sample application. If you intend to
use Blix for your projects and you like to
share your experience, please contact us:
gerda@crs4.it
www.javapolis.com
17. Mark your agenda for JavaPolis 2006
December 11th till 15th
JAVAPOLIS
2006
December 11th till 15th