Skip to content

Commit

Permalink
Minor tweaks to the CC32xx WiFi driver to allow better setting of the…
Browse files Browse the repository at this point in the history
… AP configuration. (#437)
  • Loading branch information
balazsracz authored Sep 28, 2020
1 parent 4e3f14b commit ad4c454
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
27 changes: 26 additions & 1 deletion src/freertos_drivers/net_cc32xx/CC32xxWiFi.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,8 @@ void CC32xxWiFi::wlan_setup_ap(const char *ssid, const char *security_key,
sl_WlanSet(SL_WLAN_CFG_AP_ID, SL_WLAN_AP_OPT_SECURITY_TYPE, 1,
(uint8_t*)&sec_type);

if (sec_type == SL_WLAN_SEC_TYPE_OPEN)
if (sec_type == SL_WLAN_SEC_TYPE_OPEN ||
security_key == nullptr)
{
return;
}
Expand All @@ -780,6 +781,30 @@ void CC32xxWiFi::wlan_setup_ap(const char *ssid, const char *security_key,
strlen(security_key), (uint8_t*)security_key);
}

/*
* CC32xxWiFi::wlan_get_ap_config()
*/
void CC32xxWiFi::wlan_get_ap_config(string *ssid, SecurityType *security_type)
{
if (ssid)
{
// Reads AP SSID configuration from NWP.
ssid->clear();
ssid->resize(33);
uint16_t len = ssid->size();
uint16_t config_opt = SL_WLAN_AP_OPT_SSID;
sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (_u8*) &(*ssid)[0]);
ssid->resize(len);
}
if (security_type)
{
uint16_t len = sizeof(*security_type);
uint16_t config_opt = SL_WLAN_AP_OPT_SECURITY_TYPE;
sl_WlanGet(SL_WLAN_CFG_AP_ID, &config_opt, &len, (_u8*) security_type);
}
}


void CC32xxWiFi::connecting_update_blinker()
{
if (!connected)
Expand Down
15 changes: 12 additions & 3 deletions src/freertos_drivers/net_cc32xx/CC32xxWiFi.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "freertos_drivers/common/WifiDefs.hxx"

class CC32xxSocket;
class NetworkSpace;

/** Interface that aids in unit testing.
*/
Expand Down Expand Up @@ -211,6 +212,12 @@ public:
void wlan_setup_ap(const char *ssid, const char *security_key,
SecurityType security_type) override;

/** Retrieve current AP config.
* @param ssid will be filled with the SSID of the AP
* @param security_type will be filled with the security type
*/
void wlan_get_ap_config(string *ssid, SecurityType *security_type);

/** @return true if the wlan interface is ready to establish outgoing
* connections. */
bool wlan_ready()
Expand Down Expand Up @@ -488,24 +495,26 @@ public:
static std::string get_version();

private:
friend class ::NetworkSpace;

/** Translates the SecurityType enum to the internal SimpleLink code.
* @param sec_type security type
* @return simplelink security type
*/
uint8_t security_type_to_simplelink(SecurityType sec_type);
static uint8_t security_type_to_simplelink(SecurityType sec_type);

/** Translates the SimpleLink code to SecurityType enum.
* @param sec_type simplelink security type
* @return security type
*/
SecurityType security_type_from_simplelink(uint8_t sec_type);
static SecurityType security_type_from_simplelink(uint8_t sec_type);

/** Translates the SimpleLink code from the network scan to SecurityType
* enum.
* @param sec_type simplelink network scan security result
* @return security type
*/
SecurityType security_type_from_scan(unsigned sec_type);
static SecurityType security_type_from_scan(unsigned sec_type);

/** Set the CC32xx to its default state, including station mode.
*/
Expand Down

0 comments on commit ad4c454

Please sign in to comment.