1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-09-27 16:56:57 +02:00

Xiaomi: fix GB crashing when sending command to disconnected SPP-based device

This commit is contained in:
MrYoranimo 2024-04-02 01:13:53 +02:00 committed by José Rebelo
parent 28066b9b7d
commit 7fb0d19374

View File

@ -277,11 +277,15 @@ public class XiaomiSppSupport extends XiaomiConnectionSupport {
@Override @Override
public void sendCommand(String taskName, XiaomiProto.Command command) { public void sendCommand(String taskName, XiaomiProto.Command command) {
XiaomiSppPacket packet = XiaomiSppPacket.fromXiaomiCommand(command, frameCounter.getAndIncrement(), false); try {
LOG.debug("sending packet: {}", packet); XiaomiSppPacket packet = XiaomiSppPacket.fromXiaomiCommand(command, frameCounter.getAndIncrement(), false);
TransactionBuilder builder = this.commsSupport.createTransactionBuilder("send " + taskName); LOG.debug("sending packet: {}", packet);
builder.write(packet.encode(mXiaomiSupport.getAuthService(), encryptionCounter)); TransactionBuilder builder = this.commsSupport.createTransactionBuilder("send " + taskName);
builder.queue(this.commsSupport.getQueue()); builder.write(packet.encode(mXiaomiSupport.getAuthService(), encryptionCounter));
builder.queue(this.commsSupport.getQueue());
} catch (final Exception ex) {
LOG.error("Caught unexpected exception while sending command, device may not have been informed!: {}", ex, ex);
}
} }
public void sendCommand(final TransactionBuilder builder, final XiaomiProto.Command command) { public void sendCommand(final TransactionBuilder builder, final XiaomiProto.Command command) {