Skip navigation
Home > All Places > WICED Studio Wi-Fi/Combo > WICED Studio Wi-Fi/Combo Forums > Blog > 2018 > December
2018

SUMMARY:

  We have some snip ,test codes in SDK release, this blog is showing how to use snip.dct_read_write, snip.apsta, snip.GPIO to finish one application. And the function is to join different AP by pressing user button. It will help you to understand how to join AP , how to read/write DCT area, be familiar with rule of GPIO operation. Test is based on Wiced 6.2.1.2 release on CYW954907AEVAL1F EVB.

 

MAIN WORK:

  1. STA join one AP, and ping , this is the APSTA from snip .
  2. Because CYW54907 has big internal flash and ram, so apsta includes COMMAN_CONSOLE function,

       you can type <status> to check the interface like below:

3. If you want to use command console ,really need big memory (2MB and above), and you need to enable it in makefile:

GLOBAL_DEFINES += INCLUDE_COMMAND_CONSOLE

If you want to use the DCT mac address, you need to enable it in makefile:

GLOBAL_DEFINES +=MAC_ADDRESS_SET_BY_HOST

Some other useful commands are showed here.

4. ADD user_1, user_2 GPIO test code into APSTA.

to find platform_gpio_buttons define in platform.c and platform.h

Below are some structure relationships in the code.

You will see real user_1, user_2 connections in the pdf circuit.

 

About user_1 and user_2 button initialization, these two pins are already set to INPUT_PULL_UP by default in the boot stage of the board,so you don’t need to initialize them again as a GPIO.

5.     Add DCT read code into APSTA.

  • Show notes about DCT usage
  • With the DCT in external FLASH, the second argument is ignored. For clarity, always use WICED_TRUE ---- This is for 54907 because DCT is in external flash.

      

  • wiced_dct_read_lock() and wiced_dct_read_unlock() need to be used with a couple.  But you do not need to call wiced_dct_read_lock() in order to write date to DCT.

    

  • DCT structure will be used by bootloader also , the sub-structure platform_dct_header_t, which is always at the start of the DCT area of the FLASH.
  • From SDK-3.7.0, it is possible to upgrade the DCT layout when doing SDK upgrading .
  • There are two DCT areas defined in the FLASH, designated as DCT1 and DCT2. we use this in a flip-flop arrangement. When need to update DCT area, we copy the “current” DCT to the opposite area , then indicate that “new” area is the “current” area. The “old ” area is viable DCT area.

 

    Below is the wifi config section printed:

 

6. Adding code to switch AP

  • IOCTL command description.
    • If you want to input “wl down” when DUT is in STA mode, call this function.

         

    • If you want to input “wl disassoc”, call this function

         

    • If you want to input an IOCTL command with value or not, please use below interface:

                 And it is better to add some wwd_wlan_status judge before jumping into  calling.

           

7. add all functions into apsta code:

    The steps are:

  1. to check the Button pressed status.
  2. to disassociate the AP.
  3. Network down.
  4. to write DCT to update the AP ssid which will be joined.
  5. to print the DCT updated.
  6. Network up, join the AP.

 

Reference:

Snip.apsta

Snip.GPIO

Snip.dct_read_write

WICED Device Configuration Table (DCT) Users Guide

cyw954907aeval1f.pdf

  • SUMMARY:

  We divide the SDK code into different module or library for specific function, and Hierarchical software design also is useful for the code maintenance. This blog is to show the log setting for different module.  Please see below architecture from SDK release document. Our aim is to print useful logs when issue happens,  upload one module picture from SDK release .

 

  • HOW TO Print LOGS
  1. To use “printf” directly, this is very convenient for the debug, but not easy to make a good management for the logs added. Some basic knowledge of print is in this link

https://fresh2refresh.com/c-programming/c-printf-and-scanf/

 

     #include <stdio.h>

     int main()

     {

        char ch = 'A';

        char str[20] = "fresh2refresh.com";

        float flt = 10.234;

        int no = 150;

        double dbl = 20.123456;                         

        printf("Character is %c \n", ch);

        printf("String is %s \n" , str);

        printf("Float value is %f \n", flt);

        printf("Integer value is %d\n" , no);

        printf("Double value is %lf \n", dbl);

        printf("Octal value is %o \n", no);

        printf("Hexadecimal value is %x \n", no);

        return 0;

     }

 

