Java Code Examples for com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.util.HexDump#dumpHexString()

The following examples show how to use com.eveningoutpost.dexdrip.ImportedLibraries.usbserial.util.HexDump#dumpHexString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DexCollectionService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCharacteristicChanged(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {

    final PowerManager.WakeLock wakeLock1 = JoH.getWakeLock("DexCollectionService", 60000);
    try {
        final byte[] data = characteristic.getValue();

        if (data != null && data.length > 0) {
            setSerialDataToTransmitterRawData(data, data.length);

            final String hexdump = HexDump.dumpHexString(data);
            //if (!hexdump.contains("0x00000000 00      ")) {
            if (data.length > 1 || data[0] != 0x00) {
                static_last_hexdump = hexdump;
            }
            if (d) Log.i(TAG, "onCharacteristicChanged entered " + hexdump);

        }
        lastdata = data;

        Inevitable.task("dex-set-failover", 1000, () -> {
            setFailoverTimer(); // restart the countdown
            // intentionally left hanging wakelock for 5 seconds after we receive something
            final PowerManager.WakeLock wakeLock2 = JoH.getWakeLock("DexCollectionLinger", 5000);
        });

    } finally {
       /* if (Pref.getBoolean("bluetooth_frequent_reset", false)) {
            Log.e(TAG, "Resetting bluetooth due to constant reset option being set!");
            JoH.restartBluetooth(getApplicationContext(), 5000);
        }*/
        JoH.releaseWakeLock(wakeLock1);
    }
}
 
