Ejemplo n.º 1
0
  private void sendGetRequest() {
    try {
      pdu = new BlockPdu(context);
      pdu.setPduType(BlockPdu.GET);
      pdu.addOid(ifNumber);
      AsnObject res = pdu.getResponseVariable();

      if (res != null) {
        int ifCount = ((AsnInteger) res).getValue();
        System.out.println("ifCount " + ifCount);

        pdu = new BlockPdu(context);
        pdu.setPduType(BlockPdu.GETNEXT);
        for (int no = 0; no < ifCount; no++) {
          for (int i = 1; i <= noIfEntry; i++) {
            String oid = ifEntry + "." + i + "." + no;
            pdu.addOid(oid);
          }
        }
        sendRequest(pdu);
      } else {
        System.out.println("Received no answer");
      }
    } catch (Exception exc) {
      exc.printStackTrace();
    }
  }