mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 11:26:47 +01:00
Xiaomi: Prevent NPE when not yet connected
This commit is contained in:
parent
ce1d095074
commit
81ca617601
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user