C#如何判断短信猫来电。(就是接到电话)
大神来啊 。
[解决办法]
短信猫有提供这个方法么...
看接口资料吧
[解决办法]
//--------------------------------------- // <copyright file="RILHelper.cs" company="Yaping Xin"> // Copyright (c) Yaping Xin. All rights reserved. // </copyright> // <Description>Helper class for Radio Interface Layer.</Description> //--------------------------------------- namespace MobileAutomation.Projects.VDFStressTesting { using System; using System.Runtime.InteropServices; using System.Threading; /// <summary> /// Helper class for Radio Interface Layer. /// </summary> public class RILHelper { /// <summary> /// Delegation definition of Log event handler /// </summary> /// <param name="message">Message to transfer</param> public delegate void LogHandler(string message); /// <summary>Event handler to record log</summary> public static event LogHandler Log; /// <summary>AutoResetEvent object</summary> private static AutoResetEvent waithandle = new AutoResetEvent(false); /// <summary>HRESULT to RIL object</summary> private static IntPtr hRil = IntPtr.Zero; /// <summary>HRESULT to result</summary> private static IntPtr hRes = IntPtr.Zero; /// <summary> /// RILRESULTCALLBACK delegation /// http://msdn.microsoft.com/en-us/library/aa920069.aspx /// </summary> /// <param name="dwCode">Specifies the result code.</param> /// <param name="hrCmdID">ID returned by the command that originated this response.</param> /// <param name="lpData">Data associated with the notification.</param> /// <param name="cbData">Size of the structure pointed to by lpData.</param> /// <param name="dwParam">Specifies the parameter passed to RIL_Initialize or RIL_InitializeEmergency.</param> public delegate void RILRESULTCALLBACK( uint dwCode, IntPtr hrCmdID, IntPtr lpData, uint cbData, uint dwParam); /// <summary> /// RILNOTIFYCALLBACK delegation /// http://msdn.microsoft.com/en-us/library/aa922465.aspx /// </summary> /// <param name="dwCode">Specifies the notification code. </param> /// <param name="lpData">Data associated with the notification.</param> /// <param name="cbData">Size of the structure pointed to by lpData.</param> /// <param name="dwParam">Specifies the parameter passed to RIL_Initialize or RIL_InitializeEmergency.</param> public delegate void RILNOTIFYCALLBACK( uint dwCode, IntPtr lpData, uint cbData, uint dwParam); /// <summary> /// RIL Initialize /// </summary> /// <returns>RIL HRESULT</returns> public static IntPtr Initialize() { return RIL_Initialize(1, new RILRESULTCALLBACK(RilResultCallback), new RILNOTIFYCALLBACK(RilNotifyCallback), 0xffffffff, 0, out hRil); } /// <summary> /// RIL Deinitialize /// </summary> /// <returns>RIL HRESULT</returns> public static IntPtr Deinitialize() { return RIL_Deinitialize(hRil); } /// <summary> /// Retrieves the system time from the network. /// </summary> /// <returns>Positive HRESULT values</returns> public static IntPtr GetSystemTime() { return RIL_GetSystemTime(hRil); } /// <summary> /// RIL Reslt Callback Proc /// </summary> /// <param name="dwCode">Specifies the result code.</param> /// <param name="hrCmdID">ID returned by the command that originated this response.</param> /// <param name="lpData">Data associated with the notification.</param> /// <param name="cbData">Size of the structure pointed to by lpData.</param> /// <param name="dwParam">Specifies the parameter passed to RIL_Initialize or RIL_InitializeEmergency.</param> public static void RilResultCallback( uint dwCode, IntPtr hrCmdID, IntPtr lpData, uint cbData, uint dwParam) { RIL_NCLASS dwClass = (RIL_NCLASS)dwCode & RIL_NCLASS.ALL; string message = string.Format("ResultCallback - dwCode: {0}, RIL_NCLASS: {1}", dwCode, dwClass); RILHelper.OnLog(message); waithandle.Set(); } /// <summary> /// RIL Notify Callback Proc /// </summary> /// <param name="dwCode">Specifies the notification code. </param> /// <param name="lpData">Data associated with the notification.</param> /// <param name="cbData">Size of the structure pointed to by lpData.</param> /// <param name="dwParam">Specifies the parameter passed to RIL_Initialize or RIL_InitializeEmergency.</param> public static void RilNotifyCallback( uint dwCode, IntPtr lpData, uint cbData, uint dwParam) { RIL_NCLASS dwClass = (RIL_NCLASS)dwCode & RIL_NCLASS.ALL; string message = string.Format("NotifyCallback - dwCode: {0}, RIL_NCLASS: {1}", dwCode, dwClass); RILHelper.OnLog(message); waithandle.Set(); } /// <summary> /// Record the message /// </summary> /// <param name="message">Message to transfer</param> protected static void OnLog(string message) { if (RILHelper.Log != null) { RILHelper.Log(message); } } [DllImport("ril.dll")] private static extern IntPtr RIL_Initialize( uint dwIndex, RILRESULTCALLBACK pfnResult, RILNOTIFYCALLBACK pfnNotify, uint dwNotificationClasses, uint dwParam, out IntPtr lphRil); [DllImport("ril.dll")] private static extern IntPtr RIL_Deinitialize(IntPtr hRil); [DllImport("ril.dll")] private static extern IntPtr RIL_GetSystemTime(IntPtr hRil); } }
[解决办法]
一般的短信猫来电后会在串口输出RING
连续的输出
楼主只要在串口读取到RING字符串就可以判断是来电了
OK
[解决办法]
我用的Wavecom短信猫在来电时设备会向串口发送"RING"。
[解决办法]
RING正解