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.

CC3220: How to add profile

Part Number: CC3220

Hi.

I set the device in AP mode and connect my phone to the device network (mysimplelink-xxxx).

I created a page on the device that basically takes SSID name and the password from the user and passes it to the device using HTTP POST (input and submit form).

So while connected to the device I open the page, enter my home network SSID and password and send it to the device.

So far it's successful, I can see the device gets my entries and stores those in internal variables.

Now I want to use those entries to create a profile and connect the device to my home network in STA mode.

I am not able to find how it is done in out_of_box example. 

Can you please point me to the corresponding code section in out_of_box example or any other example?

Thanks,

David

  • Hi David,

    - If you want store profile directly from web you can use POST API (see chapter 8.4 at www.ti.com/.../getliterature.tsp ). How to read values via tokens is described at chapter 8.5.
    - How to store profiles from code is described at 3.3.3.2 in swru455.

    Jan
  • Hi Jan,

    I went with POST API route. After creating the profile I reset the board, the device started in STA mode and connected to my home network. However, when device connected to my home network, my phone disconnected from the device. Now both my phone and the device are connected to the home network, but the phone doesn't know the IP address of the device. Is there a way the phone could know the IP address of STA device?
    I want to automate this transition process, in other words, I want to have the following:
    - reset the board through software
    - device connects to home network (at this moment the phone looses connection to the device AP, because the device is in STA mode, AP doesn't exist anymore)
    - somehow I want to keep the device as both AP and STA, so that the device doesn't loose connection with the phone and is able to transmit the IP address of the STA to the phone. Is that possible? Maybe there is another, more conventional way to arrange this process? Could you share your thoughts?

    Thanks,
    David
  • Hi David,

    STA+AP mode is not supported by CC3220 devices. This way is not possible. For discovery devices in local network you need to use such kind of Discovery/Zero-Conf protocol.

    CC32xx devices supports mDNS protocols for discovery devices/services. mDNS works well at Apple devices. mDNS protocol is not natively supported by Windows and Android. For mDNS support you need to use 3rd party software (e.g. Bonjour Browser).

    At Windows is supported LLMNR protocol. This protocol you can implement by yourself. Another option is to create own discovery protocol. This can be done by simple listening to UDP broadcast and replaying back.

    Jan
  • Hi Jan,

    Is there a step-by-step guide on how to implement the complete provisioning process, detailing the required steps and corresponding commands? For example:

    Step 1. Configure the device with POST API, use chapter 8.4 of swru455 to see configuration parameters, minimum required - configure SSID, password, security and priority (Table 8.6) [You already helped with this step]
    Step 2. Reset the device in software - use xxxx command from aaaaaa document. After the reset the device should be able to connect to the provided profile in Step 1 and get an IP
    Step 3. Configure mDNS - use yyyy command from bbbbb document. After this the phone application should be able to find the IP of the device and connect to the device

    Thank you for your valuable feedback.

    Thanks,
    David
  • Hi David,

    As reference of device provisioning process you can take "provisioning" or "out_of_box" example from SDK.

    mDNS service is described at SWRU455 at chapter 9. mDNS is used at example "serial_wifi" in SDK as well.

    Jan
  • Hi Jan,

    Thank you for direction. Could you advise for Step 2, what command should be used in software to replicate the hardware reset button?

    Thanks,

    David

  • Hi David,

    In case of that you have stored connection profile, NWP restart should be enough (sl_Stop / sl_Start). But if you want restart whole CC32xx SoC, you cam use this:

    sl_Stop(100); /* call in case of NWP is running */
    PRCMHibernateIntervalSet(330);
    PRCMHibernateWakeupSourceEnable(PRCM_HIB_SLOW_CLK_CTR);
    PRCMHibernateEnter();

    Jan

  • Hi Jan,

    When I use (sl_Stop / sl_Start) the device starts in AP mode. How can I make the device start in STA mode?

    Thanks,
    David
  • Hi David,

    Use API sl_WlanSetMode(ROLE_STA). It may be required to set SL_WLAN_POLICY_CONNECTION by API sl_WlanPolicySet().

    Jan
  • Hi Jan,

    I followed those steps but it didn't work, I am sure I did something wrong or missed something that is assumed but I have no clue about. However, I found the following method which works, I pretty much re-used it from Control Task but replaced AP with STA:

            Status = sl_WlanSetMode(ROLE_STA);
    
            /* Check if switching to STA command is successful */
            if(Status == 0)
            {
                UART_PRINT(
                    "[DAVID Control task] device started in STA role, rebooting "
                    "device...\n\r");
    
                /* indicate AP role on OCP register */
                ocpRegVal = MAP_PRCMOCRRegisterRead(OCP_REGISTER_INDEX);
                ocpRegVal |= (1 << OCP_REGISTER_OFFSET);
                MAP_PRCMOCRRegisterWrite(OCP_REGISTER_INDEX, ocpRegVal);
                mcuReboot();
            }
            else
            {
                UART_PRINT("[DAVID Control task] device not started in STA role\n\r");
            }
    

    Do you see any potential issues with the above usage?

    The next step, mDNS cast, seems a bit more vague to me. I appended the following code to validateLocalLinkConnection function, after the device successfully acquires IP  from my home network:

                UART_PRINT("Started in STA mode, starting to cast mDNS \n\r");
                retVal = sl_NetAppStop(SL_NETAPP_MDNS_ID);
                UART_PRINT("RetVal from NetAppStop is equal to %d \n\r", retVal);
                retVal = sl_NetAppStart(SL_NETAPP_MDNS_ID);
                UART_PRINT("RetVal from NetAppStart is equal to %d \n\r", retVal);
                Options = SL_NETAPP_MDNS_OPTIONS_IS_NOT_PERSISTENT | SL_NETAPP_MDNS_IPV4_ONLY_SERVICE;
                retVal = sl_NetAppMDNSRegisterService(AddService, strlen(AddService),"aaa",strlen("aaa"),4578,120,Options);
                UART_PRINT("RetVal from sl_NetAppMDNSRegisterService is equal to %d \n\r", retVal);
    

    I am not sure if the above code is correct for starting mDNS casting. If it's correct, then how am I going to listen to this cast from my webpage, are there any javascript function examples for that purpose? 

    I realize that I might be following wrong tracks altogether, if I am on wrong direction, could you please let me know what my next step should be?

    Thanks,

    David

  • Hi David,

    After changing mode from AP to STA you need to restart NWP. Your code probably should work but it is not a best way. Better way is:
    - set connection policy if you not already have it
    - set to STA mode
    - restart NWP

    As I said...
    mDNS is fully supported by Apple devices. At Windows and Android devices you need 3rd party software. In case you need to resolve .local address at Windows computer (from webrowser) you need to implement LLMNR.

    BTW ... there is one more option for discovery devices in local network. But for this purpose you need to use external webserver in internet.

    Jan