Android Open Source - BtDemo Bluetooth Server






From Project

Back to project page BtDemo.

License

The source code is released under:

Apache License

If you think the Android project BtDemo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package cn.edu.hust.cm.bt.demo.server;
/* w  w  w.ja va 2  s.co m*/
import java.io.IOException;
import java.util.UUID;

import android.bluetooth.BluetoothAdapter;

import cn.edu.hust.cm.bt.demo.BaseBluetoothSocket;

public class BluetoothServer {

    private String name;
    private String uuid;
    private BluetoothServerThread serverThread;

    public BluetoothServer(String name, String uuid) {
        super();
        this.name = name;
        this.uuid = uuid;
    }

    public String getName() {
        return name;
    }

    public UUID getUuid() {
        return UUID.fromString(uuid);
    }

    public boolean isRunning() {
        return null != serverThread && serverThread.isRunning();
    }

    public void setup() throws IOException {
        // TODO bt check

        try {
            serverThread = new BluetoothServerThread(this,
                    BluetoothAdapter.getDefaultAdapter());
            serverThread.start();
        } catch (IOException e) {
            throw e;
        }
    }

    public void shutdown() throws IOException {
        if (null != serverThread) {
            try {
                serverThread.shutdown();
            } catch (IOException e) {
                throw e;
            }
        }
    }

    protected void onConnected(BaseBluetoothSocket socket) {

    }
}




Java Source Code List

cn.edu.hust.cm.bt.demo.BaseBinderActivity.java
cn.edu.hust.cm.bt.demo.BaseBinderService.java
cn.edu.hust.cm.bt.demo.BaseBluetoothSocket.java
cn.edu.hust.cm.bt.demo.LocalBinder.java
cn.edu.hust.cm.bt.demo.MainActivity.java
cn.edu.hust.cm.bt.demo.client.ClientMainActivity.java
cn.edu.hust.cm.bt.demo.client.package-info.java
cn.edu.hust.cm.bt.demo.server.BluetoothServerThread.java
cn.edu.hust.cm.bt.demo.server.BluetoothServer.java
cn.edu.hust.cm.bt.demo.server.ServerBinderActivity.java
cn.edu.hust.cm.bt.demo.server.ServerBinderService.java
cn.edu.hust.cm.bt.demo.server.ServerMainActivity.java
cn.edu.hust.cm.bt.demo.server.package-info.java