接收不能在Windows Mobile 6.5 HSDPA设备上运行的USSD消息(Opennetcf.Telephony)

时间:2011-10-20 14:58:23

标签: windows-mobile ussd

我一直在使用OpenNetCF.Telephony(这里提供http://tapi.codeplex.com),这个包装器很容易使用TAPI发送和接收USSD消息;直到现在我一直在使用它与许多GSM设备,它工作完美!

最近,我在摩托罗拉MC65和ES400上测试了我的程序,这两款都是3.5G HSDPA设备,能够毫无问题地发送我的USSD请求,但是响应并没有被读取消息功能捕获;奇怪的是,它与我曾经使用的所有其他GSM设备完美配合的代码相同,因为USSD在响应时显示弹出窗口,我知道Carrier的服务器反应非常快但我的LineGetMessage呼叫命中超时没有注意到收到了响应......

以下是我为测试功能而制作的一个小样本的摘录,它可以在任何地方进行测试,因为任何运营商的平台都会响应“未知的应用程序”或类似的消息,如果它不期望发送的消息,甚至这个回应没有被抓住......

        private void btnUSSDSend_Click(object sender, EventArgs e)
    {
        int ret = 0; 
        for (int i = 0; i < m_tapi.NumberOfDevices; i++)
        {

            DeviceCapabilities dc = new DeviceCapabilities(LINE_DEV_CAPS_INITIAL_SIZE); //LINEDEVCAPS
            dc.Store(); 
            int dwVersion = m_tapi.NegotiateVersion(i);
            ret = NativeMethods.lineGetDevCaps(m_tapi.hLineApp, i, dwVersion, 0, dc.Data); //NativeTapi.lineGetDevCaps
            if (ret < 0)
            {
                MessageBox.Show(((ErrorCode)ret).ToString()); //LINEERR
            }

            if ((ErrorCode)ret == ErrorCode.StructureTooSmall)  //LINEERR  STRUCTURETOOSMALL
            {
                dc.Data = new byte[dc.NeededSize]; //dc.dwNeededSize
                ret = NativeMethods.lineGetDevCaps(m_tapi.hLineApp, i, dwVersion, 0, dc.Data); //NativeTapi
            }

            dc.Load();

            DeviceCaps.Add( i, dc);

            AddressStatus ac = new AddressStatus(1024);
            ac.Store();
            ret = NativeMethods.lineGetAddressCaps(m_tapi.hLineApp, i, 0, dwVersion, 0, ac.Data); //NativeTapi
            ac.Load();
            ac = null;

        }


        bool found = false;
        foreach (KeyValuePair<int, DeviceCapabilities> entry in DeviceCaps) //LINEDEVCAPS
        {
            DeviceCapabilities dc = entry.Value;  //LINEDEVCAPS 
            found = true;
            if (dc != null && dc.ProviderName.StartsWith(NativeMethods.CELLTSP_PROVIDERINFO_STRING)) //CellTSP.CELLTSP_PROVIDERINFO_STRING
            {
                m_line = m_tapi.CreateLine(entry.Key,  MediaMode.DataModem  | MediaMode.InteractiveVoice, CallPrivilege.Monitor |CallPrivilege.Owner ); //LINEMEDIAMODE LINECALLPRIVILEGE

                byte[] dialArray; 
                LineMessage msg; //LINEMESSAGE
                int flags = 0;
                byte[] chResponse;
                string Mensaje="";
                string dial = "*888#";
                int continuetonext = 0;
            needtosendanother:
                dialArray= Encoding.Unicode.GetBytes(dial);
                int length = dialArray.Length;
                int result = NativeMethods.lineSendUSSD(m_line.hLine, dialArray, dialArray.Length, 0); 
                AddMessage(dial, 0);


                while ( NativeMethods.lineGetMessage(m_tapi.hLineApp, out msg,10000)==0 ) //NativeTapi
                { 
                    if (msg.MessageID == LineMessages.LINE_DEVSPECIFIC && (int)(msg.Param1) == (int)LineMessages.LINE_USSD) //msg.dwMessageID | LINEMESSAGES | LINEDEVSPECIFIC_CELLTSP
                    {
                        flags = 0;
                        chResponse = new byte[(int)(msg.Param3)]; //msg.dwParam3
                        result = NativeMethods.lineGetUSSD(m_line.hLine, (int)(msg.Param2), chResponse, chResponse.Length, out flags); 
                        Mensaje = Encoding.Unicode.GetString(chResponse, 0, chResponse.Length);
                        AddMessage(Mensaje, 1);
                        break;
                    }
                }
                //in case I have to respond to another message
                if (Mensaje.ToUpper().Contains("ENTER PIN:"))
                {
                    continuetonext = 1;
                    dial = "1234";
                }
                //some more conditions here...
                //
                if (Mensaje.ToUpper().Contains("TRANSFERED"))
                {
                    continuetonext = 0;
                    dial = "TRANSFERED";
                }
                if (Mensaje.ToUpper().Contains("FAILED") || Mensaje.ToUpper().Contains("ERROR"))
                {
                    continuetonext = 0;
                    dial = "ERROR";
                }
                if (continuetonext==1) goto needtosendanother;
            }

        }

        if (!found)
        {
            MessageBox.Show("Error - line not found");
            return;
        }
    }

这是没有得到响应的代码,每次都会达到超时:(

while(NativeMethods.lineGetMessage(m_tapi.hLineApp,out msg,10000)== 0)

我知道我已经初始化了TAPI,因为我已经发送了参数来注册事件,实际上它设法从发送USSD请求接收确认Linemessage,该请求由在TAPI包装器中实例化的另一个线程处理,但是事件这些设备中从未提出实际响应。

为了让3 / 3.5G设备正常工作,是否需要进行更改?我一直在比较2G设备所做的一切(用代码),一切看起来完全一样,只是阅读响应是问题,我真的没有任何关于如何使它工作的线索......

提前感谢任何其他尝试或改变参数的想法......

0 个答案:

没有答案
相关问题