brnunes / Android-SNMP

Android SMNP Agent and Manager
67 stars 26 forks source link

How to realize the function of the trap on mobile phone? #1

Open DDDDDFG opened 8 years ago

DDDDDFG commented 8 years ago

` private class SendTrap extends AsyncTask<Void, Void, Void> { protected Void doInBackground(Void... params) { PDUv1 pdu = new PDUv1(); pdu.setType(PDU.V1TRAP); pdu.setGenericTrap(PDUv1.COLDSTART); pdu.add(new VariableBinding(new OID(new int[]{ 1,3,6,1}),new Integer32(1995)));//1, 3, 6, 1, 2, 1, 1, 2

        // Specify receiver
        Address targetAddress = new UdpAddress("192.168.0.6/161");
        CommunityTarget target = new CommunityTarget();
        target.setCommunity(new OctetString("public"));
        target.setVersion(SnmpConstants.version1);
        target.setAddress(targetAddress);
        target.setRetries(2);
        target.setTimeout(1500);

        try {
            snmp.trap(pdu, target);
            Log.i(TAG, "doInBackground: !!!!!!!!!!!!!!!!!!");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}

`

This is I use the Trap right?

DDDDDFG commented 8 years ago

I have already solved.SNMP trap (pdu, target) method cannot be used, although there is no error, but also send out, but cannot find send data on the server.I am the send by directly using SNMP (pdu, target) method, so you can receive.

brnunes commented 8 years ago

The manager doesn't implement a listener for traps, so the Android device sends the trap but it's not received. SNMP4J seems to support traps, so implementing that should be simple. Take a look at this example.

DDDDDFG commented 8 years ago

For the first time to communicate with international friends, I am a student, English is very slag, is I use translation tools to communicate, very thank you for your busy schedule to take time to answer my question, thank you.

presita commented 5 years ago

Hello guys, How to connect mobile device to SNMP Device manager? I got "Error: Agent Timeout". Also I attached screenshot of SNMP device(Showing 'Unknown devices')Please help me WhatsApp Image 2019-07-22 at 4 06 48 PM