public bool Set(string varName, object value, int timeout) { var socket = new SnmpSocket(_manager); var request = new SetMessage(); BuildRequest(request, new Variable(_manager.Mib[varName], value.ToString())); var task = Task.Run(() => socket.GetResponse(request, DeviceEndPoint)); if (task.Wait(timeout)) { return(task.Result.ErrorStatus == ErrorStatus.Success); } return(false); }
public object Get(string varName, int timeout) { var socket = new SnmpSocket(_manager); var request = new GetMessage(); BuildRequest(request, new Variable(_manager.Mib[varName])); var task = Task.Run(() => socket.GetResponse(request, DeviceEndPoint)); if (task.Wait(timeout)) { // TODO: make sure that the response is returned in the first [0] element and not in the last return(task.Result.Variables[0].Value as object); } return(null); }