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.

CC3220SF: CC3220sf wifi door lock- Adding new wifi profile

Part Number: CC3220SF
Other Parts Discussed in Thread: TIDC-01005, CC2640

Hello,

I'm working on cc3220sf launch pad.i am building my application on wifi door lock reference tidc -01005.

Right now I'm working on provisioning tasks.

In the beginning when there is no wifi profile ..using the wifi start up pro I'm AP provisioning it  a new AP. once the profile is added it will be stored in serial flash and after that every time the device restarts it will automatically provisioned to the stored profile.

1)My question is what if i need to provision to a new AP?how can it go to the AP mode again?

2) Can i delete or erase the old profile using software without factory reset?

Regards,

Sanath Rai

  • Hi Sanath,

    1. Our programmer's guide show you what API you could use to go into AP mode. Refer to section 4.4.2.1 specifically. Keep in mind you have to set the mode before calling sl_Start.

    2. This feature is also discussed in the programmer's guide - section 4.3. 

    Jesu

  • Hi Jesu,

    Thank you for the reply.

    I'll go through the guide.

    If any doubt I'll let you know.

    Regards,

    Sanath Rai

  • Hi Jesu,

    I went through the section 4.3 in guide where i can delete the stored profile using sl_WlanProfileDel

    In my application i am trying to delete the stored profile using sl_WlanProfileDel when i press a particular switch in cc3220 launchpad.

    but the issue here is the profile stored is getting deleted but the code is getting hanged after the sl_WlanProfileDel API. its not returning anything .

    when i hard reset the board it goes to AP provisioning mode again which means the profile stored has been deleted.

    but why is it hanged after the command called?

    But when there is no profile stored if the command sl_WlanProfileDel is called it will not get hanged.

    below is code snippet i am using

    i am calling this inside the external button interrupt ISR

    int Status;


    Status = sl_WlanProfileDel(0);

    if( Status ) {

    Display_printf( display,0,0,"Error");

    }

    regards,

    Sanath

  • Sanath,

    Does it work if you call it outside of ISR? I don't see a problem with how you're calling sl_WlanProfileDel. 

    Jesu

  • Hi Jesu,

    I didn't try it outside exactly...I'll try it out tomorrow first thing in the morning.

    But the confusing part is the profile is getting deleted...but code hangs.

    Does deleting api ( sl_WlanProfileDel)needs the provisioning task to be stopped?

    I'm asking this because when there is no profile at the time api is called it will not get hanged...may be because there's no profile to be deleted i guess.

    Also one more thing i just found out that 7 profiles can be stored in serial flash....but once in the beginning if we provision it to a profile it will directly get connected to the first stored profile...

    How can we provision more profiles by going to AP provisioning mode?

    Regards,

    Sanath

  • Hi Jesu,

    I tested it outside the ISR and it is working.

    Inside the ISR its getting hanged.i also tested in UART recieve ISR it also hanged there.

    what might be the issue? 

    Regards

    Sanath

  • Hi Jesu,

    I read in one of the post that simplelink API when called from ISRs has issues...

    For the time being I am planning to change my application a bit by calling the APIs outside ISRs....

    Today i tested sl_WlanProfileDel outside isr it's working...

    According to the guide we can store upto 7 profiles but in my application I need max 2 profiles so i have changed the max profile to 2.

    Let's say i am storing 2 profiles ...the first profile index will be 0 right? and then the next profile which stores has the index as 1....

    So when i need to delete the first profile i am calling

    sl_WlanProfileDel(0)...but in this case for me both profiles are getting deleted...i don't understand that..

    Regards

    Sanath

  • Sanath,

    When you add a profile it API returns what index the profile was stored at. Deleting more than one profile when you are specifically referring to index 0 does not sound right. The only way to delete all profile is by passing 0xFF or calling sl_WlanProfileDel one by one for each index.

    Jesu

  • Hi Jesu,

    Yes when adding profile api returns the index number...but in the wifi door lock tidc-01005 reference design project I'm little bit confused how the profile is being added because there is no api (sl_WlanProfileAdd)  for adding profile is being called...if it was the case i could have easily read the index number and used it for deleteing individual profiles.

    Regards

    Sanath

  • Hi Jesu,

    Below is the way i am trying now to add the profile is it the correct way?

    I am getting the return value as -2003 for the API while adding profile  which means invalid parameter

    _i16 Index;
    int32_t retValue;
    SecParams.Type = SL_WLAN_SEC_TYPE_WPA_WPA2;


    sl_WlanProfileDel(255);

    Index = sl_WlanProfileAdd((const int8_t*)App_CB.connectionSSID,
    strlen((const char *) App_CB.connectionSSID),
    NULL,
    &SecParams, NULL, 1, 0);

    Regards,

    Sanath

  • Hi Jesu,

    Here is a update.

    when i passed  the security parameters key and key length i am able to add profile successfully but there is a small issue here is i am hard coding the key and key length .

    where can i read the Key and Key Length?SSID i'm able to read and pass as parameter 

    SlWlanSecParams_t SecParams;
    _i16 Index;
    SecParams.Type = SL_WLAN_SEC_TYPE_WPA_WPA2;
    SecParams.Key ="networks123";
    SecParams.KeyLen= 11 ;

    sl_WlanProfileDel(255);

    Index = sl_WlanProfileAdd((const int8_t*)App_CB.connectionSSID,
    strlen((const char *) App_CB.connectionSSID),
    NULL,
    &SecParams, NULL, 1, 0);

     

    Regards

    Sanath

  • Hi,

    It is not possible read back password from the security reasons.

    Jan

  • Hi Jan,

    Any other way to pass the security key and length?

    Regards

    Sanath

  • Hi Sanath,

    Key (WLAN password) when is stored into profile there is no way how to read back. If you need to know key later, you need to remember it somehow before you are saving into profile.

    Jan

  • Jan,

    Here in my application i need to store one profile at once so  i'm trying to delete old profiles and after that i'm trying add the new profile after my provision is successfully completed as soon i get the SSID and other details.

    SlWlanSecParams_t SecParams;
    _i16 Index;
    SecParams.Type = SL_WLAN_SEC_TYPE_WPA_WPA2;
    SecParams.Key ="networks123";
    SecParams.KeyLen= 11 ;

    sl_WlanProfileDel(255);

    Index = sl_WlanProfileAdd((const int8_t*)App_CB.connectionSSID,
    strlen((const char *) App_CB.connectionSSID),
    NULL,
    &SecParams, NULL, 1, 0);

     

     

    Any suggestion how i can overcome this issue?

    Regards

    Sanath

  • Hi Sanath,

    Sorry, I don't understand what you need. Why you need to read values (key) from already stored profile?

    Storing connection profiles is is a one-way procedure. Once you save values you are not able read back them all.

    Jan

  • Hi Jan,

    I will explain.

    Initially using AP provisioning i will store a profile.

    and then i will  add new profile by going to AP provisioning mode once again where i will provision to a new profile but at the same time i need to delete the old profile.

    Individually i am unable to delete the old profile so i'm deleting all the old profile as you can see in my code snippet and then adding the new profile which i have provisioned second time.

    i hope you got it :)

    regards

    Sanath

  • Hi Sanath,

    If you need to need to retain some of already stored profiles you cannot delete all profiles. Because there is no way how to read all parameters of profile (not able get key) before deleting. One of options may to be save all parameters independently into file, additional memory etc.

    Jan

  • Hi Jan,

    Or i need to take the Key as input from outside like phone and save it in a register and after that pass it to the API and add new profile.

    i will just think about it.

    Thank you,

    Regards,

    Sanath

  • Hi Jan,

    1) In tidc-01005 wifi doorlock reference project where is the API sl_WlanProfileAdd called for the initial provisioning? I don't find it anywhere?

    So that i need to read the Index number after the first profile is saved. For each profile added it should return the index number ,after getting the Index number i can use it to delete the profile individually.

    Regards,

    Sanath Rai

  • Hi,

    I am not familiar with TIDC-01005 design. But after quick looks, there are two (three) ways for provisioning:

    • BLE provisioning. In this case are provisioning information transferred via BLE (from CC2640 via UART) and profile is saved by code in application MCU (see sl_WlanProfileAdd() inside network_if.c).
    • Provisioning via Wifi is done via AP or SmartConfig. In this case application code starts provisioning procedure and transferring provisioning information is done inside NWP without interaction from application MCU code. Information about provisioning procedure you find here.

    Jan

     sl_WlanProfileAdd

  • Hi Jan,

    Yes i'm at present building my application on AP provisioning,where the sl_WlanProfileAdd has not been used.

    Correct me if i'm wrong .

    say for example there are 2 profiles the first profile index should be 0 right?

    the next will be 1.

    so if i need to delete the first profile i need to call sl_WlanProfileDel(0) correct?

    and to delete second profile sl_WlanProfileDel(1) right?

    but right now when i call sl_WlanProfileDel(0) both profiles are  getting deleted,i dont know why.

    Regards

    Sanath

  • Hi Sanath,

    As I know, your statement above should be correct. I don't know why your both profiles are deleted by sl_WlanProfileDel(0). Please wait for answer from TI.

    Personally I use my own provisioning methods without using profiles. It allows to me much flexible way how to setup my device.

    Jan

  • Hi Jan,

    Ok,I will wait for an answer from TI.

    As i have looked up to tidc-01005 wifi door lock reference project Mr  has been replying many of the queries on this reference project.

    Any way this thread can be linked to him?

    Regards

    Sanath

  • Hi Sanath,

    If you need, you can contact his by private message at e2e forum. I don't want share his email without his permission.

    Jan

  • Hi Jan,

    Ok i'll try to contact him via e2e forum.

    Thank You,

    Regards,

    Sanath 

  • Sanath,

    The only place where sl_WlanProfileAdd is called in network_if.c line 1702 in the switch case for BLE provisioning.

    For a quick test, please call sl_WlanProfileGet before calling delete to make sure both profile exist. 

    Also, apologies if this was asked already I don't remember, but are you checking the return from sl_WlanProfileAdd to make sure it worked? Please make sure it's not returning an error (negative value).

    Jesu


  • Yes, sl_WlanProfileAdd has not been used in AP provisioning.
    For sl_WlanProfileGet Index number is one of the parameter which is the return value of sl_WlanProfileAdd.

    I had called  sl_WlanProfileGet and have confirmed that two profiles are added.

    when i passed  the security parameters key and key length i am able to add profile successfully but there is a small issue here is i am hard coding the key and key length .

    SSID i'm able to read and pass as parameter 

    SlWlanSecParams_t SecParams;
    _i16 Index;
    SecParams.Type = SL_WLAN_SEC_TYPE_WPA_WPA2;
    SecParams.Key ="networks123";
    SecParams.KeyLen= 11 ;

    sl_WlanProfileDel(255);

    Index = sl_WlanProfileAdd((const int8_t*)App_CB.connectionSSID,
    strlen((const char *) App_CB.connectionSSID),
    NULL,
    &SecParams, NULL, 1, 0);

    Regards

    Sanath

     

  • Hi Sanath,

    sanath rai said:

    but there is a small issue here is i am hard coding the key and key length .

    Just use strlen for key length like you are for SSID.

    I cannot reproduce the behavior you're seeing. Is how you showed above the only way you're calling sl_WlanProfileDel?

    Jesu

  • Hi Jesu,

    Let me explain exactly what i am trying to do.

    In our application we are planning to store just two profiles.that is initially we will provision to a profile and store it .

    next  when i press a button i will go to AP mode again and will add another profile, if it adds successfully i need to delete the first profile .this is the plan.

    Now  i am unable to make this work.

    First scenario i tried is

    I will tell you where i have changed the code in the reference design.

    i have added a pushbutton ISR in that i am triggering the AP mode again by adding the following piece of code

    SignalProvisioningEvent(PrvnEvent_Triggered);
    SET_STATUS_BIT(App_CB.status, AppStatusBits_APProvInProgress);

    Then when it enters AP mode i will add another profile by AP provisioning, after that when provision is completed the code will enter provision successful part in file provisioning_task.c function ReportSuccess() here i am trying to add the follwing code


    sl_WlanProfileDel(0);

    that is, i am trying to delete the first profile assuming the index number for first profile is 0 .

    here everything gets deleted.

    Note: i have made it confirm that  both profiles are added.

    Second scenario i tried is

    same as above 

    i have added a pushbutton ISR in that i am triggering the AP mode again by adding the following piece of code

    SignalProvisioningEvent(PrvnEvent_Triggered);
    SET_STATUS_BIT(App_CB.status, AppStatusBits_APProvInProgress);

     

    But in file provisioning_task.c function ReportSuccess()  i am trying to add the following code

     SlWlanSecParams_t SecParams;
     _i16 Index;

     SecParams.Type = SL_WLAN_SEC_TYPE_WPA_WPA2;
     SecParams.KeyLen= strlen((const char *)SecParams.Key);

    sl_WlanProfileDel(255);


     Index = sl_WlanProfileAdd((const int8_t*)App_CB.connectionSSID,
     strlen((const char *) App_CB.connectionSSID),
     NULL,
     &SecParams, NULL, 1, 0);

    here as soon as second profile is added i am trying to delete all the profiles and then using  sl_WlanProfileAdd i am trying to add the second profile using the data acquired while AP provisioning.

    which is not happening because of key and key length parameters.i am able to get only SSID and SSID length .

    i tried passing only strlen of key  as you suggested but same issue continues.

    Regards

    Sanath

     

     

  • Sanath,

    I'm not sure why you're having trouble with key length. This worked for me:

    int p1, p2;
    SlWlanSecParams_t SecParams;
    SecParams.Type = SL_WLAN_SEC_TYPE_WPA_WPA2;
    SecParams.Key ="networks123";
    SecParams.KeyLen= strlen("networks123");
    p1 = sl_WlanProfileAdd("AP1", strlen("AP1"), NULL, &SecParams, NULL, 7, 0);

    Jesu

  • Hi Jesu,

    I think you didn't get me .

    sl_WlanProfileAdd is working for me  as I mentioned in my earlier post only when i  hard code the key.....but in generic when a unknown profile comes with a new key how can i add is the question?

    But as Jan suggested we cannot read the key so that's not an option.

    Regards

    Sanath

  • Sanath,

    Could you provide me with a simple code snippet to add to the example so I can reproduce your problem? To make sure we are still on the same page, the problem you're having is when you delete one profile - two profiles are deleted. Please confirm this is still the problem because and let's focus on it because I'm not sure what key lengths have to do with it. I've tested add, delete and get with multiple profiles and configurations and I cannot reproduce any unexpected behavior.

    Jesu

  • Hi Jesu,

    Really sorry for the confusion.

    As i told you i am building my application on tidc-01005 wifi door lock reference project i have not changed any major things in this project .initially i am adding a profile using AP provisioning starter pro in my android mobile.Next  i have to add another profile, after adding if it connects successfully i need to delete the old one that's it.

    Note: i am not using BLE portion of the code

    below is the code i am trying 


    int32_t ret = -1;

    /* Store profile variables */
    _i16 profileIndex = 0;
    signed char profileName[32];
    _i16 profileNameLen;
    unsigned char profileMacAddr[6];
    _u32 profilePriority;
    SlWlanSecParams_t SecParams;
    SlWlanGetSecParamsExt_t SecExtParams;

    // Check for existing profile
    // Returns profile security type (0, 1, 2) if it exists or negative on error
    ret = sl_WlanProfileGet(profileIndex, profileName, &profileNameLen,
    profileMacAddr, &SecParams, &SecExtParams,
    &profilePriority);

    if(ret < 0){

    sl_WlanProfileDel(1);

    }else{

    sl_WlanProfileDel(0);

    }

    every time after the new profile is added i am checking whether the Index 0 has the profile or not using sl_WlanProfileGet API by passing 0 as Index parameter. if it returns negative value i am trying to delete the index 1 profile by calling sl_WlanProfileDel(1) as you can see .if it returns positive value i will delete index 0 profile by calling sl_WlanProfileDel(0).

    this above logic i am using because i need to store only 1 profile at a time and delete old profile.

    but right now whats happening is when i delete one profile and when i reboot its going to AP mode again its not getting connected the stored profile.

    for confirmation i have checked that 2 profiles are getting added.

    Regards,

    Sanath

  • You go into AP mode because the example goes into AP provisioning every time it starts up. If you already have a profile stored you should put the device in station mode and make sure you sure auto connect policy enable or try to manually connect yourself before going into provisioning.

    Jesu