Example 2
Source File: DexCollectionService.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCharacteristicChanged(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {

    final PowerManager.WakeLock wakeLock1 = JoH.getWakeLock("DexCollectionService", 60000);
    try {
        final byte[] data = characteristic.getValue();

        if (data != null && data.length > 0) {
            setSerialDataToTransmitterRawData(data, data.length);

            final String hexdump = HexDump.dumpHexString(data);
            //if (!hexdump.contains("0x00000000 00      ")) {
            if (data.length > 1 || data[0] != 0x00) {
                static_last_hexdump = hexdump;
            }
            if (d) Log.i(TAG, "onCharacteristicChanged entered " + hexdump);

        }
        lastdata = data;

        Inevitable.task("dex-set-failover", 1000, () -> {
            setFailoverTimer(); // restart the countdown
            // intentionally left hanging wakelock for 5 seconds after we receive something
            final PowerManager.WakeLock wakeLock2 = JoH.getWakeLock("DexCollectionLinger", 5000);
        });

    } finally {
       /* if (Pref.getBoolean("bluetooth_frequent_reset", false)) {
            Log.e(TAG, "Resetting bluetooth due to constant reset option being set!");
            JoH.restartBluetooth(getApplicationContext(), 5000);
        }*/
        JoH.releaseWakeLock(wakeLock1);
    }
}
 
Example 3
Source File: DexCollectionService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCharacteristicChanged(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {

    final PowerManager.WakeLock wakeLock1 = JoH.getWakeLock("DexCollectionService", 60000);
    try {
        final byte[] data = characteristic.getValue();

        if (data != null && data.length > 0) {
            setSerialDataToTransmitterRawData(data, data.length);

            final String hexdump = HexDump.dumpHexString(data);
            //if (!hexdump.contains("0x00000000 00      ")) {
            if (data.length > 1 || data[0] != 0x00) {
                static_last_hexdump = hexdump;
            }
            if (d) Log.i(TAG, "onCharacteristicChanged entered " + hexdump);

        }
        lastdata = data;

        Inevitable.task("dex-set-failover", 1000, () -> {
            setFailoverTimer(); // restart the countdown
            // intentionally left hanging wakelock for 5 seconds after we receive something
            final PowerManager.WakeLock wakeLock2 = JoH.getWakeLock("DexCollectionLinger", 5000);
        });

    } finally {
       /* if (Pref.getBoolean("bluetooth_frequent_reset", false)) {
            Log.e(TAG, "Resetting bluetooth due to constant reset option being set!");
            JoH.restartBluetooth(getApplicationContext(), 5000);
        }*/
        JoH.releaseWakeLock(wakeLock1);
    }
}
 
Example 4
Source File: DexCollectionService.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCharacteristicChanged(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {

    final PowerManager.WakeLock wakeLock1 = JoH.getWakeLock("DexCollectionService", 60000);
    try {
        final byte[] data = characteristic.getValue();

        if (data != null && data.length > 0) {
            setSerialDataToTransmitterRawData(data, data.length);

            final String hexdump = HexDump.dumpHexString(data);
            //if (!hexdump.contains("0x00000000 00      ")) {
            if (data.length > 1 || data[0] != 0x00) {
                static_last_hexdump = hexdump;
            }
            if (d) Log.i(TAG, "onCharacteristicChanged entered " + hexdump);

        }
        lastdata = data;

        Inevitable.task("dex-set-failover", 1000, () -> {
            setFailoverTimer(); // restart the countdown
            // intentionally left hanging wakelock for 5 seconds after we receive something
            final PowerManager.WakeLock wakeLock2 = JoH.getWakeLock("DexCollectionLinger", 5000);
        });

    } finally {
       /* if (Pref.getBoolean("bluetooth_frequent_reset", false)) {
            Log.e(TAG, "Resetting bluetooth due to constant reset option being set!");
            JoH.restartBluetooth(getApplicationContext(), 5000);
        }*/
        JoH.releaseWakeLock(wakeLock1);
    }
}
 
Example 5
Source File: DexCollectionService.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
private synchronized boolean sendBtMessage(final ByteBuffer message) {
    // TODO affirm send happened
    //check mBluetoothGatt is available
    Log.i(TAG, "sendBtMessage: entered");
    if (mBluetoothGatt == null) {
        Log.w(TAG, "sendBtMessage: lost connection");
        if (JoH.ratelimit("sendbtmessagelost", 60)) {
            mConnectionState = STATE_DISCONNECTED;
            setRetryTimer();
        }
        return false;
    }

    final byte[] value = message.array();

    static_last_sent_hexdump = HexDump.dumpHexString(value);
    Log.i(TAG, "sendBtMessage: sending message: " + static_last_sent_hexdump);

    // Experimental support for rfduino from Tomasz Stachowicz
    if (use_rfduino_bluetooth) {
        Log.w(TAG, "sendBtMessage: use_rfduino_bluetooth");
        if (mCharacteristicSend == null) {
            status("Error: mCharacteristicSend was null in sendBtMessage");
            Log.e(TAG, lastState);
            servicesDiscovered = DISCOVERED.NULL;
            return false;
        }
        return writeChar(mCharacteristicSend, value);
    }

    // BLUCON NULL HERE? HOW TO RESOLVE?
    if (mCharacteristic == null) {
        status("Error: mCharacteristic was null in sendBtMessage");
        Log.e(TAG, lastState);
        servicesDiscovered = DISCOVERED.NULL;
        return false;
    }

    if (mCharacteristicSend != null && mCharacteristicSend != mCharacteristic) {
        return writeChar(mCharacteristicSend, value);
    }

    return writeChar(mCharacteristic, value);
}
 
Example 6
Source File: DexCollectionService.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
private synchronized boolean sendBtMessage(final ByteBuffer message) {
    // TODO affirm send happened
    //check mBluetoothGatt is available
    Log.i(TAG, "sendBtMessage: entered");
    if (mBluetoothGatt == null) {
        Log.w(TAG, "sendBtMessage: lost connection");
        if (JoH.ratelimit("sendbtmessagelost", 60)) {
            mConnectionState = STATE_DISCONNECTED;
            setRetryTimer();
        }
        return false;
    }

    final byte[] value = message.array();

    static_last_sent_hexdump = HexDump.dumpHexString(value);
    Log.i(TAG, "sendBtMessage: sending message: " + static_last_sent_hexdump);

    // Experimental support for rfduino from Tomasz Stachowicz
    if (use_rfduino_bluetooth) {
        Log.w(TAG, "sendBtMessage: use_rfduino_bluetooth");
        if (mCharacteristicSend == null) {
            status("Error: mCharacteristicSend was null in sendBtMessage");
            Log.e(TAG, lastState);
            servicesDiscovered = DISCOVERED.NULL;
            return false;
        }
        return writeChar(mCharacteristicSend, value);
    }

    // BLUCON NULL HERE? HOW TO RESOLVE?
    if (mCharacteristic == null) {
        status("Error: mCharacteristic was null in sendBtMessage");
        Log.e(TAG, lastState);
        servicesDiscovered = DISCOVERED.NULL;
        return false;
    }

    if (mCharacteristicSend != null && mCharacteristicSend != mCharacteristic) {
        return writeChar(mCharacteristicSend, value);
    }

    return writeChar(mCharacteristic, value);
}
 
Example 7
Source File: BaseTx.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public String toHexDump() {
    return HexDump.dumpHexString(getBytes());
}
 
Example 8
Source File: BaseTx.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public String toHexDump() {
    return HexDump.dumpHexString(getBytes());
}
 
Example 9
Source File: DexCollectionService.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
private synchronized boolean sendBtMessage(final ByteBuffer message) {
    // TODO affirm send happened
    //check mBluetoothGatt is available
    Log.i(TAG, "sendBtMessage: entered");
    if (mBluetoothGatt == null) {
        Log.w(TAG, "sendBtMessage: lost connection");
        if (JoH.ratelimit("sendbtmessagelost", 60)) {
            mConnectionState = STATE_DISCONNECTED;
            setRetryTimer();
        }
        return false;
    }

    final byte[] value = message.array();

    static_last_sent_hexdump = HexDump.dumpHexString(value);
    Log.i(TAG, "sendBtMessage: sending message: " + static_last_sent_hexdump);

    // Experimental support for rfduino from Tomasz Stachowicz
    if (use_rfduino_bluetooth) {
        Log.w(TAG, "sendBtMessage: use_rfduino_bluetooth");
        if (mCharacteristicSend == null) {
            status("Error: mCharacteristicSend was null in sendBtMessage");
            Log.e(TAG, lastState);
            servicesDiscovered = DISCOVERED.NULL;
            return false;
        }
        return writeChar(mCharacteristicSend, value);
    }

    // BLUCON NULL HERE? HOW TO RESOLVE?
    if (mCharacteristic == null) {
        status("Error: mCharacteristic was null in sendBtMessage");
        Log.e(TAG, lastState);
        servicesDiscovered = DISCOVERED.NULL;
        return false;
    }

    if (mCharacteristicSend != null && mCharacteristicSend != mCharacteristic) {
        return writeChar(mCharacteristicSend, value);
    }

    return writeChar(mCharacteristic, value);
}
 
Example 10
Source File: DexCollectionService.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
private synchronized boolean sendBtMessage(final ByteBuffer message) {
    // TODO affirm send happened
    //check mBluetoothGatt is available
    Log.i(TAG, "sendBtMessage: entered");
    if (mBluetoothGatt == null) {
        Log.w(TAG, "sendBtMessage: lost connection");
        if (JoH.ratelimit("sendbtmessagelost", 60)) {
            mConnectionState = STATE_DISCONNECTED;
            setRetryTimer();
        }
        return false;
    }

    final byte[] value = message.array();

    static_last_sent_hexdump = HexDump.dumpHexString(value);
    Log.i(TAG, "sendBtMessage: sending message: " + static_last_sent_hexdump);

    // Experimental support for rfduino from Tomasz Stachowicz
    if (use_rfduino_bluetooth) {
        Log.w(TAG, "sendBtMessage: use_rfduino_bluetooth");
        if (mCharacteristicSend == null) {
            status("Error: mCharacteristicSend was null in sendBtMessage");
            Log.e(TAG, lastState);
            servicesDiscovered = DISCOVERED.NULL;
            return false;
        }
        return writeChar(mCharacteristicSend, value);
    }

    // BLUCON NULL HERE? HOW TO RESOLVE?
    if (mCharacteristic == null) {
        status("Error: mCharacteristic was null in sendBtMessage");
        Log.e(TAG, lastState);
        servicesDiscovered = DISCOVERED.NULL;
        return false;
    }

    if (mCharacteristicSend != null && mCharacteristicSend != mCharacteristic) {
        return writeChar(mCharacteristicSend, value);
    }

    return writeChar(mCharacteristic, value);
}
 
Example 11
Source File: BaseTx.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public String toHexDump() {
    return HexDump.dumpHexString(getBytes());
}
 
Example 12
Source File: BaseTx.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public String toHexDump() {
    return HexDump.dumpHexString(getBytes());
}