接收 USSD 消息在 Windows Mobile 6.5 HSDPA 设备上不起作用 (Opennetcf.Telephony)

发布于 2024-12-11 04:34:47 字数 4936 浏览 0 评论 0原文

我一直在使用 OpenNetCF.Telephony (可在此处 http://tapi.codeplex.com 获取)以及此包装器使用 TAPI 发送和接收 USSD 消息非常容易;到目前为止,我一直在许多 GSM 设备上使用它,并且运行完美!

最近,我在 Motorola MC65 和 ES400(均为 3.5G HSDPA 设备)上测试了我的程序,并且能够毫无问题地发送我的 USSD 请求,但响应不会被读取消息功能捕获;奇怪的是,它是在我使用过的所有其他 GSM 设备中完美运行的相同代码,因为 USSD 在响应时会显示一个弹出窗口,我知道运营商的服务器响应速度非常快,但我的 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 设备所做的一切(使用代码),一切似乎都工作得完全相同,只是阅读响应就是问题,我真的不知道如何让它工作......

预先感谢您尝试任何其他想法或更改参数......

I've been using OpenNetCF.Telephony (available here http://tapi.codeplex.com), with this wrapper is pretty easy to use TAPI to send and receive USSD messages; until now I had been using it with many GSM devices and it worked flawlessy!!!

Recently I tested my program on a Motorola MC65 and ES400, both 3.5G HSDPA devices, and was able to send my USSD request without any problem, but the response doesnt get caught by the read message function; the strange thing is that it's the same code that has worked perfectly in all other GSM devices I have worked with, since USSD shows up a pop up window when it responds, I know that the Carrier's server is responding pretty quickly but my LineGetMessage call hits the timeout without noticing that the response was received...

Here is an extract of a little sample I made to test the functionality, it can be tested anywhere since any carrier's platform would respond with an "UNKNOWN APPLICATION" or similar message if it isn't expecting the message sent, but even this response doesn't get caught...

        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;
        }
    }

This is the code that doesn't get a response, it hits the timeout every time :(

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

I know I have initialized the TAPI right since I have sent the parameter to register for events, actually it manages to receive a confirmation Linemessage from sending the USSD request which is handled by another thread instantiated in the TAPI wrapper, but the event of the actual response is never raised in these devices.

Is there a change that has to be done in order to get 3/3.5G devices to work? I've been comparing everything that the 2G devices do (with the code), everything seems to work exactly the same, just reading the response is the problem, I really don't have any clue of how to make it work...

Thanks in advance for any other ideas to try or parameters to change...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文