Bluetooth remote interface for Java ME

973 views

Published on

Short talk presented at Javapolis 2006 about using a Java ME smatphone as remote controller (for presenters, impaired people).

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
973
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Bluetooth remote interface for Java ME

  1. 1. Mark your agenda for JavaPolis 2006 December 11th till 15thJAVAPOLIS 2006December 11th till 15th
  2. 2. Bluetooth remote interface for JAVA ME Breaking digital barriers! Stefano Sanna Researcher CRS4 www.javapolis.com
  3. 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. 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. 5. Blix: the fast way to Bluetoothinterface• 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
  6. 6. Blix Architecture Custom Custom MIDlet Application (controller) (controlled) events Listener BLIX BLIXJSR-82 Implementation JSR-82 Implementation www.javapolis.com
  7. 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. 8. Receiving remote controller eventsCreate the server endpoint// service number and nameint service = 12;String name = “My Controller”;// setup endpointBlixEndPoint ep = BlixEndPoint.createServer(service, name);// be ready to listen for events! :-)ep.setEndPointListener(myListener);// you are ready to communicate! www.javapolis.com
  9. 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. 10. Sending remote controller eventsCreate the client endpoint// address of server endpointString BD_ADDR = “00:11:22:AA:BB:CC”;// service number assigned to your serviceint service = 12;BlixEndPoint ep;ep = BlixEndPoint.createClient(BD_ADDR, service);// you are ready to communicate! www.javapolis.com
  11. 11. BlixEndPoint methodsInvoke them to dispatch event to theremote devicepublic 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
  12. 12. Simple Bluetooth presenter Custom Application (controlled) Listener BLIX BLIXJSR-82 Implementation JSR-82 Implementation www.javapolis.com
  13. 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. 14. This is the keyTyped method defined byUsing the Robot the EndPointListener interfacepublic 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. 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. 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. 17. Mark your agenda for JavaPolis 2006 December 11th till 15thJAVAPOLIS 2006December 11th till 15th

×