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.

CC3220MODA: How is the Current Device Mode (AP, STA, P2P) Set Accessed By Application?

Part Number: CC3220MODA

To learn my way into the SL API I am experimenting with code based on the network_terminal application.

I was extending the reported information on the splash screen. See screen shot where I have changed the application title and added  Device name, Domain Name and Role Type.

You can see in the screen shot that the CC3220 was set for AP mode and that a station was even added. However the variable I accessed to display role type is stale.

Here is the code I used.

   UART_PRINT("\t MAC address: %02x:%02x:%02x:%02x:%02x:%02x", macAddress[0], macAddress[1], macAddress[2], macAddress[3], macAddress[4], macAddress[5]);
     UART_PRINT(lineBreak);
     UART_PRINT("\t Device Name: %s", my_device_name);
     UART_PRINT(lineBreak);
     UART_PRINT("\t Domain Name: %s", my_domain_name);
     UART_PRINT(lineBreak);
     /* Get Role type */  //FLE 20190618
     GET_STATUS_BIT(app_CB.Status, STATUS_BIT_CONNECTION); // This does not break the AP connection but does not work
//     SET_STATUS_BIT(app_CB.Status, STATUS_BIT_CONNECTION); // This breaks the AP connection
     UART_PRINT("\t Role type: ");
     if(app_CB.Role == ROLE_AP) {
         UART_PRINT("Role is AP");
     }
     else if (app_CB.Role == ROLE_STA) {
              UART_PRINT("Role is STA");
          }
     else if (app_CB.Role == ROLE_P2P) {
              UART_PRINT("Role is P2P");
          }
     else {
         UART_PRINT("Role is ???");
     }/* end Get Role type */

     UART_PRINT(lineBreak);
     UART_PRINT(lineBreak);
     UART_PRINT("\t");
  

So I infer that app_CB.Role is stale and I need to do something to get the app_CB refereshed.
Would like some insight.

