none
CmAddConnectionConfig invalid parameter RRS feed

  • Question

  • I am tryin to connect via wifi to an AP named rain with an OPEN authentication on OMAP4 with TI's WL1283. My code is as follows:

    ......

    pstConfig->Version = CM_CURRENT_VERSION;
    StringCchCopy(pstConfig->szDescription, _countof(pstConfig->szDescription), pwszSsid);
    pstConfig->Type = CM_CSP_WIFI_TYPE;
    pstConfig->Characteristic[CMCH_BANDWIDTH_KBITPS] = CM_UNKNOWN_CHARACTERISTIC_VALUE;
    pstConfig->Characteristic[CMCH_SUPPORTS_WAKE_ON_INCOMING] = CM_UNKNOWN_CHARACTERISTIC_VALUE;
    pstConfig->Characteristic[CMCH_ROAMING] = CM_UNKNOWN_CHARACTERISTIC_VALUE;
    pstConfig->ConnectBehavior = CMCB_DEFAULT;
    pstConfig->AutoReconnect.DelaySec = 120;
    pstConfig->AutoReconnect.Attempts = 3;
    pstConfig->AutoReconnect.AttemptsExceededDelaySec = 120;
    pstConfig->fEnabled = TRUE;


    pInfo->Version
    = CSP_WIFI_SPECIFIC_INFO_VERSION;
    pInfo->InterfaceSpecific
    = TRUE;
    pInfo->InterfaceGuid
    = InterfaceGuid;
    pInfo->cbDevConfig
    = dwProfileXml;

    pInfo->cbUserDataOffset = pInfo->cbDevConfig;
    memcpy(&(pInfo->DevConfigXml), wlan_Profile, dwProfileXml);

    memcpy(&(pstConfig->TypeSpecificInfo), pInfo, dwInfo);
    pstConfig->cbTypeSpecificInfo = offsetof(CspWiFiSpecificInfo, DevConfigXml[0]) + (pInfo->cbDevConfig);

    if(bExistingConfig)
    {
    // CM info Update
    }
    else
    {
    // CM Info Register
    dwCmResult = CmAddConnectionConfig(pwszSsid, pstConfig, dwConfig);
    if (dwCmResult != CMRE_SUCCESS)
    {
    RETAILMSG(1,(TEXT("SDK: CmAddConnectionConfig Fail. Ret=0x%08X.\r\n"), dwCmResult));
    dwRet = FALSE;
    goto ERROR_EXIT;
    }

    When it tries to addconnectionconfig, it always fails with an error message:  CMRE_INVALID_PARAMETER, does it mean i set something wrong? How should I set up my configuration parameter?
    Tuesday, March 4, 2014 7:10 AM

Answers

  • Hi,

    For starters you seem to be missing 

    1. ReconnectAlg member of AutoReconnect structure in CM_CONNECTION_CONFIG. i.e. 

    pstConfig->AutoReconnect.ReconnectAlg is missing.

    2. Hopefully you have the XML schema contents filled properly in CspWifiSpecificInfo. 

    3. dwConfig contains actual number of CM_CONNECTION_CONFIG structures. From the code posted above it seems to be uninitialized.

    Regards,

    Balaji.

    • Marked as answer by Wenyi Thursday, March 6, 2014 8:24 AM
    Tuesday, March 4, 2014 12:26 PM

All replies

  • Hi,

    For starters you seem to be missing 

    1. ReconnectAlg member of AutoReconnect structure in CM_CONNECTION_CONFIG. i.e. 

    pstConfig->AutoReconnect.ReconnectAlg is missing.

    2. Hopefully you have the XML schema contents filled properly in CspWifiSpecificInfo. 

    3. dwConfig contains actual number of CM_CONNECTION_CONFIG structures. From the code posted above it seems to be uninitialized.

    Regards,

    Balaji.

    • Marked as answer by Wenyi Thursday, March 6, 2014 8:24 AM
    Tuesday, March 4, 2014 12:26 PM
  • Thanks. I have added the line:

    pstConfig->AutoReconnect.ReconnectAlg = CMTR_LINEAR;

    before the autoreconnect structure definition. 

    also, dwConfig is defined as:

    dwProfileXml = sizeof(WCHAR) * (wcslen(wlan_Profile) + 1);
    dwInfo = offsetof(CspWiFiSpecificInfo, DevConfigXml[0]) +dwProfileXml;
    dwConfig = CmGetConnectionConfigNeededSize(dwInfo);

    and wlan_Profile is defined as below(the AP name is TEST-3F, WPA2-Personal, AES, password="1234567890":

    WCHAR wlan_Profile[] =
    L"<?xml version=\"1.0\" encoding=\"\"?>\
    <WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\">\
    <name>SampleWPA2PSK</name>\
    <SSIDConfig>\
    <SSID>\
    <name>TEST-3F</name>\
    </SSID>\
    </SSIDConfig>\
    <connectionType>ESS</connectionType>\
    <connectionMode>auto</connectionMode>\
    <autoSwitch>false</autoSwitch>\
    <MSM>\
    <security>\
    <authEncryption>\
                    <authentication>WPA2PSK</authentication>\
                    <encryption>AES</encryption>\
                    <useOneX>false</useOneX>\
                </authEncryption>\
    <sharedKey>\
    <keyType>passPhrase</keyType>\
    <protected>false</protected>\
    <keyMaterial> 1234567890</keyMaterial>\
    </sharedKey>\
            </security>\
        </MSM>\
    </WLANProfile>";

    However, I still see an invalid parameter message. Any further suggestions?

    I also want to try connecting to an AP without any password settings, i.e., authentication is open. How should I modify the above xml?




    • Edited by Wenyi Wednesday, March 5, 2014 11:31 AM
    Wednesday, March 5, 2014 9:39 AM
  • Hi Balaji,

    After I added the "OneX" part in the xml schema, it begins to work. Thanks a lot for the help!

    Wenyi

    Thursday, March 6, 2014 8:23 AM
  • Hi Balaji,

    I am also getting same error CMRE_INVALID_PARAMETERS ERROR when i am creating open auto profile. My code is as follows :

    ulConfig = offsetof(CM_CONNECTION_CONFIG, TypeSpecificInfo[0]) + offsetof(CspWiFiSpecificInfo,DevConfigXml[0]) + ulXmlBuffer;
    pConfig = (CM_CONNECTION_CONFIG*)LocalAlloc(LPTR, ulConfig);
    pConfig->Version = CM_CURRENT_VERSION;
    pConfig->Type = CM_CSP_WIFI_TYPE;
    pConfig->ConnectBehavior = CMCB_DEFAULT;
    pConfig->AutoReconnect.ReconnectAlg=CMTR_LINEAR;
    pConfig->AutoReconnect.DelaySec=120;
    pConfig->AutoReconnect.Attempts=3;
    pConfig->AutoReconnect.AttemptsExceededDelaySec=120;
    pConfig->fEnabled = TRUE;
    pConfig->cbTypeSpecificInfo = 
    offsetof(CspWiFiSpecificInfo, DevConfigXml[0]) + ulXmlBuffer;
    CspWiFiSpecificInfo *pCspWiFiInfo =   (CspWiFiSpecificInfo*)&pConfig->TypeSpecificInfo[0];
    pCspWiFiInfo->Version = CSP_WIFI_SPECIFIC_INFO_VERSION;
    pCspWiFiInfo->InterfaceSpecific = TRUE;
    memcpy(&pCspWiFiInfo->InterfaceGuid, pInterfaceGuid, sizeof(GUID));
    pCspWiFiInfo->cbUserDataOffset = ulXmlBuffer;
    pCspWiFiInfo->cbDevConfig = ulXmlBuffer;
    memcpy(&pCspWiFiInfo->DevConfigXml[0], bstrXml, pCspWiFiInfo->cbDevConfig);
    CM_RESULT result= CmAddConnectionConfig(szConnectionName1,pConfig,ulConfig);

    Please find where i did the mistake in my code

    Regards 

    Venkatesh

    Monday, May 19, 2014 2:32 PM
  • Hi,

    A few parameters are missing in the CM_CONNECTION_CONFIG structure. Have you tried these:

    pConfig->Characteristic[CMCH_BANDWIDTH_KBITPS] = CM_UNKNOWN_CHARACTERISTIC_VALUE;
     pConfig->Characteristic[CMCH_SUPPORTS_WAKE_ON_INCOMING] = CM_UNKNOWN_CHARACTERISTIC_VALUE;
    pConfig->Characteristic[CMCH_ROAMING] = CM_UNKNOWN_CHARACTERISTIC_VALUE;

    Unknowns can be replaced by values you prefer depending on the profile you are creating.

    More info on these parameters here:

    http://msdn.microsoft.com/en-us/library/gg157579.aspx

    I hope the XML contents are proper.

    Good Luck.

    Regards,

    Balaji.


    • Edited by balajitrv1 Monday, May 19, 2014 4:30 PM
    Monday, May 19, 2014 4:29 PM
  • Hi Balaji,

    Thanks for giving reply i added the following lines :

    pConfig->Characteristic[CMCH_BANDWIDTH_KBITPS] = CM_UNKNOWN_CHARACTERISTIC_VALUE;
     pConfig->Characteristic[CMCH_SUPPORTS_WAKE_ON_INCOMING] = CM_UNKNOWN_CHARACTERISTIC_VALUE;
    pConfig->Characteristic[CMCH_ROAMING] = CM_UNKNOWN_CHARACTERISTIC_VALUE;

    then also i am getting the same error.

    Little modification when I am able to create the manual profile by replacing the <connectionMode>auto</connectionMode> to  <connectionMode>manual</connectionMode> and by  removing the following lines:

    pConfig->AutoReconnect.ReconnectAlg=CMTR_LINEAR;
    pConfig->AutoReconnect.DelaySec=120;
    pConfig->AutoReconnect.Attempts=3;
    pConfig->AutoReconnect.AttemptsExceededDelaySec=120;

    it is working fine. Now i 'm able to create all types of profiles under manual. But i need to create auto profiles. Any further suggestions to create auto profiles?.

    Regards 

    Venkatesh



    • Edited by DeanVenky Tuesday, May 20, 2014 9:10 AM
    Tuesday, May 20, 2014 6:38 AM
  • Hi,

    ConnectionMode set as auto in the template is creating some issues. Ideally , the code provided by you above should work without changes.

    Assuming that you want to connect to a WiFi network automatically when the network is in range , the CM_TIME_BASED_AUTO_RECONNECT_ALGORITHM structure should be more than sufficient.

    Again, it is my idea that once you have the structure filled up with example values like:

    pConfig->AutoReconnect.ReconnectAlg = CMTR_LINEAR;
    pConfig->AutoReconnect.DelaySec = 120;
    pConfig->AutoReconnect.Attempts = 3;
    pConfig->AutoReconnect.AttemptsExceededDelaySec = 120;

    and even if manual is chosen as ConnectionMode in the template , the structure elements mean that the auto-connect will be triggered by the Connection manager when the time period has elapsed. So the structure members along with manual selection in template should work.

    So considering the above example , Delaysec is 120 , so once disconnected the connection manager will try reconnecting to a profile after a delay of 2 minutes for 3 tries and then again for infinite time with a spacing of 2 minutes (AttemptsExceededDelaySec) between each tries.


    You may refer the wificpl code for guidelines. Also this link has more details won what the above structure means to the connection manager:

    http://msdn.microsoft.com/en-us/library/gg155715.aspx

    Regards,

    Balaji.

    • Proposed as answer by DeanVenky Tuesday, May 20, 2014 1:48 PM
    Tuesday, May 20, 2014 12:29 PM