6 Replies Latest reply on May 20, 2020 12:17 AM by HaTr_4568521

    Interface declaration in WICED

    HaTr_4568521

      In data transmission-reception using WIFI, the interface is declared as follows:

      wiced_interface_t interface;

      and used as follows:

      result = wiced_network_up_default( &interface, &device_init_ip_settings );

      However, upon seeing the declaration, we find the following:

      typedef enum

      {

          WICED_STA_INTERFACE      = WWD_STA_INTERFACE,             /**< STA or Client Interface  */

          WICED_AP_INTERFACE       = WWD_AP_INTERFACE,              /**< softAP Interface         */

          WICED_P2P_INTERFACE      = WWD_P2P_INTERFACE,             /**< P2P Interface            */

          WICED_ETHERNET_INTERFACE = WWD_ETHERNET_INTERFACE,        /**< Ethernet Interface       */

       

          WICED_INTERFACE_MAX,       /** DO NOT USE - MUST BE AFTER ALL NORMAL INTERFACES - used for counting interfaces */

          WICED_CONFIG_INTERFACE   = WICED_AP_INTERFACE | (1 << 7), /**< config softAP Interface  */

      } wiced_interface_t;

       

      So how do I change my WIFI module as a station? Just by changing WICED_CONFIG_INTERFACE   = WICED_STA_INTERFACE | (1 << 7)?

       

      I could not understand the variable "interface" declaration and value assignment.

       

      References:

      • udp_transmit
      • udp_receive
      • wiced_constants.h
        • 1. Re: Interface declaration in WICED
          MuraliR_36

          To change the interface under consideration, all you need to do is pass the required interface as a parameter, say in this case WICED_STA_INTERFACE as a parameter in the required API

          wiced_network_up(WICED_STA_INTERFACE, WICED_USE_EXTERNAL_DHCP_SERVER, NULL);
          

          This API would configure the STA interface to connect to a specified external AP and use the DHCP server of that AP.

           

          In the udp_receive and the udp_transmit applications the interface is defined in the wifi_config_dct.h as

          #define WICED_NETWORK_INTERFACE   WICED_AP_INTERFACE
          

          and hence you see the generic definition in the main application file.

           

          This WICED_NETWORK_INTERFACE is picked up by the CONFIG_NETWORK_INTERFACE in default_network_config_dct.h. This gets assigned in dct.c as

          .network_config.interface          = CONFIG_NETWORK_INTERFACE
          

          and gets stored in the DCT_NETWORK_CONFIG_SECTION and is read from there during runtime in the file wiced_network_common.c in the line

          wiced_dct_read_lock( (void**) &dct_network_config, WICED_TRUE, DCT_NETWORK_CONFIG_SECTION, 0, sizeof(platform_dct_network_config_t) );
          

           

          Thanks

          1 of 1 people found this helpful
          • 2. Re: Interface declaration in WICED
            HaTr_4568521

            Understood MuraliR_36 !! Thanks for the prompt response.

             

            Just a minor clarification:

            I've done some minor modifications in the built-in wifi_config_dct.h. I've commented out a few client-configuration related points since I want to configure my device as an AP only. However, still not so sure about the changes done. Can you please share your thoughts on the same?

             

            #pragma once

             

            #ifdef __cplusplus

            extern "C" {

            #endif

             

            /* This is the soft AP used for device configuration */

            // #define CONFIG_AP_SSID       "NOT USED FOR THIS APP"

            // #define CONFIG_AP_PASSPHRASE "NOT USED FOR THIS APP"

            // #define CONFIG_AP_SECURITY   WICED_SECURITY_OPEN

            // #define CONFIG_AP_CHANNEL    1

             

            /* This is the soft AP available for normal operation */

            #define SOFT_AP_SSID         "Try1_802.11ac"

            #define SOFT_AP_PASSPHRASE   "80211AC"

            #define SOFT_AP_SECURITY     /*WICED_SECURITY_OPEN  */  WICED_SECURITY_WPA2_AES_PSK

            #define SOFT_AP_CHANNEL      1

             

            /* This is the default AP the device will connect to (as a client) */

            // #define CLIENT_AP_SSID       "YOUR_AP_SSID"

            // #define CLIENT_AP_PASSPHRASE "YOUR_AP_PASSPHRASE"

            // #define CLIENT_AP_BSS_TYPE   WICED_BSS_TYPE_INFRASTRUCTURE

            // #define CLIENT_AP_SECURITY   WICED_SECURITY_WPA2_MIXED_PSK

            // #define CLIENT_AP_CHANNEL    1

            // #define CLIENT_AP_BAND       WICED_802_11_BAND_2_4GHZ

             

            /* Override default country code */

            #define WICED_COUNTRY_CODE    WICED_COUNTRY_INDIA

            #define WICED_COUNTRY_AGGREGATE_CODE    WICED_COUNTRY_AGGREGATE_XV_0

             

            /* This is the network interface the device will work with */

            #define WICED_NETWORK_INTERFACE   WICED_AP_INTERFACE

             

            #ifdef __cplusplus

            } /*extern "C" */

            #endif

            And similarly, to configure the device as a client, shall the following be my configuration for the wifi_config_dct.h?

             

             

            #pragma once

             

            #ifdef __cplusplus

            extern "C" {

            #endif

             

            /* This is the soft AP used for device configuration */

            // #define CONFIG_AP_SSID       "NOT USED FOR THIS APP"

            // #define CONFIG_AP_PASSPHRASE "NOT USED FOR THIS APP"

            // #define CONFIG_AP_SECURITY   WICED_SECURITY_OPEN

            // #define CONFIG_AP_CHANNEL    1

             

            /* This is the soft AP available for normal operation */

            // #define SOFT_AP_SSID         "Try1_802.11ac"

            // #define SOFT_AP_PASSPHRASE   "80211AC"

            // #define SOFT_AP_SECURITY     WICED_SECURITY_WPA2_AES_PSK

            // #define SOFT_AP_CHANNEL      1

             

            /* This is the default AP the device will connect to (as a client) */

            #define CLIENT_AP_SSID       "Try1_802.11ac"

            #define CLIENT_AP_PASSPHRASE "80211AC"

            #define CLIENT_AP_BSS_TYPE   WICED_BSS_TYPE_INFRASTRUCTURE

            #define CLIENT_AP_SECURITY   WICED_SECURITY_WPA2_MIXED_PSK

            #define CLIENT_AP_CHANNEL    1

            #define CLIENT_AP_BAND       WICED_802_11_BAND_2_4GHZ

             

            /* Override default country code */

            #define WICED_COUNTRY_CODE    WICED_COUNTRY_INDIA

            #define WICED_COUNTRY_AGGREGATE_CODE    WICED_COUNTRY_AGGREGATE_XV_0

             

            /* This is the network interface the device will work with */

            #define WICED_NETWORK_INTERFACE   WICED_CLIENT_INTERFACE

             

            #ifdef __cplusplus

            } /*extern "C" */

            #endif

            • 3. Re: Interface declaration in WICED
              MuraliR_36

              HaTr_4568521 the configuration for AP looks fine.

              But in the client or the STA mode the network interface should be defined as below

              #define WICED_NETWORK_INTERFACE   WICED_STA_INTERFACE
              
              2 of 2 people found this helpful
              • 4. Re: Interface declaration in WICED
                HaTr_4568521

                Hello MuraliR_36, I'm trying to write a basic program for configuring my device as an AP. I referred to various snippets given in the WICED. Following is the code for your reference:

                 

                .c file

                #include "wiced.h"

                 

                 

                static const wiced_ip_setting_t device_init_ip_settings =

                {

                    INITIALISER_IPV4_ADDRESS( .ip_address, MAKE_IPV4_ADDRESS(192,168,  0,  1) ),

                    INITIALISER_IPV4_ADDRESS( .netmask,    MAKE_IPV4_ADDRESS(255,255,255,  0) ),

                    INITIALISER_IPV4_ADDRESS( .gateway,    MAKE_IPV4_ADDRESS(192,168,  0,  1) ),

                };

                 

                void application_start(void)

                {

                    wiced_interface_t interface;

                    wiced_result_t result;

                    // wiced_ssid_t ssid;

                 

                    /* Initialise the device and WICED framework */

                    wiced_init( );

                 

                    result = wiced_network_up(WICED_AP_INTERFACE, WICED_USE_INTERNAL_DHCP_SERVER, &device_init_ip_settings)

                    //result = wiced_network_up_default( &interface, &device_init_ip_settings );

                 

                    if( result != WICED_SUCCESS )

                    {

                        printf("Bringing up network interface failed !\r\n");

                    }

                }

                .mk file:

                NAME := apps_802.11ac_configuration_18May

                $(NAME)_SOURCES := 802.11ac_configuration_18May.c

                WIFI_CONFIG_DCT_H := wifi_config_dct.h

                wifi_config_dct.h file

                #pragma once

                 

                #ifdef __cplusplus

                extern "C"

                {

                #endif

                 

                #define SOFT_AP_SSID         "802.11ac_try1"

                #define SOFT_AP_CHANNEL      1

                #define SOFT_AP_SECURITY     WICED_SECURITY_WPA2_AES_PSK

                #define SOFT_AP_PASSPHRASE   "80211AC"

                 

                //#define WICED_COUNTRY_CODE WICED_COUNTRY_INDIA

                //#define WICED_COUNTRY_AGGREGATE_CODE WICED_COUNTRY_AGGREGATE_XV_0

                 

                /* This is the network interface the device will work with */

                #define WICED_NETWORK_INTERFACE    WICED_AP_INTERFACE

                 

                #ifdef __cplusplus

                } /*extern "C" */

                #endif

                Still, upon running the program, I'm getting eror as mentioned below:

                 

                23:38:02 **** Build of configuration Default for project 43xxx_Wi-Fi ****

                "C:\\Users\\Harsh\\Documents\\WICED-Studio-6.4\\43xxx_Wi-Fi\\make.exe" Harsh_May.802.11ac_configuration_18May-CYW954907AEVAL1F download run

                MAKEFILE MAKECMDGOALS=Harsh_May.802.11ac_configuration_18May-CYW954907AEVAL1F download run OTA2_SUPPORT is disabled

                Making config file for first time

                tools/makefiles/wiced_config.mk:267: *** Unknown component: Harsh_May.802.11ac_configuration_18May.  Stop.

                make: *** No rule to make target 'build/Harsh_May.802.11ac_configuration_18May-CYW954907AEVAL1F/config.mk', needed by 'main_app'.  Stop.

                 

                 

                23:38:04 Build Finished (took 1s.662ms)

                 

                I'm really not able to understand what can possibly go wrong with this program! It's just a simple code that defines type of interface and assigns IP. Alternatively I also tried with

                result = wiced_network_up_default( &interface, &device_init_ip_settings );

                and it also ended up with the same error. Can you please guide?

                • 5. Re: Interface declaration in WICED
                  MuraliR_36

                  Hello HaTr_4568521

                   

                  I think the issue is not with your application rather with the make target.

                  Your make target says Harsh_May.802.11ac_configuration_18May-CYW954907AEVAL1F download run So what essentially is happening is that, the Make command is looking for Harsh_May directory under apps, 802 directory under Harsh_May and 11ac_configuration under 802 which according to your .mk file isn't the case. You need to remove the dot in 802.11 in the Make target(also in the folder name and the file name if you have placed it there) and the compilation should go through. If it doesn't please do attach your application here and i will check what else is missing.

                   

                  Thanks

                   

                  1 of 1 people found this helpful
                  • 6. Re: Interface declaration in WICED
                    HaTr_4568521

                    Hello MuraliR_36,

                     

                    Your judgement was perfectly correct. it was this dot after 802 that was making the issue. Now I was able to run the code.

                     

                    However, I'd to do some minor modifications in my wifi_config_dct.h file. In wifi_config_dct.h file, since I wanted to configure my device as a softAP only, I'd commented out CONFIG_AP_* and CLIENT_AP_* related commands, which I had to uncomment to get the error free outcome. The program is mentioned below:

                     

                    #pragma once

                     

                    #ifdef __cplusplus

                    extern "C" {

                    #endif

                     

                    /*

                    * AP settings in this file are stored in the DCT. These

                    * settings may be overwritten at manufacture when the

                    * DCT is written with the final production configuration

                    */

                     

                    /* This is the soft AP used for device configuration

                    #define CONFIG_AP_SSID       "NOT USED FOR THIS APP"

                    #define CONFIG_AP_PASSPHRASE "NOT USED FOR THIS APP"

                    #define CONFIG_AP_SECURITY   WICED_SECURITY_OPEN

                    #define CONFIG_AP_CHANNEL    1

                    #define CONFIG_AP_VALID      WICED_FALSE*/

                     

                    /* This is the soft AP available for normal operation */

                    #define SOFT_AP_SSID         "802.11ac_try1"

                    #define SOFT_AP_PASSPHRASE   "80211AC"

                    #define SOFT_AP_SECURITY     WICED_SECURITY_WPA2_AES_PSK

                    #define SOFT_AP_CHANNEL      1

                     

                    /* This is the default AP the device will connect to (as a client)

                    #define CLIENT_AP_SSID       "YOUR_AP_SSID_FOR_APSTA"

                    #define CLIENT_AP_PASSPHRASE "YOUR_AP_PASSPHRASE"

                    #define CLIENT_AP_BSS_TYPE   WICED_BSS_TYPE_INFRASTRUCTURE

                    #define CLIENT_AP_SECURITY   WICED_SECURITY_WPA2_MIXED_PSK

                    #define CLIENT_AP_CHANNEL    1

                    #define CLIENT_AP_BAND       WICED_802_11_BAND_2_4GHZ

                    */

                    /* Override default country code */

                    #define WICED_COUNTRY_CODE    WICED_COUNTRY_UNITED_STATES

                    #define WICED_COUNTRY_AGGREGATE_CODE    WICED_COUNTRY_AGGREGATE_XV_0

                     

                    #ifdef __cplusplus

                    } /*extern "C" */

                    #endif

                     

                    Below is the outcome of loading the code into the kit, showing errors reg. CONFIG_AP_* and CLIENT_AP_* related commands.

                     

                     

                    12:29:30 **** Build of configuration Default for project 43xxx_Wi-Fi ****

                    "C:\\Users\\Admin\\Documents\\WICED-Studio-6.4\\43xxx_Wi-Fi\\make.exe" Harsh_May2020.AP_config-CYW954907AEVAL1F download run

                    MAKEFILE MAKECMDGOALS=Harsh_May2020.AP_config-CYW954907AEVAL1F download run OTA2_SUPPORT is disabled

                    Building Bootloader waf.bootloader-NoOS-NoNS-CYW954907AEVAL1F-P101-SoC.43909

                    Building Serial Flash Loader App

                    prgm hdr cnt=3

                    total_size = 15904, entry_point = 0x696000

                    Loadsegment_offset = 0xA0 segment_size = 15668, segment_pad = 0

                    Loadsegment_offset = 0x3DE0 segment_size = 32, segment_pad = 0

                    Loadsegment_offset = 0x3E04 segment_size = 204, segment_pad = 0

                    Finished Building Serial Flash Loader App

                    Finished Building Bootloader

                     

                     

                    Making DCT image

                    Harsh_May2020.AP_config-CYW954907AEVAL1F

                    ----------------------------------|---------|---------|

                                                      |         |  Static |

                                  Module              |  Flash  |   RAM   |

                    ----------------------------------+---------+---------|

                    App                               |       0 |     140 |

                    crc                               |       0 |    1060 |

                    DHCP_Server                       |       0 |    1540 |

                    DNS                               |       0 |     108 |

                    Interrupt Vectors                 |       0 |     292 |

                    libc                              |       0 |   36781 |

                    Networking                        |       0 |   25755 |

                    NetX-Duo - Interfaces & Stacks    |       0 |      16 |

                    NVRam                             |       0 |    2231 |

                    Other                             |       0 |  106859 |

                    Packet Buffers                    |       0 |   71659 |

                    platform                          |       0 |     632 |

                    RAM Initialisation                |      32 |       0 |

                    resources                         |       0 |      32 |

                    Ring_Buffer                       |       0 |     132 |

                    Startup Stack & Link Script fill  |       0 |     273 |

                    Supplicant - BESL                 |       0 |      84 |

                    ThreadX                           |       0 |   13220 |

                    WICED                             |       0 |    5324 |

                    Wiced_RO_FS                       |       0 |     566 |

                    WWD                               |       0 |    2551 |

                    ----------------------------------+---------+---------|

                    TOTAL (bytes)                     |       0 |  269255 |

                    ----------------------------------|---------|---------|

                     

                    Creating Filesystem BCM94390x_targets.mk ...

                    ./tools/common/Win32/mk_wicedfs32 build/Harsh_May2020.AP_config-CYW954907AEVAL1F/filesystem.bin build/Harsh_May2020.AP_config-CYW954907AEVAL1F/resources/Staging/

                    Creating Filesystem Done

                    ./WICED/internal/dct.c:161:33: error: 'CLIENT_AP_SSID' undeclared here (not in a function); did you mean 'SOFT_AP_SSID'?

                                 .details = {{sizeof(CLIENT_AP_SSID)-1, CLIENT_AP_SSID},{{0,0,0,0,0,0}}, 0, 0, CLIENT_AP_BSS_TYPE, CLIENT_AP_SECURITY, CLIENT_AP_CHANNEL, CLIENT_AP_BAND}, \

                                                     ^

                    ./WICED/internal/dct.c:242:40: note: in expansion of macro 'DEFAULT_AP_LIST'

                         .wifi_config.stored_ap_list      = DEFAULT_AP_LIST,

                                                           ^~~~~~~~~~~~~~~

                    ./WICED/internal/dct.c:161:91: error: 'CLIENT_AP_BSS_TYPE' undeclared here (not in a function); did you mean 'CLIENT_AP_SSID'?

                                 .details = {{sizeof(CLIENT_AP_SSID)-1, CLIENT_AP_SSID},{{0,0,0,0,0,0}}, 0, 0, CLIENT_AP_BSS_TYPE, CLIENT_AP_SECURITY, CLIENT_AP_CHANNEL, CLIENT_AP_BAND}, \

                                                                                                               ^

                    ./WICED/internal/dct.c:242:40: note: in expansion of macro 'DEFAULT_AP_LIST'

                         .wifi_config.stored_ap_list      = DEFAULT_AP_LIST,

                                                            ^~~~~~~~~~~~~~~

                    ./WICED/internal/dct.c:161:111: error: 'CLIENT_AP_SECURITY' undeclared here (not in a function); did you mean 'SOFT_AP_SECURITY'?

                                 .details = {{sizeof(CLIENT_AP_SSID)-1, CLIENT_AP_SSID},{{0,0,0,0,0,0}}, 0, 0, CLIENT_AP_BSS_TYPE, CLIENT_AP_SECURITY, CLIENT_AP_CHANNEL, CLIENT_AP_BAND}, \

                                                                                                                                   ^

                    ./WICED/internal/dct.c:242:40: note: in expansion of macro 'DEFAULT_AP_LIST'

                         .wifi_config.stored_ap_list      = DEFAULT_AP_LIST,

                                                            ^~~~~~~~~~~~~~~

                    ./WICED/internal/dct.c:161:131: error: 'CLIENT_AP_CHANNEL' undeclared here (not in a function); did you mean 'SOFT_AP_CHANNEL'?

                                 .details = {{sizeof(CLIENT_AP_SSID)-1, CLIENT_AP_SSID},{{0,0,0,0,0,0}}, 0, 0, CLIENT_AP_BSS_TYPE, CLIENT_AP_SECURITY, CLIENT_AP_CHANNEL, CLIENT_AP_BAND}, \

                                                                                                                                                       ^

                    ./WICED/internal/dct.c:242:40: note: in expansion of macro 'DEFAULT_AP_LIST'

                         .wifi_config.stored_ap_list      = DEFAULT_AP_LIST,

                                                            ^~~~~~~~~~~~~~~

                    ./WICED/internal/dct.c:161:150: error: 'CLIENT_AP_BAND' undeclared here (not in a function); did you mean 'CLIENT_AP_SSID'?

                                 .details = {{sizeof(CLIENT_AP_SSID)-1, CLIENT_AP_SSID},{{0,0,0,0,0,0}}, 0, 0, CLIENT_AP_BSS_TYPE, CLIENT_AP_SECURITY, CLIENT_AP_CHANNEL, CLIENT_AP_BAND}, \

                                                                                                                                                                          ^

                    ./WICED/internal/dct.c:242:40: note: in expansion of macro 'DEFAULT_AP_LIST'

                         .wifi_config.stored_ap_list      = DEFAULT_AP_LIST,

                                                            ^~~~~~~~~~~~~~~

                    ./WICED/internal/dct.c:162:43: error: 'CLIENT_AP_PASSPHRASE' undeclared here (not in a function); did you mean 'SOFT_AP_PASSPHRASE'?

                                 .security_key_length = sizeof(CLIENT_AP_PASSPHRASE)-1, \

                                                               ^

                    ./WICED/internal/dct.c:242:40: note: in expansion of macro 'DEFAULT_AP_LIST'

                         .wifi_config.stored_ap_list      = DEFAULT_AP_LIST,

                                                            ^~~~~~~~~~~~~~~

                    ./WICED/internal/dct.c:244:49: error: 'CONFIG_AP_SSID' undeclared here (not in a function); did you mean 'SOFT_AP_SSID'?

                         .wifi_config.config_ap_settings  = {{sizeof(CONFIG_AP_SSID)-1, CONFIG_AP_SSID}, CONFIG_AP_SECURITY, CONFIG_AP_CHANNEL, CONFIG_AP_PASSPHRASE_LENGTH, CONFIG_AP_PASSPHRASE, CONFIG_VALIDITY_VALUE},

                                                                     ^~~~~~~~~~~~~~

                                                                     SOFT_AP_SSID

                    ./WICED/internal/dct.c:244:85: error: 'CONFIG_AP_SECURITY' undeclared here (not in a function); did you mean 'SOFT_AP_SECURITY'?

                         .wifi_config.config_ap_settings  = {{sizeof(CONFIG_AP_SSID)-1, CONFIG_AP_SSID}, CONFIG_AP_SECURITY, CONFIG_AP_CHANNEL, CONFIG_AP_PASSPHRASE_LENGTH, CONFIG_AP_PASSPHRASE, CONFIG_VALIDITY_VALUE},

                                                                                                         ^~~~~~~~~~~~~~~~~~

                                                                                                         SOFT_AP_SECURITY

                    ./WICED/internal/dct.c:244:105: error: 'CONFIG_AP_CHANNEL' undeclared here (not in a function); did you mean 'SOFT_AP_CHANNEL'?

                         .wifi_config.config_ap_settings  = {{sizeof(CONFIG_AP_SSID)-1, CONFIG_AP_SSID}, CONFIG_AP_SECURITY, CONFIG_AP_CHANNEL, CONFIG_AP_PASSPHRASE_LENGTH, CONFIG_AP_PASSPHRASE, CONFIG_VALIDITY_VALUE},

                                                                                                                             ^~~~~~~~~~~~~~~~~

                                                                                                                             SOFT_AP_CHANNEL

                    ./WICED/internal/dct.c:129:47: error: 'CONFIG_AP_PASSPHRASE' undeclared here (not in a function); did you mean 'SOFT_AP_PASSPHRASE'?

                    #define CONFIG_AP_PASSPHRASE_LENGTH    sizeof(CONFIG_AP_PASSPHRASE)-1

                                                                   ^

                    ./WICED/internal/dct.c:244:124: note: in expansion of macro 'CONFIG_AP_PASSPHRASE_LENGTH'

                         .wifi_config.config_ap_settings  = {{sizeof(CONFIG_AP_SSID)-1, CONFIG_AP_SSID}, CONFIG_AP_SECURITY, CONFIG_AP_CHANNEL, CONFIG_AP_PASSPHRASE_LENGTH, CONFIG_AP_PASSPHRASE, CONFIG_VALIDITY_VALUE},

                                                                                                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~

                    1. make.exe[1]: *** [build/Harsh_May2020.AP_config-CYW954907AEVAL1F/DCT.elf] Error 1

                    tools/makefiles/wiced_elf.mk:334: recipe for target 'build/Harsh_May2020.AP_config-CYW954907AEVAL1F/DCT.elf' failed

                    make: *** [main_app] Error 2

                    Makefile:351: recipe for target 'main_app' failed

                     

                    12:29:40 Build Finished (took 10s.328ms)