Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

How to switch AP connection in an application

lock attach
Attachments are accessible only for community members.

How to switch AP connection in an application

Zhengbao_Zhang
Moderator
Moderator
Moderator
250 sign-ins First comment on KBA 10 questions asked

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:

pastedImage_5.png

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.

pastedImage_6.png

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.

pastedImage_18.png

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

pastedImage_24.png

 

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.

pastedImage_25.png

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.

       pastedImage_38.png

  • 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.

     pastedImage_43.png

  • 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:

pastedImage_48.png

 

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.

          pastedImage_58.png

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

          pastedImage_63.png

    • 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.

            pastedImage_67.png

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.

 

pastedImage_71.png

pastedImage_72.png

Reference:

Snip.apsta

Snip.GPIO

Snip.dct_read_write

WICED Device Configuration Table (DCT) Users Guide

cyw954907aeval1f.pdf

Attachments
943 Views
Comments
cohuc_3807591
Level 3
Level 3
5 likes given First like given

Hey zhez​:

Thanks for the great post - lot of good information here! I wanted to ask you about the speed of the change on devices like the 43907 and 54907 (without 802.11r). I took what was here and did some timing and I got that the average time to switch to a new AP (including network down, rewriting dct, then bringing the network interface back up) was about 20 seconds all told on average. Would you have any ideas on what the bottlenecks are in this situation? The one major one I can think of is DHCP so maybe using a static IP would be best but are there any ways you think time could be shaved off those 20 seconds?

I appreciate the consideration of the question, and thanks again for the blog post.

Zhengbao_Zhang
Moderator
Moderator
Moderator
250 sign-ins First comment on KBA 10 questions asked

Hello:

     thanks,  I think we can have a time print to figure out which is the max time consuming part .  Just as you said DHCP will save a lot of time, and we can do more diggings on network_up period.