This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3120MOD: How to handle errors of sl_start() and sl_WlanSetMode()

Part Number: CC3120MOD


 

 

 

 

Hi,

Can anyone comment on my below query: -

Is this functions will return this errors and how I can replicate this to test? and please comment that I have handles this errors correctly?

SL_ERROR_ROLE_AP_ERR and SL_ERROR_ROLE_STA_ERR : -

a)      status = sl_Start(NULL,NULL,NULL);            // Start the device

        if ((status == SL_ERROR_ROLE_AP_ERR) || (status == SL_ERROR_ROLE_STA_ERR))

       {

          scomData.wireless_reg.bit.wifi_error = WIFI_ERROR_MODE;

       }

 

b)      Status = sl_WlanSetMode(ROLE_AP);  // Set the device mode

       if (status == SL_ERROR_ROLE_AP_ERR)

      {

           scomData.wireless_reg.bit.wifi_error = WIFI_ERROR_MODE;

      }

 

c)       Status = sl_WlanSetMode(ROLE_STA);  // Set the device mode

if (status == SL_ERROR_ROLE_STA_ERR)

{

    scomData.wireless_reg.bit.wifi_error = WIFI_ERROR_MODE;

}

  • Part Number: CC3120MOD

    Hi,

    Can anyone comment on my below query: -

    Is this function will return this error and how I can replicate this to test as I have tried to pass only single char password but not return any error and I am getting always 0 in Status?

    Also is it I handled correctly this error? "SL_ERROR_WLAN_INVALID_AP_PASSWORD_LENGTH"

    Status = sl_WlanSet(SL_WLAN_CFG_AP_ID, SL_WLAN_AP_OPT_PASSWORD, strlen((const char *)password), (_u8 *)password);

    Regards,

    Mahendra Rana

  • Part Number: CC3120MOD

    Hi,

    Can anyone comment on my below query: -

    Is this function will return this error and how I can replicate this to test as I have tried to pass only single char password but not return any error and I am getting always 0 in Status?

    Also is it I handled correctly this error? 

    "SL_ERROR_WLAN_PASSWORD_ERROR", 

    "SL_ERROR_WLAN_SSID_LEN_ERROR", 

    "SL_ERROR_WLAN_KEY_ERROR", 

    "SL_ERROR_WLAN_INVALID_SECURITY_TYPE"  and 

    "SL_ERROR_WLAN_ILLEGAL_WEP_KEY_INDEX"

    Status = sl_WlanProfileAdd(name, strlen((const char *)name), 0, &SecParams, NULL, 1,0);

    if (Status == SL_ERROR_WLAN_PASSWORD_ERROR)

      {

        scomData.wireless_reg.bit.wifi_error = WIFI_ERROR_PWD;

      }

      else if (Status == SL_ERROR_WLAN_SSID_LEN_ERROR)

      {

        scomData.wireless_reg.bit.wifi_error = WIFI_ERROR_SSID;

      }

      else if ((Status == SL_ERROR_WLAN_KEY_ERROR) || (Status == SL_ERROR_WLAN_INVALID_SECURITY_TYPE) ||

               (Status == SL_ERROR_WLAN_ILLEGAL_WEP_KEY_INDEX))

      {

        scomData.wireless_reg.bit.wifi_error = WIFI_ERROR_ENCRYPT;

      }

    Regards,

    Mahendra Rana

  • Hi Mahendra Rana,

    Are those theoretical questions or have you received the errors?

    The API documentation (you can refer to doxygen in the SDK or directly check the simplelink driver's headers) and the CC3220 NWP programmers guide are the best places to check about those API.

    You can also check the examples code. Some return codes you mentioned are not errors but valid value (e.g. if sl_Start return the wrong mode, you will need to use sl_WlanSetMode to set the required role - most of the examples are starting by setting the right role).

    Br,

    Kobi

  • Hi,

    Thanks for your reply!

    Not a theoretical a question, actually I want to handle errors and after reading programming guide I have tried but just confirming that  is it I did in correct way?

    Because in programming guide not mentioned by which function this error codes get return.

    So can you please reply that I have handled in correct way means 

    1) sl_WlanProfileAdd() returns this error code 

    "SL_ERROR_WLAN_PASSWORD_ERROR", 

    "SL_ERROR_WLAN_SSID_LEN_ERROR", 

    "SL_ERROR_WLAN_KEY_ERROR", 

    "SL_ERROR_WLAN_INVALID_SECURITY_TYPE"  and 

    "SL_ERROR_WLAN_ILLEGAL_WEP_KEY_INDEX"

    Also I have tried to pass only single digit password but this function not returns this "SL_ERROR_WLAN_PASSWORD_ERROR" and return always 0. Either this is a bug in CC3120Mod or I have done in wrong way.

    2) Similarly sl_WlanSet() also not return error code "SL_ERROR_WLAN_INVALID_AP_PASSWORD_LENGTH" on in correct password?

    3) Is it this function sl_Start() and sl_WlanSetMode() will return error code as "SL_ERROR_ROLE_AP_ERR" or "SL_ERROR_ROLE_STA_ERR"?

    4) If you can also suggest me a way to replicate this error in run time to test of my code?

     

    So many error code not exactly return by function only mentioned in programming guide, may its a bug in CC3120Mod or I have done in wrong way.

    waiting for your reply!

    Regards,

    Mahendra Rana

     

  • Hi Mahendra,

    1) the error check you mentioned seems reasonable. However, the NWP doesn't verify all the parameters (e.g. if password is strong enough). It will return errors if the password is empty or more than 64 chars.

    Unfortunately, the error checking is also not consistent between different API, for example sl_WlanConnect can return errors that are not verified in sl_WlanProfileAdd. Please make sure to verify in the application the validity of parameters that are important for you.

    2) same as 1. The length is not check for all the error cases. You'll need to add verification on the application side.

    3) Those values are not expected. 

    4) You can't.

    Br,

    Kobi

  • Hi,

    Thanks for your reply!

    On my query no. 3 (Is it this function sl_Start() and sl_WlanSetMode() will return error code as "SL_ERROR_ROLE_AP_ERR" or "SL_ERROR_ROLE_STA_ERR"?)

    You replied that this function will not return this error code. But in programming guide "SWRU455E–February 2017–Revised February 2018" this is mentioned that

    Table 2-5. Common Error Codes

    Error                                           Value  Comments
    SL_ERROR_ROLE_STA_ERR –4107 Initialization failure in the specified mode (sl_Start)
    SL_ERROR_ROLE_AP_ERR   –4108
    SL_ERROR_ROLE_P2P_ERR –4108

    Table 3-5. Common Errors
    Error                                          Value Comments
    SL_ERROR_ROLE_AP_ERR –4108 Initialization failure in AP mode.

    If not then by which function this error will be return "SL_ERROR_ROLE_AP_ERR" or "SL_ERROR_ROLE_STA_ERR"?, can you guide me.

    Regards,

    Mahendra Rana

  • You can check these return codes, but they these errors are very rare and are not expected.

  • Hi,

    One more concern on query 1,2 that even I entered empty password then also it not return error "SL_ERROR_WLAN_PASSWORD_ERROR" or SL_ERROR_WLAN_INVALID_AP_PASSWORD_LENGTH.

    Why it happen so?

    Regards,

    Mahendra Rana

  • With sl_WlanProfileAdd, I'm not sure even if this are being verified (the length==0 is verified when you call sl_WlanConnect).

    The NWP mainly focus on protection from memory corruptions (i.e. when password is too long for the available buffer). The assumption is that short lengths will fail when you try to connect to the wlan AP. 

    As mentioned before, if you have concerns about user inputs the best way would be to check them yourself (in the application).