简体   繁体   English

来电显示检查来电是否已结束

[英]Caller ID Check if Caller has ended Call

I have a program that gets the incoming number, date and time. 我有一个程序来获取传入的号码,日期和时间。 I want to check however if the person who is ringing me has put the phone down, how can I do this? 但是,我想检查正在打铃的人是否已放下电话,我该怎么办?

Below is the code which I currently have: 以下是我目前拥有的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;

namespace CallerID
{
    public partial class CallerID : Form
    {
        int timesTicked = 0;
        Point defaultLocation = new Point();
        Point newLocation = new Point();
        public CallerID()
        {
            InitializeComponent();
            port.Open();
            SetModem(); // SetModem(); originally went after WatchModem();
            WatchModem();
            //SetModem();
            telephoneTimer.Interval = 16;
            telephoneTimer.Tick += new EventHandler(telephoneTimer_Tick);
            defaultLocation = pictureBox1.Location;
            newLocation = pictureBox1.Location;

        }

        void telephoneTimer_Tick(object sender, EventArgs e)
        {
            if (timesTicked <= 2)
                newLocation.X++;
            if (timesTicked >= 4)
                newLocation.X--;
            if (timesTicked == 6)
            {
                timesTicked = 0;
                pictureBox1.Location = defaultLocation;
                newLocation = defaultLocation;
            }
            pictureBox1.Location = newLocation;
            timesTicked++;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            WatchModem();
        }

        private SerialPort port = new SerialPort("COM3");
        string CallName;
        string CallNumber;
        string ReadData;

        private void SetModem()
        {
            port.WriteLine("AT+VCID=1\n");
            //port.WriteLine("AT+VCID=1");
            port.RtsEnable = true;
        }

        private void WatchModem()
        {
            port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
        }

        public delegate void SetCallerIdText();

        private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            ReadData = port.ReadExisting();
            //Add code to split up/decode the incoming data
            //if (lblCallerIDTitle.InvokeRequired)
            if (ReadData.Contains("NMBR"))
            {
                lblData.Invoke(new SetCallerIdText(() => lblData.Text = ReadData));
            }
            //else
            //    lblCallerIDTitle.Text = ReadData;
        }

        private void lblData_TextChanged(object sender, EventArgs e)
        {
            telephoneTimer.Start();
            button1.Visible = true;
        }
    }
}

Please ignore the Timer Code as that is just for animation. 请忽略计时器代码,因为它仅用于动画。

Have you tried the PinChanged event? 您是否尝试过PinChanged事件? Normally Carrier Detect will go low when the remote end disconnects. 通常,当远端断开连接时,载波检测将变低。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM