Пример #1
0
        // SNMP version 1 is default
        public SnmpPacket(string community, string oidString, SnmpMethod method, byte snmpVersion = 0, uint packetId = 1, byte errorStatus = 0, byte errorIndex = 0)
        {
            this.community   = community;
            this.method      = method;
            this.snmpVersion = snmpVersion;
            this.packetId    = packetId;
            this.errorStatus = errorStatus;
            this.errorIndex  = errorIndex;
            var oidConverter = new OidConverter();
            var oid          = oidConverter.ToByteArray(oidString);

            Create(oid);
        }
Пример #2
0
 public virtual async Task Start(string ip, string mib, SnmpMethod method, int pingEveryMs, Action <SnmpData> onResponse, CancellationToken token = default(CancellationToken))
 {
     while (!token.IsCancellationRequested)
     {
         onResponse(_snmpService.Request(ip, mib, method));
         try
         {
             await Task.Delay(TimeSpan.FromMilliseconds(pingEveryMs), token);
         }
         catch (TaskCanceledException)
         {
             break;
         }
     }
 }
 public void Send(string oid, SnmpMethod method)
 {
     Method = method;
     Send(oid);
 }