Wie zum senden von Daten über eine Bluetooth Low Energy (BLE) link?

Ich bin in der Lage zu entdecken, eine Verbindung zu bluetooth.

Source-Code - - -

Über bluetooth verbinden, um Remote-Gerät:

//Get the device by its serial number
 bdDevice = mBluetoothAdapter.getRemoteDevice(blackBox);

 //for ble connection
 bdDevice.connectGatt(getApplicationContext(), true, mGattCallback);

Gatt-Rückruf-Status:

 private BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
    @Override
    public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
    //Connection established
    if (status == BluetoothGatt.GATT_SUCCESS
        && newState == BluetoothProfile.STATE_CONNECTED) {

        //Discover services
        gatt.discoverServices();

    } else if (status == BluetoothGatt.GATT_SUCCESS
        && newState == BluetoothProfile.STATE_DISCONNECTED) {

        //Handle a disconnect event

    }
    }

    @Override
    public void onServicesDiscovered(BluetoothGatt gatt, int status) {

    //Now we can start reading/writing characteristics

    }
};

Nun möchte ich, um Befehle zu senden, um Remote-BLE-Gerät, wissen aber nicht, wie das zu tun.

Sobald der Befehl gesendet, um die BLE Geräte, die BLE-Gerät reagiert, indem er
Daten, die meine Bewerbung erhalten können.

InformationsquelleAutor der Frage My God | 2014-04-30

Schreibe einen Kommentar