Connecting to Mobile Network via Mobile Broadband API

517 views Asked by At

I am trying to connect to a mobile network via a modem and a sim card. Every time I try to set the APN String and User Credentials in a Context via SetProvisionedContext() I get the E_INVALIDARG HRESULT. As Parameters I used an Instance of MBN_CONTEXT, a wchar_t* in form of &std::vector<wchar_t>[0], and a ULONG*.

    MBN_CONTEXT context;

    std::vector<WCHAR> apnVector;
    inParamAPN.GetCString(apnVector);

    std::vector<WCHAR> userNameVec;
    inParamUsername.GetCString(userNameVec);

    std::vector<WCHAR> passwordVector;
    inParamPassword.GetCString(passwordVector);

    context.contextID = MBN_CONTEXT_ID_APPEND;
    context.contextType = MBN_CONTEXT_TYPE_INTERNET;
    context.accessString = &apnVector[0];
    context.userName = &userNameVec[0];
    context.password = &passwordVector[0];
    context.compression = MBN_COMPRESSION_NONE;
    context.authType = MBN_AUTH_PROTOCOL_PAP;

and later when I have the IMbnConnectionContext:

    std::vector<WCHAR> providerVector;
    InParamProvider.GetCString(providerVector);
    ULONG requestID;
    contextInterface->SetProvisionedContext(context, &providerVector[0], &requestID);

So my Question is: Which Parameter does the WinAPI have a Problem with, and how can I fix it?

Also any Tips of additional Sources for Information are appriciated. All I have so far are the official MSDN and the Code Example contained in the Windows 7 SDK. Are there any further sources of Information I am not aware of? A google search didn't yield the hoped for results.

1

There are 1 answers

0
Stefan On BEST ANSWER

In the end I did not get it working as it should. I used the second way of connecting to a custom APN, by making a new connection profile. For this I used a XML filled with the Values I needed.

Along the way I encountered another problem with an unforseen Error Code which I described here.

Best regards,

Stefan