·    %d got replaced by value of an integer variable  (no),

·       %c got replaced by value of a character variable  (ch),

·       %f got replaced by value of a float variable  (flt),

·       %lf got replaced by value of a double variable  (dbl),

·       %s got replaced by value of a string variable  (str),

·       %o got replaced by a octal value corresponding to integer variable  (no),

·       %x got replaced by a hexadecimal value corresponding to integer variable

·       \n got replaced by a newline.

 

2.     In wwd_debug.h, wwd_debug.c , wiced_defaults.h

We defined Macros to control the log output for different MODULE.

Modules are Application, library, Webserver , Network, RTOS,

Security , WPS, Supplicant, Wiced , WWD(Wiced wi-fi Driver) .

 

We have good instructions and warnings for the log setting:

* ** WARNING for PRINTING **

*  If printing is enabled, the stack of each thread that uses printing

* must be increased to at least 4 kBytes since the printf function uses

a lot of memory (including dynamic memory)

/* Select which group of functions are allowed to print */

/* WPRINT_ENABLE_<MODULE>_ERROR - Enable print messages in the respective <MODULE> that are present

* as WPRINT_<MODULE>_ERROR.

* For instance, if WPRINT_ENABLE_WWD_ERROR is enabled, then trace messages that are under

* WPRINT_WWD_ERROR will be printed. This directive shall also result in an ASSERT if the target is built in DEBUG                                 mode.

* WPRINT_ENABLE_<MODULE>_DEBUG - Enable print messages in the respective module that are present as

* WPRINT_<MODULE>_DEBUG.

* For instance, if WPRINT_ENABLE_WWD_DEBUG is enabled, then trace messages that are under

* WPRINT_WWD_DEBUG will be printed.

 

* WPRINT_ENABLE_<MODULE>_INFO - Enable print messages in the respective module that are present as

* WPRINT_<MODULE>_INFO.

* For instance, if WPRINT_ENABLE_WWD_INFO is enabled, then trace messages that are under

* WPRINT_WWD_INFO will be printed.

 

If you disable all the logs, there will have a compiled error, so please keep this one at least:

#define WPRINT_ENABLE_APP_INFO           /* Application prints */

 

 

So general debug sequence for log enable:

    • Enable WPRINT_ENABLE_MODULE_INFO to track the process.
    • If found an error was printed out, check which module , then enable DEBUG and ERROR mode also. Be noted, Debug compile will go to an assert if enable ERROR layer .
    • Find the bug position , add more debug info by using the same level log print.

I think if you want to manage the log clearly , you can define one MACRO to just add your debug info ,like           #define WPRINT_ENABLE_BUG_DEBUG_INFO , after issue is fixed you can disable it .Another log print mode :

 

3.     Wiced_log_setting, it is often used on application area.

If you want to close the log , please change the log to WICED_LOG_OFF, the logs added in      the application will be disabled. And strongly suggest to use this debug info in application debug stage.

Log initialize at application_start and enum structure.

         wiced_log_init(WICED_LOG_INFO, render_log_output, wiced_time_get_time);

         wiced_log_msg(WLF_DEF, WICED_LOG_NOTICE, "wiced logging system is initialized\n");

 

typedef enum

{

    WICED_LOG_OFF = 0,

    WICED_LOG_ERR,

    WICED_LOG_WARNING,

    WICED_LOG_NOTICE,

    WICED_LOG_INFO,

    WICED_LOG_DEBUG0,

    WICED_LOG_DEBUG1,

    WICED_LOG_DEBUG2,

    WICED_LOG_DEBUG3,

    WICED_LOG_DEBUG4,

 

    WICED_LOG_PRINTF, /* Identifies log messages generated by wiced_log_printf calls */

 

    WICED_LOG_MAX

} WICED_LOG_LEVEL_T;

 

b: How to write to STDOUT .

use this function:

Enable time output with log together.

Filter Blog

By date:
By tag: