mirror of https://github.com/ARMmbed/mbed-os.git
PSOC6: apply astyle to WHD EMAC driver implementation
parent
6bde6efa0a
commit
6bdb10d180
|
@ -1,5 +1,6 @@
|
|||
/* WHD STAION implementation of NetworkInterfaceAPI
|
||||
* Copyright (c) 2017 ARM Limited
|
||||
* Copyright (c) 2017-2019 ARM Limited
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -37,7 +38,7 @@
|
|||
struct whd_scan_userdata {
|
||||
Semaphore *sema;
|
||||
WiFiAccessPoint *aps;
|
||||
vector<whd_scan_result_t> *result_buff;
|
||||
std::vector<whd_scan_result_t> *result_buff;
|
||||
unsigned count;
|
||||
unsigned offset;
|
||||
whd_interface_t ifp;
|
||||
|
@ -51,65 +52,92 @@ static whd_scan_result_t *result_ptr = &internal_scan_result;
|
|||
extern "C" void whd_emac_wifi_link_state_changed(bool state_up, whd_interface_t ifp);
|
||||
|
||||
|
||||
int whd_toerror(whd_result_t res) {
|
||||
int whd_toerror(whd_result_t res)
|
||||
{
|
||||
switch (res) {
|
||||
case WHD_SUCCESS: return NSAPI_ERROR_OK;
|
||||
case WHD_SUCCESS:
|
||||
return NSAPI_ERROR_OK;
|
||||
case WHD_UNSUPPORTED:
|
||||
case WHD_WLAN_UNSUPPORTED:
|
||||
case WHD_WLAN_ACM_NOTSUPPORTED: return NSAPI_ERROR_UNSUPPORTED;
|
||||
case WHD_WLAN_ACM_NOTSUPPORTED:
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
case WHD_BADARG:
|
||||
case WHD_WLAN_BADARG: return NSAPI_ERROR_PARAMETER;
|
||||
case WHD_WLAN_BADARG:
|
||||
return NSAPI_ERROR_PARAMETER;
|
||||
case WHD_WLAN_NOTASSOCIATED:
|
||||
case WHD_INVALID_JOIN_STATUS: return NSAPI_ERROR_NO_CONNECTION;
|
||||
case WHD_INVALID_JOIN_STATUS:
|
||||
return NSAPI_ERROR_NO_CONNECTION;
|
||||
case WHD_BUFFER_UNAVAILABLE_PERMANENT:
|
||||
case WHD_BUFFER_UNAVAILABLE_TEMPORARY:
|
||||
case WHD_RX_BUFFER_ALLOC_FAIL:
|
||||
case WHD_BUFFER_ALLOC_FAIL:
|
||||
case WHD_WLAN_NOMEM:
|
||||
case WHD_MALLOC_FAILURE: return NSAPI_ERROR_NO_MEMORY;
|
||||
case WHD_MALLOC_FAILURE:
|
||||
return NSAPI_ERROR_NO_MEMORY;
|
||||
case WHD_ACCESS_POINT_NOT_FOUND:
|
||||
case WHD_NETWORK_NOT_FOUND: return NSAPI_ERROR_NO_SSID;
|
||||
case WHD_NETWORK_NOT_FOUND:
|
||||
return NSAPI_ERROR_NO_SSID;
|
||||
case WHD_NOT_AUTHENTICATED:
|
||||
case WHD_INVALID_KEY:
|
||||
case WHD_NOT_KEYED: return NSAPI_ERROR_AUTH_FAILURE;
|
||||
case WHD_NOT_KEYED:
|
||||
return NSAPI_ERROR_AUTH_FAILURE;
|
||||
case WHD_PENDING:
|
||||
case WHD_JOIN_IN_PROGRESS: return NSAPI_ERROR_IN_PROGRESS;
|
||||
case WHD_CONNECTION_LOST: return NSAPI_ERROR_CONNECTION_LOST;
|
||||
case WHD_JOIN_IN_PROGRESS:
|
||||
return NSAPI_ERROR_IN_PROGRESS;
|
||||
case WHD_CONNECTION_LOST:
|
||||
return NSAPI_ERROR_CONNECTION_LOST;
|
||||
case WHD_TIMEOUT:
|
||||
case WHD_EAPOL_KEY_PACKET_M1_TIMEOUT:
|
||||
case WHD_EAPOL_KEY_PACKET_M3_TIMEOUT:
|
||||
case WHD_EAPOL_KEY_PACKET_G1_TIMEOUT: return NSAPI_ERROR_CONNECTION_TIMEOUT;
|
||||
case WHD_WLAN_BUSY: return NSAPI_ERROR_BUSY;
|
||||
case WHD_WLAN_NODEVICE: return NSAPI_ERROR_DEVICE_ERROR;
|
||||
default: return -res;
|
||||
case WHD_EAPOL_KEY_PACKET_G1_TIMEOUT:
|
||||
return NSAPI_ERROR_CONNECTION_TIMEOUT;
|
||||
case WHD_WLAN_BUSY:
|
||||
return NSAPI_ERROR_BUSY;
|
||||
case WHD_WLAN_NODEVICE:
|
||||
return NSAPI_ERROR_DEVICE_ERROR;
|
||||
default:
|
||||
return -res;
|
||||
}
|
||||
}
|
||||
|
||||
static nsapi_security_t whd_tosecurity(whd_security_t sec) {
|
||||
static nsapi_security_t whd_tosecurity(whd_security_t sec)
|
||||
{
|
||||
switch (sec) {
|
||||
case WHD_SECURITY_OPEN: return NSAPI_SECURITY_NONE;
|
||||
case WHD_SECURITY_OPEN:
|
||||
return NSAPI_SECURITY_NONE;
|
||||
case WHD_SECURITY_WEP_PSK:
|
||||
case WHD_SECURITY_WEP_SHARED: return NSAPI_SECURITY_WEP;
|
||||
case WHD_SECURITY_WEP_SHARED:
|
||||
return NSAPI_SECURITY_WEP;
|
||||
case WHD_SECURITY_WPA_TKIP_PSK:
|
||||
case WHD_SECURITY_WPA_TKIP_ENT: return NSAPI_SECURITY_WPA;
|
||||
case WHD_SECURITY_WPA2_MIXED_PSK: return NSAPI_SECURITY_WPA_WPA2;
|
||||
case WHD_SECURITY_WPA_TKIP_ENT:
|
||||
return NSAPI_SECURITY_WPA;
|
||||
case WHD_SECURITY_WPA2_MIXED_PSK:
|
||||
return NSAPI_SECURITY_WPA_WPA2;
|
||||
case WHD_SECURITY_WPA2_AES_PSK:
|
||||
case WHD_SECURITY_WPA2_AES_ENT:
|
||||
case WHD_SECURITY_WPA2_FBT_PSK:
|
||||
case WHD_SECURITY_WPA2_FBT_ENT: return NSAPI_SECURITY_WPA2;
|
||||
case WHD_SECURITY_WPA2_FBT_ENT:
|
||||
return NSAPI_SECURITY_WPA2;
|
||||
default:
|
||||
return NSAPI_SECURITY_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
whd_security_t whd_fromsecurity(nsapi_security_t sec) {
|
||||
whd_security_t whd_fromsecurity(nsapi_security_t sec)
|
||||
{
|
||||
switch (sec) {
|
||||
case NSAPI_SECURITY_NONE: return WHD_SECURITY_OPEN;
|
||||
case NSAPI_SECURITY_WEP: return WHD_SECURITY_WEP_PSK;
|
||||
case NSAPI_SECURITY_WPA: return WHD_SECURITY_WPA_MIXED_PSK;
|
||||
case NSAPI_SECURITY_WPA2: return WHD_SECURITY_WPA2_AES_PSK;
|
||||
case NSAPI_SECURITY_WPA_WPA2: return WHD_SECURITY_WPA2_MIXED_PSK;
|
||||
default: return WHD_SECURITY_UNKNOWN;
|
||||
case NSAPI_SECURITY_NONE:
|
||||
return WHD_SECURITY_OPEN;
|
||||
case NSAPI_SECURITY_WEP:
|
||||
return WHD_SECURITY_WEP_PSK;
|
||||
case NSAPI_SECURITY_WPA:
|
||||
return WHD_SECURITY_WPA_MIXED_PSK;
|
||||
case NSAPI_SECURITY_WPA2:
|
||||
return WHD_SECURITY_WPA2_AES_PSK;
|
||||
case NSAPI_SECURITY_WPA_WPA2:
|
||||
return WHD_SECURITY_WPA2_MIXED_PSK;
|
||||
default:
|
||||
return WHD_SECURITY_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,8 +182,7 @@ nsapi_error_t WhdSTAInterface::set_credentials(const char *ssid, const char *pas
|
|||
(pass == NULL && (security != NSAPI_SECURITY_NONE)) ||
|
||||
(strlen(pass) == 0 && (security != NSAPI_SECURITY_NONE)) ||
|
||||
(strlen(pass) > 63 && (security == NSAPI_SECURITY_WPA2 || security == NSAPI_SECURITY_WPA || security == NSAPI_SECURITY_WPA_WPA2))
|
||||
)
|
||||
{
|
||||
) {
|
||||
return NSAPI_ERROR_PARAMETER;
|
||||
}
|
||||
|
||||
|
@ -177,8 +204,9 @@ nsapi_error_t WhdSTAInterface::connect()
|
|||
int i;
|
||||
|
||||
// initialize wiced, this is noop if already init
|
||||
if (!_whd_emac.powered_up)
|
||||
if (!_whd_emac.powered_up) {
|
||||
_whd_emac.power_up();
|
||||
}
|
||||
|
||||
if (!_interface) {
|
||||
nsapi_error_t err = _stack.add_ethernet_interface(_emac, true, &_interface);
|
||||
|
@ -210,8 +238,7 @@ nsapi_error_t WhdSTAInterface::connect()
|
|||
|
||||
// join the network
|
||||
whd_result_t res;
|
||||
for ( i = 0; i < MAX_RETRY_COUNT; i++ )
|
||||
{
|
||||
for (i = 0; i < MAX_RETRY_COUNT; i++) {
|
||||
res = (whd_result_t)whd_wifi_join(_whd_emac.ifp,
|
||||
&ssid,
|
||||
security,
|
||||
|
@ -225,8 +252,7 @@ nsapi_error_t WhdSTAInterface::connect()
|
|||
return whd_toerror(res);
|
||||
}
|
||||
|
||||
if(whd_wifi_is_ready_to_transceive(_whd_emac.ifp) == WHD_SUCCESS)
|
||||
{
|
||||
if (whd_wifi_is_ready_to_transceive(_whd_emac.ifp) == WHD_SUCCESS) {
|
||||
whd_emac_wifi_link_state_changed(true, _whd_emac.ifp);
|
||||
}
|
||||
|
||||
|
@ -240,9 +266,10 @@ nsapi_error_t WhdSTAInterface::connect()
|
|||
|
||||
void WhdSTAInterface::wifi_on()
|
||||
{
|
||||
if (!_whd_emac.powered_up)
|
||||
if (!_whd_emac.powered_up) {
|
||||
_whd_emac.power_up();
|
||||
}
|
||||
}
|
||||
|
||||
nsapi_error_t WhdSTAInterface::disconnect()
|
||||
{
|
||||
|
@ -276,8 +303,9 @@ int8_t WhdSTAInterface::get_rssi()
|
|||
whd_result_t res;
|
||||
|
||||
// initialize wiced, this is noop if already init
|
||||
if (!_whd_emac.powered_up)
|
||||
if (!_whd_emac.powered_up) {
|
||||
_whd_emac.power_up();
|
||||
}
|
||||
|
||||
res = (whd_result_t)whd_wifi_get_rssi(_whd_emac.ifp, &rssi);
|
||||
if (res != 0) {
|
||||
|
@ -315,9 +343,10 @@ static void whd_scan_handler(whd_scan_result_t** result_ptr,
|
|||
whd_scan_result_t *record = *result_ptr;
|
||||
|
||||
for (unsigned int i = 0; i < data->result_buff->size(); i++) {
|
||||
if (CMP_MAC( (*data->result_buff)[i].BSSID.octet, record->BSSID.octet ))
|
||||
if (CMP_MAC((*data->result_buff)[i].BSSID.octet, record->BSSID.octet)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (data->count > 0) {
|
||||
// get ap stats
|
||||
|
@ -348,8 +377,9 @@ static void whd_scan_handler(whd_scan_result_t** result_ptr,
|
|||
int WhdSTAInterface::scan(WiFiAccessPoint *aps, unsigned count)
|
||||
{
|
||||
// initialize wiced, this is noop if already init
|
||||
if (!_whd_emac.powered_up)
|
||||
if (!_whd_emac.powered_up) {
|
||||
_whd_emac.power_up();
|
||||
}
|
||||
|
||||
interal_scan_data.sema = new Semaphore();
|
||||
interal_scan_data.aps = aps;
|
||||
|
@ -357,7 +387,7 @@ int WhdSTAInterface::scan(WiFiAccessPoint *aps, unsigned count)
|
|||
interal_scan_data.offset = 0;
|
||||
interal_scan_data.ifp = _whd_emac.ifp;
|
||||
interal_scan_data.scan_in_progress = true;
|
||||
interal_scan_data.result_buff = new vector<whd_scan_result_t>();
|
||||
interal_scan_data.result_buff = new std::vector<whd_scan_result_t>();
|
||||
whd_result_t whd_res;
|
||||
int res;
|
||||
|
||||
|
@ -383,12 +413,9 @@ int WhdSTAInterface::scan(WiFiAccessPoint *aps, unsigned count)
|
|||
int WhdSTAInterface::is_interface_connected(void)
|
||||
{
|
||||
_whd_emac.ifp->role = WHD_STA_ROLE;
|
||||
if ( ( whd_wifi_is_ready_to_transceive( _whd_emac.ifp ) == WHD_SUCCESS ) )
|
||||
{
|
||||
if ((whd_wifi_is_ready_to_transceive(_whd_emac.ifp) == WHD_SUCCESS)) {
|
||||
return WHD_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return WHD_CONNECTION_LOST;
|
||||
}
|
||||
}
|
||||
|
@ -400,12 +427,10 @@ int WhdSTAInterface::get_bssid(uint8_t *bssid)
|
|||
|
||||
memset(&ap_mac, 0, sizeof(ap_mac));
|
||||
_whd_emac.ifp->role = WHD_STA_ROLE;
|
||||
if ( ( whd_wifi_is_ready_to_transceive( _whd_emac.ifp ) == WHD_SUCCESS ) )
|
||||
{
|
||||
if ((whd_wifi_is_ready_to_transceive(_whd_emac.ifp) == WHD_SUCCESS)) {
|
||||
res = whd_wifi_get_bssid(_whd_emac.ifp, &ap_mac);
|
||||
|
||||
if ( res == WHD_SUCCESS )
|
||||
{
|
||||
if (res == WHD_SUCCESS) {
|
||||
memcpy(bssid, ap_mac.octet, sizeof(ap_mac.octet));
|
||||
}
|
||||
}
|
||||
|
@ -420,8 +445,7 @@ int WhdSTAInterface::whd_log_print ( void )
|
|||
int WhdSTAInterface::whd_log_read(char *buffer, int buffer_size)
|
||||
{
|
||||
whd_result_t res = WHD_SUCCESS;
|
||||
if ( buffer != NULL )
|
||||
{
|
||||
if (buffer != NULL) {
|
||||
res = whd_wifi_read_wlan_log(_whd_emac.drvp, buffer, buffer_size);
|
||||
}
|
||||
return res;
|
||||
|
@ -433,8 +457,7 @@ nsapi_error_t WhdSTAInterface::wifi_get_ac_params_sta(void *acp )
|
|||
edcf_acparam_t *ac_param = (edcf_acparam_t *)acp;
|
||||
|
||||
res = whd_wifi_get_acparams(_whd_emac.ifp, ac_param);
|
||||
if ( res != WHD_SUCCESS )
|
||||
{
|
||||
if (res != WHD_SUCCESS) {
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* WHD implementation of NetworkInterfaceAPI
|
||||
* Copyright (c) 2017 ARM Limited
|
||||
* Copyright (c) 2017-2019 ARM Limited
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,8 +18,8 @@
|
|||
#ifndef WHD_STA_INTERFACE_H
|
||||
#define WHD_STA_INTERFACE_H
|
||||
|
||||
#include "mbed.h"
|
||||
#include "EthernetInterface.h"
|
||||
#include "netsocket/WiFiInterface.h"
|
||||
#include "netsocket/EMACInterface.h"
|
||||
#include "netsocket/OnboardNetworkStack.h"
|
||||
#include "whd_emac.h"
|
||||
#include "whd_types_int.h"
|
||||
|
@ -28,21 +29,28 @@ struct ol_desc;
|
|||
/** WhdSTAInterface class
|
||||
* Implementation of the NetworkStack for the WHD
|
||||
*/
|
||||
class WhdSTAInterface : public WiFiInterface, public EMACInterface
|
||||
{
|
||||
class WhdSTAInterface : public WiFiInterface, public EMACInterface {
|
||||
public:
|
||||
|
||||
class OlmInterface
|
||||
{
|
||||
class OlmInterface {
|
||||
public:
|
||||
/** Get the default OLM interface. */
|
||||
static OlmInterface &get_default_instance();
|
||||
|
||||
OlmInterface(struct ol_desc *list = NULL) {}
|
||||
|
||||
virtual int init_ols(void *whd, void *ip) { return 0; }
|
||||
virtual int sleep() { return 0; }
|
||||
virtual int wake() { return 0; }
|
||||
virtual int init_ols(void *whd, void *ip)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual int sleep()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
virtual int wake()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void deinit_ols(void) {}
|
||||
};
|
||||
|
@ -100,7 +108,8 @@ public:
|
|||
* @param channel Channel on which the connection is to be made, or 0 for any (Default: 0)
|
||||
* @return Not supported, returns NSAPI_ERROR_UNSUPPORTED
|
||||
*/
|
||||
nsapi_error_t set_channel(uint8_t channel) {
|
||||
nsapi_error_t set_channel(uint8_t channel)
|
||||
{
|
||||
if (channel != 0) {
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
@ -165,9 +174,9 @@ public:
|
|||
* @return true if completed successfully
|
||||
* false if Interface is connected
|
||||
*/
|
||||
int set_olm(OlmInterface *olm) {
|
||||
if (get_connection_status() == NSAPI_STATUS_DISCONNECTED)
|
||||
int set_olm(OlmInterface *olm)
|
||||
{
|
||||
if (get_connection_status() == NSAPI_STATUS_DISCONNECTED) {
|
||||
_olm = olm;
|
||||
return true;
|
||||
}
|
||||
|
@ -178,7 +187,8 @@ public:
|
|||
*
|
||||
* @return 0 if successful
|
||||
*/
|
||||
int net_suspended() {
|
||||
int net_suspended()
|
||||
{
|
||||
int ret = _olm->sleep();
|
||||
return ret;
|
||||
}
|
||||
|
@ -187,7 +197,8 @@ public:
|
|||
*
|
||||
* @return 0 if successful
|
||||
*/
|
||||
int net_resuming() {
|
||||
int net_resuming()
|
||||
{
|
||||
int ret = _olm->wake();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* Wiced implementation of NetworkInterfaceAPI
|
||||
* Copyright (c) 2017 ARM Limited
|
||||
* Copyright (c) 2017-2019 ARM Limited
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* WHD SoftAP implementation of SoftAPInterface
|
||||
* Copyright (c) 2017 ARM Limited
|
||||
* Copyright (c) 2017-2019 ARM Limited
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,8 +18,7 @@
|
|||
#ifndef WHD_SOFTAP_INTERFACE_H
|
||||
#define WHD_SOFTAP_INTERFACE_H
|
||||
|
||||
#include "mbed.h"
|
||||
#include "EthernetInterface.h"
|
||||
#include "netsocket/EMACInterface.h"
|
||||
#include "netsocket/OnboardNetworkStack.h"
|
||||
#include "whd_emac.h"
|
||||
|
||||
|
@ -26,8 +26,7 @@
|
|||
/**
|
||||
* Vendor IE details
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint8_t oui[WIFI_IE_OUI_LENGTH]; /**< Unique identifier for the IE */
|
||||
uint8_t subtype; /**< Sub-type of the IE */
|
||||
void *data; /**< Pointer to IE data */
|
||||
|
@ -40,8 +39,7 @@ typedef struct
|
|||
/** WhdSoftAPInterface class
|
||||
* Implementation of the SoftAPInterface for the Whd
|
||||
*/
|
||||
class WhdSoftAPInterface : public EMACInterface
|
||||
{
|
||||
class WhdSoftAPInterface : public EMACInterface {
|
||||
public:
|
||||
/** Construct SoftAP interface
|
||||
* @return pointer to default WhdSoftAPInterface instance
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Arm Limited and affiliates.
|
||||
* Copyright (c) 2018-2019, Arm Limited and affiliates.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018 ARM Limited
|
||||
* Copyright (c) 2018-2019 ARM Limited
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -45,11 +46,13 @@ WHD_EMAC::WHD_EMAC()
|
|||
{
|
||||
}
|
||||
|
||||
WHD_EMAC &WHD_EMAC::get_instance() {
|
||||
WHD_EMAC &WHD_EMAC::get_instance()
|
||||
{
|
||||
return get_instance(WHD_STA_ROLE);
|
||||
}
|
||||
|
||||
WHD_EMAC &WHD_EMAC::get_instance(whd_interface_role_t role) {
|
||||
WHD_EMAC &WHD_EMAC::get_instance(whd_interface_role_t role)
|
||||
{
|
||||
static WHD_EMAC emac_sta(WHD_STA_ROLE);
|
||||
static WHD_EMAC emac_ap(WHD_AP_ROLE);
|
||||
return role == WHD_AP_ROLE ? emac_ap : emac_sta;
|
||||
|
@ -83,8 +86,7 @@ void WHD_EMAC::set_all_multicast(bool all)
|
|||
|
||||
void WHD_EMAC::power_down()
|
||||
{
|
||||
if(powered_up)
|
||||
{
|
||||
if (powered_up) {
|
||||
powered_up = false;
|
||||
whd_wifi_off(ifp);
|
||||
whd_deinit(ifp);
|
||||
|
@ -93,8 +95,7 @@ void WHD_EMAC::power_down()
|
|||
|
||||
bool WHD_EMAC::power_up()
|
||||
{
|
||||
if(!powered_up)
|
||||
{
|
||||
if (!powered_up) {
|
||||
if (CY_RSLT_SUCCESS != cybsp_wifi_init()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -153,8 +154,7 @@ bool WHD_EMAC::link_out(emac_mem_buf_t *buf)
|
|||
uint16_t size = memory_manager->get_total_len(buf);
|
||||
|
||||
whd_result_t res = whd_host_buffer_get(drvp, &buffer, WHD_NETWORK_TX, size + offset, WHD_TRUE);
|
||||
if ( res != WHD_SUCCESS)
|
||||
{
|
||||
if (res != WHD_SUCCESS) {
|
||||
memory_manager->free(buf);
|
||||
return true;
|
||||
}
|
||||
|
@ -188,15 +188,11 @@ extern "C"
|
|||
|
||||
static void emac_receive_eapol_packet(whd_interface_t interface, whd_buffer_t buffer)
|
||||
{
|
||||
if ( buffer != NULL )
|
||||
{
|
||||
if ( emac_eapol_packet_handler != NULL )
|
||||
{
|
||||
if (buffer != NULL) {
|
||||
if (emac_eapol_packet_handler != NULL) {
|
||||
|
||||
emac_eapol_packet_handler(interface, buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
whd_buffer_release(interface->whd_driver, buffer, WHD_NETWORK_RX);
|
||||
}
|
||||
}
|
||||
|
@ -205,8 +201,7 @@ static void emac_receive_eapol_packet(whd_interface_t interface, whd_buffer_t bu
|
|||
whd_result_t emac_register_eapol_packet_handler(eapol_packet_handler_t eapol_packet_handler)
|
||||
{
|
||||
|
||||
if ( emac_eapol_packet_handler == NULL )
|
||||
{
|
||||
if (emac_eapol_packet_handler == NULL) {
|
||||
emac_eapol_packet_handler = eapol_packet_handler;
|
||||
return WHD_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018 ARM Limited
|
||||
* Copyright (c) 2018-2019 ARM Limited
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2017 ARM Limited
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -48,16 +49,14 @@ extern "C"
|
|||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
WICED_SOCKET_ERROR
|
||||
} wiced_socket_state_t;
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint8_t *payload;
|
||||
uint16_t len;
|
||||
uint16_t pktstart;
|
||||
|
@ -81,11 +80,9 @@ typedef struct wiced_udp_socket_struct wiced_udp_socket_t;
|
|||
typedef wiced_result_t (*wiced_tcp_socket_callback_t)(wiced_tcp_socket_t *socket, void *arg);
|
||||
typedef wiced_result_t (*wiced_udp_socket_callback_t)(wiced_udp_socket_t *socket, void *arg);
|
||||
|
||||
struct wiced_udp_socket_struct
|
||||
{
|
||||
struct wiced_udp_socket_struct {
|
||||
wiced_dtls_context_t *dtls_context;
|
||||
struct
|
||||
{
|
||||
struct {
|
||||
wiced_tcp_socket_callback_t disconnect;
|
||||
wiced_tcp_socket_callback_t receive;
|
||||
wiced_tcp_socket_callback_t connect;
|
||||
|
@ -93,13 +90,11 @@ struct wiced_udp_socket_struct
|
|||
void *callback_arg;
|
||||
};
|
||||
|
||||
struct wiced_tcp_socket_struct
|
||||
{
|
||||
struct wiced_tcp_socket_struct {
|
||||
NOOS_TCP_SOCKET socket;
|
||||
wiced_tls_context_t *tls_context;
|
||||
wiced_bool_t context_malloced;
|
||||
struct
|
||||
{
|
||||
struct {
|
||||
wiced_tcp_socket_callback_t disconnect;
|
||||
wiced_tcp_socket_callback_t receive;
|
||||
wiced_tcp_socket_callback_t connect;
|
||||
|
@ -107,8 +102,7 @@ struct wiced_tcp_socket_struct
|
|||
void *callback_arg;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
wiced_tcp_socket_t socket[WICED_MAXIMUM_NUMBER_OF_SERVER_SOCKETS];
|
||||
int interface;
|
||||
uint16_t port;
|
||||
|
@ -118,12 +112,10 @@ typedef struct
|
|||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
int dummy;
|
||||
} NOOS_IP;
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
int dummy;
|
||||
} NOOS_PACKET_POOL;
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue