mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-29 12:05:53 +01:00
Xiaomi Spp: Log plaintext payload
It's very hard to troubleshoot issues with Xiaomi Spp devices from logs without having access to the plain-text payload, so we now log it.
This commit is contained in:
parent
b704276e49
commit
db33bc3ee9
@ -16,6 +16,8 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.xiaomi;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -142,6 +144,8 @@ public class XiaomiSppPacket {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(Locale.ROOT,
|
||||
"SppPacket{ channel=0x%x, flag=%b, needsResponse=%b, opCode=0x%x, frameSerial=0x%x, dataType=0x%x, payloadSize=%d }",
|
||||
|
@ -48,6 +48,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btbr.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btbr.actions.PlainAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btbr.actions.SetDeviceStateAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btbr.actions.SetProgressAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class XiaomiSppSupport extends XiaomiConnectionSupport {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(XiaomiSppSupport.class);
|
||||
@ -283,21 +284,19 @@ public class XiaomiSppSupport extends XiaomiConnectionSupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCommand(String taskName, XiaomiProto.Command command) {
|
||||
public void sendCommand(final String taskName, final XiaomiProto.Command command) {
|
||||
try {
|
||||
XiaomiSppPacket packet = XiaomiSppPacket.fromXiaomiCommand(command, frameCounter.getAndIncrement(), false);
|
||||
LOG.debug("sending packet: {}", packet);
|
||||
TransactionBuilder builder = this.commsSupport.createTransactionBuilder("send " + taskName);
|
||||
builder.write(packet.encode(mXiaomiSupport.getAuthService(), encryptionCounter));
|
||||
final TransactionBuilder builder = this.commsSupport.createTransactionBuilder("send " + taskName);
|
||||
sendCommand(builder, command);
|
||||
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);
|
||||
LOG.error("Caught unexpected exception while sending command, device may not have been informed!", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendCommand(final TransactionBuilder builder, final XiaomiProto.Command command) {
|
||||
XiaomiSppPacket packet = XiaomiSppPacket.fromXiaomiCommand(command, frameCounter.getAndIncrement(), false);
|
||||
LOG.debug("sending packet: {}", packet);
|
||||
final XiaomiSppPacket packet = XiaomiSppPacket.fromXiaomiCommand(command, frameCounter.getAndIncrement(), false);
|
||||
LOG.debug("sending packet: {}, payload={}", packet, GB.hexdump(packet.getPayload()));
|
||||
|
||||
builder.write(packet.encode(mXiaomiSupport.getAuthService(), encryptionCounter));
|
||||
// do not queue here, that's the job of the caller
|
||||
|
Loading…
Reference in New Issue
Block a user