简体   繁体   English

在Windows CE 6.0中使用opennetcf Ras创建持久RAS连接

[英]Creating persistent RAS connection with opennetcf Ras in Windows CE 6.0

I'm in need to create an GPRS connection in an PDA that has windows ce 6. Now normally i would had to use the manufacturer's dll to create that, but they said that they use ras to accomplish this. 我需要在具有Windows ce 6的PDA中创建GPRS连接。现在通常我必须使用制造商的dll来创建该连接,但是他们说他们使用ras来完成此操作。 The only problem of using that is that i program in .net c#, and the library is an unmanaged code one. 使用它的唯一问题是我在.net c#中编程,而该库是不受管的代码之一。

Fortunately i came by the opennetcf ras library that does already the necessary pInvokes for the windows ras library, the only problem being the poor documentation. 幸运的是,我来自opennetcf ras库,该库已经对Windows ras库进行了必要的pInvokes调用,唯一的问题是文档不佳。

I created then an library that would call and set-up the necessary GPRS connection on windows. 然后,我创建了一个库,该库将在Windows上调用并建立必要的GPRS连接。 I'm using an Portuguese telecom operator that uses the following definitions: 我使用的葡萄牙电信运营商使用以下定义:

Operator Name: Optimus P
Apn:  umts
Password: *******
User: ******

Consulting the gsm module definition, i had the following modem settings: 咨询gsm模块定义,我具有以下调制解调器设置:

Connection Name: GPRS
Device: Hayes Compatible on COM1:
Baund Rate:115200
Data Bits: 8
Parity:1
Stop Bits: 1
Flow Control: Hardware

and of course the extra settings (or how i call it the atCall) 当然还有额外的设置(或者我怎么称呼它为atCall)

+cgdcont=1, "ip", "umts"

This settings when i use the control panel and do an connect with that profile, it connects and i'm able to call all the webservices without an error. 当我使用控制面板并使用该配置文件进行连接时,此设置可以连接,并且我可以无错误地调用所有Web服务。 It also shows an extra profile for the modem that shows the settings for the device, incluid the ipaddress, subnet mask and even the default gateway. 它还显示了调制解调器的额外配置文件,其中显示了设备的设置,包括ip地址,子网掩码,甚至是默认网关。

The problem is that when i use the library that i created to create an gprs connection programatically, and then call the webservices at some point it throws me an web exception : The remote name could not be resolved. 问题是,当我使用自己创建的库以编程方式创建gprs连接,然后在某个时候调用webservices时,将引发Web异常:无法解析远程名称。 I also checked and the extra icon does not appear, but if i see the GPRS status it appears as it is connected. 我也检查了一下,但没有出现多余的图标,但是如果我看到GPRS状态,它就会在连接时显示出来。

The code that create, destroys and query if it exists an connection is as follows: 创建,销毁和查询连接是否存在的代码如下:

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using OpenNETCF.Net;
using OpenNETCF.Diagnostics;

namespace gsmAdapterNet
{
/// <summary>
/// GPRS Connection class
/// </summary>
public class GPRS
{
    private static string connectionName = "GPRS";


    /// <summary>
    /// Connects the GPRS.
    /// </summary>
    /// <returns></returns>
    public static bool ConnectGPRS()
    {

            //precisamos de obter as connecoes e ligar

            RasEntryCollection connecoesPossiveis = Ras.Entries;
            RasEntry _currentEntry = connecoesPossiveis[connectionName];
            _currentEntry.RasStatus += new RasNotificationHandler(RasStatusHandler);
            RasError resultado = _currentEntry.Dial(false);
            if (resultado == RasError.Success)
                return true;
            else
                return false;


    }

    static void RasStatusHandler(int hConn, RasConnState State, RasError ErrorCode)
    {
        Logger.WriteLine("");
        Logger.WriteLine("RAS STATUS: " + ErrorCode.ToString() + " , State: " + State.ToString());
    }


    /// <summary>
    /// Disconnects the GPRS.
    /// </summary>
    /// <returns></returns>
    public static void DisconnectGPRS()
    {
        RasEntryCollection entradas = Ras.Entries;
        foreach (RasEntry possivelEntrada in entradas)
        {
            if (possivelEntrada.Name == connectionName)
            {
                possivelEntrada.Hangup();
            }
        }


    }

    /// <summary>
    /// Determines whether this instance is connected.
    /// </summary>
    /// <returns>
    ///     <c>true</c> if this instance is connected; otherwise, <c>false</c>.
    /// </returns>
    public static bool isConnected()
    {

        RasConnection[] conecoes = Ras.ActiveConnections;
        foreach (RasConnection conecao in conecoes)
        {
            if (conecao.Name == connectionName)
                return true;
        }
        return false;

    }

    /// <summary>
    /// Dumps the ras entries.
    /// </summary>
    public static void DumpRasEntries()
    {
        foreach (RasEntry entry in Ras.Entries)
        {
            Logger.DumpRasEntry(entry);
        }
    }

}

} }

So resuming the question is how i can create an viable connection with the opennetcf ras library 所以,问题是我如何与opennetcf ras库建立可行的连接

Best Greetings 最好的问候

It seems as if the network interface for the GPRS connection that you get when dialing in is not configured with the correct DNS servers. 似乎您拨入时获得的GPRS连接的网络接口未使用正确的DNS服务器进行配置。 Alternatively, the domain names needed for your service calls may be wrong. 或者,您的服务呼叫所需的域名可能是错误的。

To verify this: 要验证这一点:

Is it only a specific web service whose domain name cannot be resolved? 仅仅是域名无法解析的特定Web服务吗? Is it always the same? 总是一样吗? Do others work? 别人工作吗? Can you simply HTTP GET something like http://stackoverflow.com programmatically after the connection has been established? 建立连接后,能否通过编程方式简单地通过HTTP GET来获取类似http://stackoverflow.com的内容

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

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