private String operation(
      String serialNumber,
      String head,
      int length,
      short l,
      String agreement,
      ByteBuf in,
      ChannelHandlerContext ctx)
      throws ParseException {
    String content = null;
    if ("7101".equals(agreement) && length == l) {

      content = byteToArray(in.readBytes(l - 17).array());
    } else if ("5100".equals(agreement)
        || "4106".equals(agreement)
        || "9965".equals(agreement)
        || "3104".equals(agreement)
        || "2001".equals(agreement)
        || "2002".equals(agreement)
        || "2003".equals(agreement)
        || "9990".equals(agreement)
        || "9992".equals(agreement) && length == l) {
      byteToArray(in.readBytes(1).array());
      content = byteToArray(in.readBytes(l - 18).array());
      String info = new String(Hex.decodeHex(content.toCharArray()));
      System.out.println(content);
      System.out.println(info);
    } else if ("9991".equals(agreement) && "$$".equals(head) && length == l) {

      content = byteToArray(in.readBytes(l - 17).array());
    } else if ("9982".equals(agreement) && "$$".equals(head) && length == l) {

      content = byteToArray(in.readBytes(l - 17).array());
    } else if ("4130".equals(agreement) && "$$".equals(head)) {

      byteToArray(in.readBytes(1).array());
      content = byteToArray(in.readBytes(l - 18).array());
    } else {

      content = byteToArray(in.readBytes(l - 17).array());
      String info = new String(Hex.decodeHex(content.toCharArray()));
      System.out.println(content);
      System.out.println(info);
    }
    return content;
  }
Beispiel #2
0
 public static byte[] hexDecode(String s) {
   try {
     return Hex.decodeHex(s.toCharArray());
   } catch (DecoderException e) {
     throw new ClientProblemException(
         "Hex content is not valid hex: " + e.getMessage() + ": " + s);
   }
 }