// Get Operator public string GetOPerator() { if (comm.IsOpen()) { OperatorInfo info = comm.GetCurrentOperator(); return(info.TheOperator); } return("None"); }
static void infotimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { bool modemstatus = _comm.IsOpen() && _comm.IsConnected(); string modeminfo = ""; try { if (modemstatus) { modeminfo = $"\r\nPort: {_comm.PortName}\r\nOperator: {_comm.GetCurrentOperator().TheOperator}" + $"\r\nSignal: { (_comm.GetSignalQuality().SignalStrength == 99 ? "Unknown" : (Math.Floor(((double)_comm.GetSignalQuality().SignalStrength / 31) * 100)) + "%")}\r\n"; } } catch (Exception) { modemstatus = false; } _logger.Info($"Application Information:\r\nModem status: {(modemstatus ? "OK" : "ERROR") + modeminfo}"); }
public void connect() { string cmbCOM = "COM" + comms.Text; comm = new GsmCommMain(cmbCOM, 9600, 150); try { if (comm.IsConnected()) { info.Content = comm.IdentifyDevice().Manufacturer.ToUpper().ToString(); info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().Manufacturer.ToUpper().ToString(); info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().Model.ToUpper().ToString(); info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().Revision.ToUpper().ToString(); info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().SerialNumber.ToUpper().ToString(); info.Content = info.Content + Environment.NewLine + comm.GetCurrentOperator(); info.Content = info.Content + Environment.NewLine + comm.GetSignalQuality(); info.Content = info.Content + Environment.NewLine + comm.GetSmscAddress(); info.Content = info.Content + Environment.NewLine + comm.GetSubscriberNumbers(); save.Visibility = Visibility.Visible; Console.WriteLine("comm is already open"); } else { Console.WriteLine("comm is not open"); comm.Open(); info.Content = comm.IdentifyDevice().Manufacturer.ToUpper().ToString(); info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().Manufacturer.ToUpper().ToString(); info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().Model.ToUpper().ToString(); info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().Revision.ToUpper().ToString(); info.Content = info.Content + Environment.NewLine + comm.IdentifyDevice().SerialNumber.ToUpper().ToString(); save.Visibility = Visibility.Visible; } } catch (Exception r) { MessageBox.Show(r.Message); } }