Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BTSend
- {
- public static final UUID uuid = new UUID("27012f0c68af4fbf8dbe6bbaf7aa432a", false);
- public static final String name = "NXTBridge";
- public static final String url = "btspp://localhost:" + uuid //the service url
- + ";name=" + name
- + ";authenticate=false;encrypt=false;";
- static LocalDevice ipod_local = null;
- static StreamConnectionNotifier ipod_server = null;
- static StreamConnection ipod_conn = null;
- public static void main(String[] args)
- {
- System.out.println("Beginning Server");
- try {
- System.out.println("Setting device to be discoverable...");
- ipod_local = LocalDevice.getLocalDevice();
- ipod_local.setDiscoverable(DiscoveryAgent.GIAC);
- System.out.println("Start advertising service...");
- ipod_server = (StreamConnectionNotifier)Connector.open(url);
- System.out.println("Waiting for incoming connection...");
- ipod_conn = ipod_server.acceptAndOpen();
- System.out.println("Client Connected...");
- DataInputStream din = new DataInputStream(ipod_conn.openInputStream());
- while(true)
- {
- String cmd = "";
- char c;
- while (((c = din.readChar()) > 0) && (c!='\n') ){
- cmd = cmd + c;
- }
- System.out.println("Received " + cmd);
- }
- } catch (Exception e) {System.out.println("Exception Occured: " + e.toString());}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement