Other Parts Discussed in Thread: CC3235SF,
Hello,
I have made modifications to the mqtt_client_CC3235SF_LAUNCHXL_tirtos7_ticlang example (with WIFI credentials and MQTT broker address only). Because I emulate the network using my mobile, I can easily switch between a 2.4GHz and a 5GHz AP. Everything functions properly when connecting to a 2.4GHz WiFi access point (AP). However, the code does not seem to find any 5GHz network.
SlWlanScanParam5GCommand_t ScanParamConfig5G;
ScanParamConfig5G.ChannelsMask = 0x3FFFFFFF; // Select ChannelsMask for channels 36, 40, 44, 48
ScanParamConfig5G.RssiThreshold = -99;
ret = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,
SL_WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS_5G,
sizeof(ScanParamConfig5G),
(uint8_t *)(&ScanParamConfig5G));
assert (ret == 0);
uint8_t WifiMode = 1;
ret = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,
SL_WLAN_GENERAL_PARAM_OPT_ENABLE_5G, 1,
(uint8_t *)&WifiMode);
/* Enable scan */
uint8_t hiddenSsid = 1;
uint8_t policyOpt = SL_WLAN_SCAN_POLICY(1, hiddenSsid);
/* Set scan policy - this API starts the scans */
uint32_t ScanIntervalinSec = 5;
ret = sl_WlanPolicySet(SL_WLAN_POLICY_SCAN, policyOpt,
(uint8_t*)(&ScanIntervalinSec),
sizeof(ScanIntervalinSec));
assert (ret == 0);
sleep(ScanIntervalinSec);
uint8_t* ssid = (uint8_t*)"test5G";
SlWlanSecParams_t secParams;
secParams.Key = (signed char*)"Chong1234";
secParams.KeyLen = strlen((const char *)(secParams.Key));
secParams.Type = SL_WLAN_SEC_TYPE_WPA_WPA2;
ret = sl_WlanSetMode(ROLE_STA);
ret = sl_Stop(SL_STOP_TIMEOUT);
ret = sl_Start(0, 0, 0);
ret = sl_WlanConnect((const signed char *)(ssid),
strlen((const char *)(ssid)), 0,
&(secParams), 0);
assert (ret == 0);
But I am able to scan for 5GHz WiFi AP stations and show in terminal with following code.
/* Set scan parameters for 5Ghz */
SlWlanScanParam5GCommand_t ScanParamConfig5G;
ScanParamConfig5G.ChannelsMask = 0x3FFFFFFF; // Select ChannelsMask for channels 36, 40, 44, 48
ScanParamConfig5G.RssiThreshold = -99;
ret = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,
SL_WLAN_GENERAL_PARAM_OPT_SCAN_PARAMS_5G,
sizeof(ScanParamConfig5G),
(uint8_t *)(&ScanParamConfig5G));
assert (ret == 0);
uint8_t WifiMode = 1;
ret = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID,
SL_WLAN_GENERAL_PARAM_OPT_ENABLE_5G, 1,
(uint8_t *)&WifiMode);
/* Enable scan */
uint8_t hiddenSsid = 1;
uint8_t policyOpt = SL_WLAN_SCAN_POLICY(1, hiddenSsid);
/* Set scan policy - this API starts the scans */
uint32_t ScanIntervalinSec = 5;
ret = sl_WlanPolicySet(SL_WLAN_POLICY_SCAN, policyOpt,
(uint8_t*)(&ScanIntervalinSec),
sizeof(ScanIntervalinSec));
assert (ret == 0);
sleep(ScanIntervalinSec);
/* Show scan networks in terminal */
SlWlanNetworkEntry_t Entries[10];
_u8 i;
_i16 resultsCount = sl_WlanGetNetworkList(0,10,&Entries[0]);
UART_PRINT("resultsCount:%d\r\n",resultsCount);
for(i=0; i< resultsCount; i++)
{
UART_PRINT("%d. ", i + 1);
UART_PRINT("SSID: %.32s ", Entries[i].Ssid);
UART_PRINT("BSSID: %x:%x:%x:%x:%x:%x ", Entries[i].Bssid[0], Entries[i].Bssid[1], Entries[i].Bssid[2], Entries[i].Bssid[3], Entries[i].Bssid[4], Entries[i].Bssid[5]);
UART_PRINT("Channel: %d ", Entries[i].Channel);
UART_PRINT("RSSI: %d ", Entries[i].Rssi);
UART_PRINT("Security type: %d ", SL_WLAN_SCAN_RESULT_SEC_TYPE_BITMAP(Entries[i].SecurityInfo));
UART_PRINT("Group Cipher: %d ", SL_WLAN_SCAN_RESULT_GROUP_CIPHER(Entries[i].SecurityInfo));
UART_PRINT("Unicast Cipher bitmap: %d ", SL_WLAN_SCAN_RESULT_UNICAST_CIPHER_BITMAP(Entries[i].SecurityInfo));
UART_PRINT("Key Mgmt suites bitmap: %d ", SL_WLAN_SCAN_RESULT_KEY_MGMT_SUITES_BITMAP(Entries[i].SecurityInfo));
UART_PRINT("Hidden SSID: %d ", SL_WLAN_SCAN_RESULT_HIDDEN_SSID(Entries[i].SecurityInfo));
UART_PRINT("PMF Enable: %d ", SL_WLAN_SCAN_RESULT_PMF_ENABLE(Entries[i].SecurityInfo));
UART_PRINT("PMF Required: %d\r\n", SL_WLAN_SCAN_RESULT_PMF_REQUIRED(Entries[i].SecurityInfo));
}