Perhaps there is a better way. On page 21 of SWRU455H is a list of APIs and I see a sl_WanSetMode but no corresponding sl_WanGetMode so no joy there.

  • Hi Forrest,

    You are correct, you are going to have to use an API to update the internal appCB. you can get the role by using the following function:

    sl_WlanGet(SL_WLAN_CONNECTION_INFO, NULL , &Len, (_u8*)&WlanConnectInfo);

    Inside the struct SL_WLAN_CONNECTION_INFO, you will have a mode field, so you could then do:

    app_CB.Role = WlanConnectInfo.Mode;

    Please take a look at this thread:
    https://e2e.ti.com/support/wireless-connectivity/wifi/f/968/t/715698

    BR,
    Vince

  • Hello again Vince,

    I tried the code but am not succeeding. First I had to get the length argument not to throw an error And now the first argument is not defined

    Here is my code

         /* Get Role type */  //FLE 20190618
         //sl_WlanGet(SL_WLAN_CONNECTION_INFO, NULL , &Len, (_u8*)&WlanConnectInfo);
         sl_WlanGet(SL_WLAN_CONNECTION_INFO, NULL , (_u16)sizeof(SL_WLAN_CONNECTION_INFO), (_u8*)&WlanConnectInfo);
         app_CB.Role = WlanConnectInfo.Mode;
    //     GET_STATUS_BIT(app_CB.Status, STATUS_BIT_CONNECTION); // This does not break the AP connection but does not work
    //     SET_STATUS_BIT(app_CB.Status, STATUS_BIT_CONNECTION); // This breaks the AP connection
         UART_PRINT("\t Role type: ");
         if(app_CB.Role == ROLE_AP) {
             UART_PRINT("Role is AP");
         }
         else if (app_CB.Role == ROLE_STA) {
                  UART_PRINT("Role is STA");
              }
         else if (app_CB.Role == ROLE_P2P) {
                  UART_PRINT("Role is P2P");
              }
         else {
             UART_PRINT("Role is ???");
         }/* end Get Role type */
    

    I get a build error, "#20 identifier "WlanConnectInfo" is undefined"

    When I look at the definition of "sl_WlanGet"  I find the list of the first arguments do not include "SL_WLAN_CONNECTION_INFO"

    I am using SDK version: "simplelink_cc32xx_sdk_2_30_00_05".

  • Hi Forrest,

    From file wlan.h in 2.30 SDK:

    _i16 RetVal = 0 ;
    _u16 Len = sizeof(SlWlanConnStatusParam_t) ;
    SlWlanConnStatusParam_t WlanConnectInfo ;
    RetVal = sl_WlanGet(SL_WLAN_CONNECTION_INFO, NULL , &Len, (_u8*)&WlanConnectInfo); 

    Jan

  • Ok I made progress. I found this suggested code in the wlan.h file

        - SL_WLAN_CONNECTION_INFO:
        \code
            _i16 RetVal = 0 ;
            _u16 Len = sizeof(SlWlanConnStatusParam_t) ;
            SlWlanConnStatusParam_t WlanConnectInfo ;
            RetVal = sl_WlanGet(SL_WLAN_CONNECTION_INFO, NULL , &Len, (_u8*)&WlanConnectInfo);
       \endcode
        <br>
    

    My code (not cleaned up yet) is:

         /* Get Role type */  //FLE 20190618
    //     _u16 Len = sizeof(SlWlanConnStatusParam_t) ;
         //sl_WlanGet(SL_WLAN_CONNECTION_INFO, NULL , &Len, (_u8*)&WlanConnectInfo);
    //     sl_WlanGet(SL_WLAN_CFG_GENERAL_PARAM_ID, NULL , (_u16)sizeof(SL_WLAN_CFG_GENERAL_PARAM_ID), (_u8*)&WlanConnectInfo);
    
         _i16 RetVal = 0 ;
         _u16 Len = sizeof(SlWlanConnStatusParam_t) ;
         SlWlanConnStatusParam_t WlanConnectInfo ;
         RetVal = sl_WlanGet(SL_WLAN_CONNECTION_INFO, NULL , &Len, (_u8*)&WlanConnectInfo);
         app_CB.Role = WlanConnectInfo.Mode;
    //     GET_STATUS_BIT(app_CB.Status, STATUS_BIT_CONNECTION); // This does not break the AP connection but does not work
    //     SET_STATUS_BIT(app_CB.Status, STATUS_BIT_CONNECTION); // This breaks the AP connection
         UART_PRINT("\t Role type: ");
         if(app_CB.Role == ROLE_AP) {
             UART_PRINT("Role is AP");
         }
         else if (app_CB.Role == ROLE_STA) {
                  UART_PRINT("Role is STA");
              }
         else if (app_CB.Role == ROLE_P2P) {
                  UART_PRINT("Role is P2P");
              }
         else {
             UART_PRINT("Role is ???");
         }/* end Get Role type */
    

    This builds and runs. It returns puzzeling incorrect results. I put the device into STA mode by loging into our network AP. However the role type reports as P2p. See terminal screen shot.

    Makes me wonder if the enumerated type for the mode is off by one or something...

  • Hi Forrest,

    Did you read return values from structure SlWlanConnStatusParam_t?

    typedef struct
    {
        _u8 Mode;       /* ROLE_STA, ROLE_AP, ROLE_P2P */
        _u8 ConnStatus; /* SlWlanConnStatusFlags_e */
        _u8 SecType;    /* Current connection security type - (0 in case of disconnect or AP mode) SL_WLAN_SEC_TYPE_OPEN, SL_WLAN_SEC_TYPE_WEP, SL_WLAN_SEC_TYPE_WPA_WPA2, SL_WLAN_SEC_TYPE_WPA_ENT, SL_WLAN_SEC_TYPE_WPS_PBC, SL_WLAN_SEC_TYPE_WPS_PIN */
        _u8 Reserved;
        SlWlanConnectionInfo_u ConnectionInfo;
    }SlWlanConnStatusParam_t;

    OK, now I found your line app_CB.Role = WlanConnectInfo.Mode;

    BTW .. why you not save return value from sl_Start() command?

    Jan

  • I think I found an error in the wlan.h documentation for the arguments for sl_WlanGet

    At about line 1945

    /*!
        \brief     Getting WLAN configurations
    
        \param[in] ConfigId -  configuration id
                              - <b>SL_WLAN_CFG_AP_ID</b>
                              - <b>SL_WLAN_CFG_GENERAL_PARAM_ID</b>
                              - <b>SL_WLAN_CFG_P2P_PARAM_ID</b>
                              - <b>SL_WLAN_CFG_AP_ACCESS_LIST_ID</b>
                              - <b>SL_WLAN_RX_FILTERS_ID</b>
    

    There are five arguments, 0 to 4.

    However on line 276 there are 0 to 5.

    /* wlan config application IDs */
    #define SL_WLAN_CFG_AP_ID                             (0)
    #define SL_WLAN_CFG_GENERAL_PARAM_ID                  (1)
    #define SL_WLAN_CFG_P2P_PARAM_ID                      (2)
    #define SL_WLAN_CFG_AP_ACCESS_LIST_ID                 (3)
    #define SL_WLAN_RX_FILTERS_ID                         (4)
    #define SL_WLAN_CONNECTION_INFO                       (5)
    

  • Hi Forrest,

    Yes, but If you look closer you will find much more mistakes in comments (and doxygen documentation).

    Jan

  • Jan,

    Regarding, "BTW .. why you not save return value from sl_Start() command?"  I am trying to figure how to quire the NWP to see what it is doing not what the host code thinks it is doing.

    And It was not clear to me what might happen if I called sl_Start() a second time and after their is a connection for example. I had not gotten around to just trying it.

  • It is end of the day and I simply hard coded a test against some integers (magic numbers) for AT and STA and a guess for P2P into the code.

         /* Get Role type */  //FLE 20190618
         _i16 RetVal = 0 ;
         _u16 Len = sizeof(SlWlanConnStatusParam_t) ;
         SlWlanConnStatusParam_t WlanConnectInfo ;
         RetVal = sl_WlanGet(SL_WLAN_CONNECTION_INFO, NULL , &Len, (_u8*)&WlanConnectInfo);
         app_CB.Role = WlanConnectInfo.Mode;
         UART_PRINT("\t Role type: ");
    //     if(app_CB.Role == (uint32_t)ROLE_AP) {
         if(app_CB.Role == 0) {
             UART_PRINT("'0'. Role is AP");
         }
    //     else if (app_CB.Role == (uint32_t)ROLE_STA) {
         else if (app_CB.Role == 3) {
                  UART_PRINT("'3'. Role is STA");
              }
    //     else if (app_CB.Role == (uint32_t)ROLE_P2P) {
         else if (app_CB.Role == 1) {
                UART_PRINT("'1'. Role is P2P");
              }
         else {
             UART_PRINT("Number %d Role is ???", app_CB.Role);
         }/* end Get Role type */

    Screen shot:

    Hope for more insight on what WlanConnectInfo.Mode actually is supposed to return.