Comment envoyer des données via un lien Bluetooth Low Energy (BLE)?

Je suis capable de découvrir, se connecter à des périphériques bluetooth.

Code Source---

Se connecter via bluetooth à un Appareil Distant:

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

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

Gatt de Rappel pour Statut:

 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

    }
};

Maintenant, je veux envoyer des commandes à Distance BLE appareil, mais ne sais pas comment faire.

Une fois que la commande est envoyée à la BLE de l'appareil, le BLE dispositif répondra par la radiodiffusion
données de mon application peut recevoir.

source d'informationauteur My God