Search code examples
c#windows-cegprsras

Dialing RAS from WinCE device


I am working on a bigger project, which part is to create software for Motorola MC9596 scanner, but I am stuck with datatransmission trough GPRS mobile connection using FTP server.

For this purpose I am using OpenNETCF.

The problem is that I cannot dial connection with entry I created. That means there are 2 entries in device's phonebook, test1 - generated by device, when I configured connection on device manually and test2, which was created programatically using:

private const string CONNAME = "test2";
private const string PHONENR = "~GPRS!xxx.xxx-xxxxxxxx.eu";
private const string USER = "xx";
private const string PWD = "xx";
private const string DEVICE_TYPE = "modem";
private const string DEVICE_NAME = "Cellular Line";

private void createConnectionEntry()
{
    RasEntry rasEnt = new RasEntry()
    {
        Name = CONNAME,
        CountryCode = 0,
        AreaCode = "",
        PhoneNumber = PHONENR,
        DeviceName = DEVICE_NAME,
        DeviceType = DEVICE_TYPE,
        IPAddress = "0.0.0.0",
        IPAddressDns = "0.0.0.0"
    };

    /*rasEnt.Options |= (int)ConnectionOptions.UseCountryAndAreaCodes;
    rasEnt.Options |= (int)ConnectionOptions.UseLogonCredentials;*/
    rasEnt.Options = 4194304;

    RasDialParams dialParams = new RasDialParams()
    {
        UserName = USER,
        Password = PWD,
    };

    cEntry = Ras.CreateEntry(rasEnt, dialParams);
}

Note "rasEnt.Options = 4194304", what was hardcoded, to have exact copy of settings generated by device by configuring connection manually. Strange is, that if I compare 2 entries in debug mode, both are equal - that means all properties are equal, the only difference is Name. I am sure about this, used also reflection, to compare objects.

I dial connection with:

RasError re = cEntry.Dial(false, new RasDialParams(CONNAME, USER, PWD));

In case Test1 I get "success", in case of Test2 "unknown" error.

Could you please help me with that nasty problem?


Solution

  • For now I ended with adding necessary registry entries manually - just checked difference in registry before and after creating connection. Not a clean solution, but did not find other one. It seems to be working stable, I can dial connection created this way. I will see, if it is OK in productive phase.