Skip to main content
se eliminaron 85 caracteres en el cuerpo
Origen Enlace
        @Override
        public void onServicesDiscovered(final BluetoothGatt gatt, int status)
        {
            super.onServicesDiscovered(gatt, status);
            Log.d(TAG, "onServicesDiscovered status="+status);

            if (status == BluetoothGatt.GATT_SUCCESS) {
                charact_2A06 = gatt.getService(Constants.UUID_SERVICE_1802).getCharacteristic(Constants.UUID_CHARACTERISTIC_2A46);
                isConnected = true;
            }
        }

        @Override
        public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
        {
            super.onCharacteristicChanged(gatt, characteristic);
            Log.d(TAG, "onCharacteristicChanged "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
        }

        @Override
        public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
            super.onCharacteristicWrite(gatt, characteristic, status);
            Log.d(TAG, "onCharacteristicWrite "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
            if(mWait!=null && mWait.getCount()>0)
                mWait.countDown();
        }
    };

 public void enviarDatos(String dato){
    
        if(!isConnected){
            connect();
        }


        try {
            mWait = new CountDownLatch(1);

            mWait = new CountDownLatch(1);

            byte b =Byte.valueOf(dato);
           
            charact_2A06.setValue(new byte[]{-3,2,b,(byte)0});
            mGatt.writeCharacteristic(charact_2A06);
            

        }
        catch (Exception e)
        {
            e.printStackTrace();
        }


    }
        @Override
        public void onServicesDiscovered(final BluetoothGatt gatt, int status)
        {
            super.onServicesDiscovered(gatt, status);
            Log.d(TAG, "onServicesDiscovered status="+status);

            if (status == BluetoothGatt.GATT_SUCCESS) {
                charact_2A06 = gatt.getService(Constants.UUID_SERVICE_1802).getCharacteristic(Constants.UUID_CHARACTERISTIC_2A46);
                isConnected = true;
            }
        }

        @Override
        public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
        {
            super.onCharacteristicChanged(gatt, characteristic);
            Log.d(TAG, "onCharacteristicChanged "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
        }

        @Override
        public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
            super.onCharacteristicWrite(gatt, characteristic, status);
            Log.d(TAG, "onCharacteristicWrite "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
            if(mWait!=null && mWait.getCount()>0)
                mWait.countDown();
        }
    };

 public void enviarDatos(String dato){
    
        if(!isConnected){
            connect();
        }


        try {
            mWait = new CountDownLatch(1);

            mWait = new CountDownLatch(1);

            byte b =Byte.valueOf(dato);
           
            charact_2A06.setValue(new byte[]{-3,2,b,(byte)0});
            mGatt.writeCharacteristic(charact_2A06);
            

        }
        catch (Exception e)
        {
            e.printStackTrace();
        }


    }
        @Override
        public void onServicesDiscovered(final BluetoothGatt gatt, int status)
        {
            super.onServicesDiscovered(gatt, status);
            Log.d(TAG, "onServicesDiscovered status="+status);

            if (status == BluetoothGatt.GATT_SUCCESS) {
                charact_2A06 = gatt.getService(Constants.UUID_SERVICE_1802).getCharacteristic(Constants.UUID_CHARACTERISTIC_2A46);
                isConnected = true;
            }
        }

        @Override
        public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
        {
            super.onCharacteristicChanged(gatt, characteristic);
            Log.d(TAG, "onCharacteristicChanged "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
        }

        @Override
        public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
            super.onCharacteristicWrite(gatt, characteristic, status);
            Log.d(TAG, "onCharacteristicWrite "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
            if(mWait!=null && mWait.getCount()>0)
                mWait.countDown();
        }
    };

 public void enviarDatos(String dato){
    
        if(!isConnected){
            connect();
        }


        try {
           

            byte b =Byte.valueOf(dato);
           
            charact_2A06.setValue(new byte[]{-3,2,b,(byte)0});
            mGatt.writeCharacteristic(charact_2A06);
            

        }
        catch (Exception e)
        {
            e.printStackTrace();
        }


    }

@Override

        @Override
        public void onServicesDiscovered(final BluetoothGatt gatt, int status)
        {
            super.onServicesDiscovered(gatt, status);
            Log.d(TAG, "onServicesDiscovered status="+status);

            if (status == BluetoothGatt.GATT_SUCCESS) {
                charact_2A06 = gatt.getService(Constants.UUID_SERVICE_1802).getCharacteristic(Constants.UUID_CHARACTERISTIC_2A46);
                isConnected = true;
            }
        }

        @Override
        public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
        {
            super.onCharacteristicChanged(gatt, characteristic);
            Log.d(TAG, "onCharacteristicChanged "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
        }

        @Override
        public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
            super.onCharacteristicWrite(gatt, characteristic, status);
            Log.d(TAG, "onCharacteristicWrite "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
            if(mWait!=null && mWait.getCount()>0)
                mWait.countDown();
        }
    };

