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 220.127.116.11 release on CYW954907AEVAL1F EVB.
- STA join one AP, and ping , this is the APSTA from snip .
- 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:
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:
- to check the Button pressed status.
- to disassociate the AP.
- Network down.
- to write DCT to update the AP ssid which will be joined.
- to print the DCT updated.
- Network up, join the AP.