Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of cc3000_hostdriver_mbedsocket by
Diff: cc3000_wlan.cpp
- Revision:
- 45:50ab13d8f2dc
- Parent:
- 34:1ad18123bf11
--- a/cc3000_wlan.cpp Sun Oct 13 11:46:21 2013 +0200
+++ b/cc3000_wlan.cpp Wed Nov 06 17:56:25 2013 +0100
@@ -86,22 +86,13 @@
// ASIC 1273 chip enable: toggle WLAN EN line
_spi.set_wlan_en(WLAN_ENABLE);
- if (spi_irq_state)
- {
+ if (spi_irq_state) {
// wait till the IRQ line goes low
- while(_spi.wlan_irq_read() != 0)
- {
- }
- }
- else
- {
+ while(_spi.wlan_irq_read() != 0);
+ } else {
// wait till the IRQ line goes high and then low
- while(_spi.wlan_irq_read() == 0)
- {
- }
- while(_spi.wlan_irq_read() != 0)
- {
- }
+ while(_spi.wlan_irq_read() == 0);
+ while(_spi.wlan_irq_read() != 0);
}
simpleLink_init_start(patches_available_host);
@@ -113,12 +104,10 @@
void cc3000_wlan::stop() {
// ASIC 1273 chip disable
- _spi.set_wlan_en( WLAN_DISABLE );
+ _spi.set_wlan_en(WLAN_DISABLE);
- // Wait till IRQ line goes high...
- while(_spi.wlan_irq_read() == 0)
- {
- }
+ // Wait till IRQ line goes high
+ while(_spi.wlan_irq_read() == 0);
_spi.close();
}
@@ -137,7 +126,7 @@
_event.simplelink_wait_event(HCI_CMND_WLAN_DISCONNECT, &ret);
errno = ret;
- return(ret);
+ return ret;
}
@@ -163,7 +152,7 @@
// Wait for command complete event
_event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY, &ret);
- return(ret);
+ return ret;
}
@@ -185,7 +174,7 @@
// Wait for command complete event
_event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_DEL_PROFILE, &ret);
- return(ret);
+ return ret;
}
int32_t cc3000_wlan::set_event_mask(uint32_t mask) {
@@ -194,22 +183,18 @@
uint8_t *args;
- if ((mask & HCI_EVNT_WLAN_TX_COMPLETE) == HCI_EVNT_WLAN_TX_COMPLETE)
- {
+ if ((mask & HCI_EVNT_WLAN_TX_COMPLETE) == HCI_EVNT_WLAN_TX_COMPLETE) {
_simple_link.set_tx_complete_signal(0);
// Since an event is a virtual event - i.e. it is not coming from CC3000
// there is no need to send anything to the device if it was an only event
- if (mask == HCI_EVNT_WLAN_TX_COMPLETE)
- {
+ if (mask == HCI_EVNT_WLAN_TX_COMPLETE) {
return 0;
}
mask &= ~HCI_EVNT_WLAN_TX_COMPLETE;
mask |= HCI_EVNT_WLAN_UNSOL_BASE;
- }
- else
- {
+ } else {
_simple_link.set_tx_complete_signal(1);
}
@@ -226,7 +211,7 @@
// Wait for command complete event
_event.simplelink_wait_event(HCI_CMND_EVENT_MASK, &ret);
- return(ret);
+ return ret;
}
@@ -248,7 +233,7 @@
// Wait for command complete event
_event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START, &ret);
- return(ret);
+ return ret;
}
@@ -264,7 +249,7 @@
// Wait for command complete event
_event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP, &ret);
- return(ret);
+ return ret;
}
int32_t cc3000_wlan::smart_config_set_prefix(uint8_t *new_prefix) {
@@ -276,10 +261,10 @@
ptr = _simple_link.get_transmit_buffer();
args = (ptr + HEADERS_SIZE_CMD);
- if (new_prefix == NULL)
+ if (new_prefix == NULL) {
return ret;
- else // with the new Smart Config, prefix must be TTT
- {
+ } else {
+ // with the new Smart Config, prefix must be TTT
*new_prefix = 'T';
*(new_prefix + 1) = 'T';
*(new_prefix + 2) = 'T';
@@ -292,7 +277,7 @@
// Wait for command complete event
_event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX, &ret);
- return(ret);
+ return ret;
}
#ifndef CC3000_TINY_DRIVER
@@ -316,19 +301,15 @@
args = UINT16_TO_STREAM(args, 0);
// padding shall be zeroed
- if(bssid)
- {
+ if (bssid) {
ARRAY_TO_STREAM(args, bssid, ETH_ALEN);
- }
- else
- {
+ } else {
ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
}
ARRAY_TO_STREAM(args, ssid, ssid_len);
- if(key_len && key)
- {
+ if (key_len && key) {
ARRAY_TO_STREAM(args, key, key_len);
}
@@ -339,7 +320,7 @@
_event.simplelink_wait_event(HCI_CMND_WLAN_CONNECT, &ret);
errno = ret;
- return(ret);
+ return ret;
}
int32_t cc3000_wlan::add_profile(uint32_t sec_type,
@@ -368,17 +349,14 @@
switch (sec_type)
{
//OPEN
- case WLAN_SEC_UNSEC:
+ case WLAN_SEC_UNSEC:
{
args = UINT32_TO_STREAM(args, 0x00000014);
args = UINT32_TO_STREAM(args, ssid_length);
args = UINT16_TO_STREAM(args, 0);
- if(b_ssid)
- {
+ if(b_ssid) {
ARRAY_TO_STREAM(args, b_ssid, ETH_ALEN);
- }
- else
- {
+ } else {
ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
}
args = UINT32_TO_STREAM(args, priority);
@@ -389,17 +367,14 @@
break;
//WEP
- case WLAN_SEC_WEP:
+ case WLAN_SEC_WEP:
{
args = UINT32_TO_STREAM(args, 0x00000020);
args = UINT32_TO_STREAM(args, ssid_length);
args = UINT16_TO_STREAM(args, 0);
- if(b_ssid)
- {
+ if (b_ssid) {
ARRAY_TO_STREAM(args, b_ssid, ETH_ALEN);
- }
- else
- {
+ } else {
ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
}
args = UINT32_TO_STREAM(args, priority);
@@ -408,8 +383,7 @@
args = UINT32_TO_STREAM(args, group_cipher_tx_key_index);
ARRAY_TO_STREAM(args, ssid, ssid_length);
- for(i = 0; i < 4; i++)
- {
+ for(i = 0; i < 4; i++) {
uint8_t *p = &pf_or_key[i * pairwise_cipher_or_tx_key_len];
ARRAY_TO_STREAM(args, p, pairwise_cipher_or_tx_key_len);
@@ -423,18 +397,15 @@
//WPA
//WPA2
- case WLAN_SEC_WPA:
- case WLAN_SEC_WPA2:
+ case WLAN_SEC_WPA:
+ case WLAN_SEC_WPA2:
{
args = UINT32_TO_STREAM(args, 0x00000028);
args = UINT32_TO_STREAM(args, ssid_length);
args = UINT16_TO_STREAM(args, 0);
- if(b_ssid)
- {
+ if (b_ssid) {
ARRAY_TO_STREAM(args, b_ssid, ETH_ALEN);
- }
- else
- {
+ } else {
ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
}
args = UINT32_TO_STREAM(args, priority);
@@ -458,7 +429,7 @@
// Wait for command complete event
_event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_ADD_PROFILE, &ret);
- return(ret);
+ return ret;
}
int32_t cc3000_wlan::ioctl_get_scan_results(uint32_t scan_timeout, uint8_t *results) {
@@ -477,7 +448,7 @@
// Wait for command complete event
_event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS, results);
- return(0);
+ return 0;
}
int32_t cc3000_wlan::ioctl_set_scan_params(uint32_t enable,
@@ -529,11 +500,11 @@
// Wait for command complete event
_event.simplelink_wait_event(HCI_CMND_WLAN_IOCTL_STATUSGET, &ret);
- return(ret);
+ return ret;
}
#else
-int32_t cc3000_wlan::wlan_add_profile(uint32_t sec_type,
+int32_t cc3000_wlan::add_profile(uint32_t sec_type,
uint8_t *ssid,
uint32_t ssid_length,
uint8_t *b_ssid,
@@ -576,7 +547,7 @@
_event.simplelink_wait_event(HCI_CMND_WLAN_CONNECT, &ret);
errno = ret;
- return(ret);
+ return ret;
}
#endif
@@ -619,20 +590,14 @@
if (profileArray[profileArray[0] + 1] > 16)
aes_decrypt((uint8_t *)(decKeyPtr + 16), key);
- if (*(uint8_t *)(decKeyPtr +31) != 0)
- {
- if (*decKeyPtr == 31)
- {
+ if (*(uint8_t *)(decKeyPtr +31) != 0) {
+ if (*decKeyPtr == 31) {
keyLen = 31;
decKeyPtr++;
- }
- else
- {
+ } else {
keyLen = 32;
}
- }
- else
- {
+ } else {
keyLen = *decKeyPtr;
decKeyPtr++;
}