public void enviarDatos(String dato){


 public void enviarDatos(String dato){
    
        if(!isConnected){
            connect();
        }


        try {
            mWait = new CountDownLatch(1);

            mWait = new CountDownLatch(1);

            byte b =Byte.valueOf(dato);
           
            charact_2A06.setValue(new byte[]{-3,2,b,(byte)0});
            mGatt.writeCharacteristic(charact_2A06);
            

        }
        catch (Exception e)
        {
            e.printStackTrace();
        }


    }

@Override

    public void onServicesDiscovered(final BluetoothGatt gatt, int status)
    {
        super.onServicesDiscovered(gatt, status);
        Log.d(TAG, "onServicesDiscovered status="+status);

        if (status == BluetoothGatt.GATT_SUCCESS) {
            charact_2A06 = gatt.getService(Constants.UUID_SERVICE_1802).getCharacteristic(Constants.UUID_CHARACTERISTIC_2A46);
            isConnected = true;
        }
    }

    @Override
    public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
    {
        super.onCharacteristicChanged(gatt, characteristic);
        Log.d(TAG, "onCharacteristicChanged "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
    }

    @Override
    public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
        super.onCharacteristicWrite(gatt, characteristic, status);
        Log.d(TAG, "onCharacteristicWrite "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
        if(mWait!=null && mWait.getCount()>0)
            mWait.countDown();
    }
};

public void enviarDatos(String dato){

    if(!isConnected){
        connect();
    }


    try {
        mWait = new CountDownLatch(1);

        mWait = new CountDownLatch(1);

        byte b =Byte.valueOf(dato);
       
        charact_2A06.setValue(new byte[]{-3,2,b,(byte)0});
        mGatt.writeCharacteristic(charact_2A06);
        

    }
    catch (Exception e)
    {
        e.printStackTrace();
    }


}
        @Override
        public void onServicesDiscovered(final BluetoothGatt gatt, int status)
        {
            super.onServicesDiscovered(gatt, status);
            Log.d(TAG, "onServicesDiscovered status="+status);

            if (status == BluetoothGatt.GATT_SUCCESS) {
                charact_2A06 = gatt.getService(Constants.UUID_SERVICE_1802).getCharacteristic(Constants.UUID_CHARACTERISTIC_2A46);
                isConnected = true;
            }
        }

        @Override
        public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
        {
            super.onCharacteristicChanged(gatt, characteristic);
            Log.d(TAG, "onCharacteristicChanged "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
        }

        @Override
        public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
            super.onCharacteristicWrite(gatt, characteristic, status);
            Log.d(TAG, "onCharacteristicWrite "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
            if(mWait!=null && mWait.getCount()>0)
                mWait.countDown();
        }
    };

 public void enviarDatos(String dato){
    
        if(!isConnected){
            connect();
        }


        try {
            mWait = new CountDownLatch(1);

            mWait = new CountDownLatch(1);

            byte b =Byte.valueOf(dato);
           
            charact_2A06.setValue(new byte[]{-3,2,b,(byte)0});
            mGatt.writeCharacteristic(charact_2A06);
            

        }
        catch (Exception e)
        {
            e.printStackTrace();
        }


    }
se añadieron 1788 caracteres en el cuerpo
Origen Enlace

¿Alguien sabe cómo mandar texto a la MiBand 2 desde android?

Hasta ahora soy capaz de enviar números pero no strings y no sé como hacer.

@Override

    public void onServicesDiscovered(final BluetoothGatt gatt, int status)
    {
        super.onServicesDiscovered(gatt, status);
        Log.d(TAG, "onServicesDiscovered status="+status);

        if (status == BluetoothGatt.GATT_SUCCESS) {
            charact_2A06 = gatt.getService(Constants.UUID_SERVICE_1802).getCharacteristic(Constants.UUID_CHARACTERISTIC_2A46);
            isConnected = true;
        }
    }

    @Override
    public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
    {
        super.onCharacteristicChanged(gatt, characteristic);
        Log.d(TAG, "onCharacteristicChanged "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
    }

    @Override
    public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
        super.onCharacteristicWrite(gatt, characteristic, status);
        Log.d(TAG, "onCharacteristicWrite "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
        if(mWait!=null && mWait.getCount()>0)
            mWait.countDown();
    }
};

public void enviarDatos(String dato){

    if(!isConnected){
        connect();
    }


    try {
        mWait = new CountDownLatch(1);

        mWait = new CountDownLatch(1);

        byte b =Byte.valueOf(dato);
       
        charact_2A06.setValue(new byte[]{-3,2,b,(byte)0});
        mGatt.writeCharacteristic(charact_2A06);
        

    }
    catch (Exception e)
    {
        e.printStackTrace();
    }


}

¿Alguien sabe cómo mandar texto a la MiBand 2 desde android?

Hasta ahora soy capaz de enviar números pero no strings y no sé como hacer.

¿Alguien sabe cómo mandar texto a la MiBand 2 desde android?

Hasta ahora soy capaz de enviar números pero no strings y no sé como hacer.

@Override

    public void onServicesDiscovered(final BluetoothGatt gatt, int status)
    {
        super.onServicesDiscovered(gatt, status);
        Log.d(TAG, "onServicesDiscovered status="+status);

        if (status == BluetoothGatt.GATT_SUCCESS) {
            charact_2A06 = gatt.getService(Constants.UUID_SERVICE_1802).getCharacteristic(Constants.UUID_CHARACTERISTIC_2A46);
            isConnected = true;
        }
    }

    @Override
    public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
    {
        super.onCharacteristicChanged(gatt, characteristic);
        Log.d(TAG, "onCharacteristicChanged "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
    }

    @Override
    public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
        super.onCharacteristicWrite(gatt, characteristic, status);
        Log.d(TAG, "onCharacteristicWrite "+characteristic.getUuid()+" "+ Arrays.toString(characteristic.getValue()));
        if(mWait!=null && mWait.getCount()>0)
            mWait.countDown();
    }
};

public void enviarDatos(String dato){

    if(!isConnected){
        connect();
    }


    try {
        mWait = new CountDownLatch(1);

        mWait = new CountDownLatch(1);

        byte b =Byte.valueOf(dato);
       
        charact_2A06.setValue(new byte[]{-3,2,b,(byte)0});
        mGatt.writeCharacteristic(charact_2A06);
        

    }
    catch (Exception e)
    {
        e.printStackTrace();
    }


}
Origen Enlace
Loading