Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for using the stored setting for AP/STA mode. #436

Merged
merged 1 commit into from
Sep 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/freertos_drivers/common/WifiDefs.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ enum class WlanState : uint8_t
*/
enum class WlanRole : uint8_t
{
UNKNOWN = 0, /**< Wi-Fi station mode */
STA, /**< Wi-Fi station mode */
AP /**< Wi-Fi access point mode */
UNKNOWN = 0, /**< Default mode (from stored configuration) */
DEFAULT = UNKNOWN, /**< Default mode (from stored configuration) */
STA, /**< Wi-Fi station mode */
AP /**< Wi-Fi access point mode */
};

enum class CountryCode : uint8_t
Expand Down
25 changes: 22 additions & 3 deletions src/freertos_drivers/net_cc32xx/CC32xxWiFi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,10 @@ void CC32xxWiFi::set_default_state()
}

SlCheckError(result);
if (wlanRole == WlanRole::AP)
if (wlanRole == WlanRole::AP ||
(wlanRole == WlanRole::UNKNOWN && result == ROLE_AP))
{
wlanRole = WlanRole::AP;
if (result != ROLE_AP)
{
sl_WlanSetMode(ROLE_AP);
Expand All @@ -821,6 +823,7 @@ void CC32xxWiFi::set_default_state()
}
else
{
wlanRole = WlanRole::STA;
if (wlan_profile_test_none())
{
/* no profiles saved, add the default profile */
Expand All @@ -845,6 +848,24 @@ void CC32xxWiFi::set_default_state()
started = true;
}

/*
* CC32xxWiFi::wlan_set_role()
*/
void CC32xxWiFi::wlan_set_role(WlanRole new_role)
{
switch (new_role)
{
case WlanRole::STA:
sl_WlanSetMode(ROLE_STA);
break;
case WlanRole::AP:
sl_WlanSetMode(ROLE_AP);
break;
default:
DIE("Unsupported wlan role");
}
}

/*
* CC32xxWiFi::wlan_task()
*/
Expand Down Expand Up @@ -1192,8 +1213,6 @@ void CC32xxWiFi::net_app_event_handler(NetAppEvent *event)
// event_data = &event->EventData.ipLeased;
//

SlIpLeasedAsync_t *ip_leased = &event->Data.IpLeased;
ipAddress = ip_leased->IpAddress;
break;
}
case SL_NETAPP_EVENT_IP_COLLISION:
Expand Down
7 changes: 7 additions & 0 deletions src/freertos_drivers/net_cc32xx/CC32xxWiFi.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ public:
return wlanRole;
}

/** Change the default Wlan Role. This will be used in the next start(...)
* if the UNKNOWN role is specified. The new setting takes effect when the
* device is restarted (either via reboot or stop + start).
* @param role new role. Must not be UNKNOWN
*/
void wlan_set_role(WlanRole new_role);

/** @return 0 if !wlan_ready, else a debugging status code. */
WlanState wlan_startup_state()
{
Expand Down