Question

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. The only problem of using that is that i program in .net c#, and the library is an unmanaged code one.

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.

I created then an library that would call and set-up the necessary GPRS connection on windows. 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:

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)

+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. 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.

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. I also checked and the extra icon does not appear, but if i see the GPRS status it appears as it is connected.

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

Best Greetings

Was it helpful?

Solution

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. 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? 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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top