mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-06-05 21:49:48 +02:00
Xiaomi: Prevent NPE when not yet connected
This commit is contained in:
@@ -428,6 +428,12 @@ public abstract class XiaomiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendCommand(final TransactionBuilder builder, final XiaomiProto.Command command) {
|
public void sendCommand(final TransactionBuilder builder, final XiaomiProto.Command command) {
|
||||||
|
if (this.characteristicCommandWrite == null) {
|
||||||
|
// Can sometimes happen in race conditions when connecting + receiving calendar event or weather updates
|
||||||
|
LOG.warn("characteristicCommandWrite is null!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME builder is ignored
|
// FIXME builder is ignored
|
||||||
final byte[] commandBytes = command.toByteArray();
|
final byte[] commandBytes = command.toByteArray();
|
||||||
LOG.debug("Sending command {}", GB.hexdump(commandBytes));
|
LOG.debug("Sending command {}", GB.hexdump(commandBytes));
|
||||||
@@ -435,6 +441,12 @@ public abstract class XiaomiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendCommand(final TransactionBuilder builder, final byte[] commandBytes) {
|
public void sendCommand(final TransactionBuilder builder, final byte[] commandBytes) {
|
||||||
|
if (this.characteristicCommandWrite == null) {
|
||||||
|
// Can sometimes happen in race conditions when connecting + receiving calendar event or weather updates
|
||||||
|
LOG.warn("characteristicCommandWrite is null!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME builder is ignored
|
// FIXME builder is ignored
|
||||||
this.characteristicCommandWrite.write(commandBytes);
|
this.characteristicCommandWrite.write(commandBytes);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user