来电显示 - 无法获取传入号码

本文关键字:号码 获取 显示 来电 | 更新日期: 2023-09-27 18:36:26

UI 上的标签一直读取"RING RING",然后返回到空"。但是,它不显示传入的号码,这是我想要的。我试图添加一个 if 函数检查数据中是否有"0",但由于某种原因仍然不起作用。

以下是我的代码:

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
    {
        public CallerID()
        {
            InitializeComponent();
            port.Open();
            WatchModem();
            SetModem();
        }
        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.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('0'))
                    lblCallerIDTitle.Invoke(new SetCallerIdText(() => lblCallerIDTitle.Text = ReadData));
            }
            else
                lblCallerIDTitle.Text = ReadData;
        }
    }
}

来电显示 - 无法获取传入号码

自从我使用调制解调器以来已经有一段时间了,但是您的调制解调器必须支持CallerID(我相信现在大多数人都支持),您必须从您的电信公司获得CallerID服务(我确定您这样做),最后,在初始化期间将有一个AT命令发送到调制解调器以打开CallerID报告。 根据您使用的调制解调器型号,命令可能会有所不同,但通常是AT#CID=1 。 调制解调器手册应包含要使用的 AT 代码。

请注意,传入号码本身是在第一个和第二个响铃之间发送的。

这可能会为你指明正确的方向。

http://www.yes-tele.com/modem.html