Skip to content

Commit

Permalink
refactor: 根据依赖包调整代码
Browse files Browse the repository at this point in the history
  • Loading branch information
toggery committed Jun 24, 2022
1 parent 82aaaa8 commit e7f5541
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/main/java/io/github/toggery/jt808/codec/B0702Codec.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ private B0702Codec() {}
public void encode(int version, ByteBuf buf, B0702 target) {
Codec.writeByte(buf, target.getStatus());
Codec.writeBcd(buf, target.getTime(), 6);
if (target.getStatus() != 1) {
if (target.getStatus() != B0702.STATUS_IC_CARD_INSERTED) {
return;
}

Codec.writeByte(buf, target.getResult());
if (target.getResult() != 0) {
if (!target.isSuccessful()) {
return;
}

Expand All @@ -51,12 +51,12 @@ public void decode(int version, ByteBuf buf, B0702 target) {

target.setStatus(Codec.readByte(buf));
target.setTime(Codec.readBcd(buf, 6, false));
if (target.getStatus() != 1) {
if (target.getStatus() != B0702.STATUS_IC_CARD_INSERTED) {
return;
}

target.setResult(Codec.readByte(buf));
if (target.getResult() != 0) {
if (!target.isSuccessful()) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/github/toggery/jt808/codec/B0805Codec.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private B0805Codec() {}
public void encode(int version, ByteBuf buf, B0805 target) {
Codec.writeWord(buf, target.getReplySn());
Codec.writeByte(buf, target.getResult());
if (target.getResult() != 0) {
if (!target.isSuccessful()) {
return;
}

Expand All @@ -44,7 +44,7 @@ public void decode(int version, ByteBuf buf, B0805 target) {

target.setReplySn(Codec.readWord(buf));
target.setResult(Codec.readByte(buf));
if (target.getResult() != 0) {
if (!target.isSuccessful()) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/github/toggery/jt808/codec/B8100Codec.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private B8100Codec() {}
public void encode(int version, ByteBuf buf, B8100 target) {
Codec.writeWord(buf, target.getReplySn());
Codec.writeByte(buf, target.getResult());
if (target.getResult() == 0) {
if (target.isSuccessful()) {
Codec.writeString(buf, target.getToken());
}
}
Expand All @@ -28,7 +28,7 @@ public void encode(int version, ByteBuf buf, B8100 target) {
public void decode(int version, ByteBuf buf, B8100 target) {
target.setReplySn(Codec.readWord(buf));
target.setResult(Codec.readByte(buf));
target.setToken(target.getResult() == 0 ? Codec.readString(buf) : null);
target.setToken(target.isSuccessful() ? Codec.readString(buf) : null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ static B8004 b8004() {
static B8100 b8100() {
final B8100 b = new B8100();
b.setReplySn(1);
b.setResult(B8100.RESULT_VEHICLE_REGISTERED);
b.setResult(B8100.RESULT_SUCCESSFUL);
b.setToken("token");

return b;
Expand Down

0 comments on commit e7f5541

Please sign in to comment.