Skip to content

Commit 85a5bc0

Browse files
committed
PSOC6: apply astyle to WHD EMAC driver implementation
1 parent 1501ffe commit 85a5bc0

File tree

9 files changed

+323
-302
lines changed

9 files changed

+323
-302
lines changed

features/netsocket/emac-drivers/TARGET_WHD/interface/WhdSTAInterface.cpp

Lines changed: 160 additions & 137 deletions
Large diffs are not rendered by default.

features/netsocket/emac-drivers/TARGET_WHD/interface/WhdSTAInterface.h

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* WHD implementation of NetworkInterfaceAPI
2-
* Copyright (c) 2017 ARM Limited
2+
* Copyright (c) 2017-2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -17,8 +18,8 @@
1718
#ifndef WHD_STA_INTERFACE_H
1819
#define WHD_STA_INTERFACE_H
1920

20-
#include "mbed.h"
21-
#include "EthernetInterface.h"
21+
#include "netsocket/WiFiInterface.h"
22+
#include "netsocket/EMACInterface.h"
2223
#include "netsocket/OnboardNetworkStack.h"
2324
#include "whd_emac.h"
2425
#include "whd_types_int.h"
@@ -28,29 +29,36 @@ struct ol_desc;
2829
/** WhdSTAInterface class
2930
* Implementation of the NetworkStack for the WHD
3031
*/
31-
class WhdSTAInterface : public WiFiInterface, public EMACInterface
32-
{
32+
class WhdSTAInterface : public WiFiInterface, public EMACInterface {
3333
public:
3434

35-
class OlmInterface
36-
{
35+
class OlmInterface {
3736
public:
3837
/** Get the default OLM interface. */
3938
static OlmInterface &get_default_instance();
4039

4140
OlmInterface(struct ol_desc *list = NULL) {}
4241

43-
virtual int init_ols(void *whd, void *ip) { return 0; }
44-
virtual int sleep() { return 0; }
45-
virtual int wake() { return 0; }
42+
virtual int init_ols(void *whd, void *ip)
43+
{
44+
return 0;
45+
}
46+
virtual int sleep()
47+
{
48+
return 0;
49+
}
50+
virtual int wake()
51+
{
52+
return 0;
53+
}
4654

4755
virtual void deinit_ols(void) {}
4856
};
4957

5058
WhdSTAInterface(
51-
WHD_EMAC &emac = WHD_EMAC::get_instance(),
52-
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance(),
53-
OlmInterface &olm = OlmInterface::get_default_instance());
59+
WHD_EMAC &emac = WHD_EMAC::get_instance(),
60+
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance(),
61+
OlmInterface &olm = OlmInterface::get_default_instance());
5462

5563
static WhdSTAInterface *get_default_instance();
5664

@@ -100,7 +108,8 @@ class WhdSTAInterface : public WiFiInterface, public EMACInterface
100108
* @param channel Channel on which the connection is to be made, or 0 for any (Default: 0)
101109
* @return Not supported, returns NSAPI_ERROR_UNSUPPORTED
102110
*/
103-
nsapi_error_t set_channel(uint8_t channel) {
111+
nsapi_error_t set_channel(uint8_t channel)
112+
{
104113
if (channel != 0) {
105114
return NSAPI_ERROR_UNSUPPORTED;
106115
}
@@ -135,28 +144,28 @@ class WhdSTAInterface : public WiFiInterface, public EMACInterface
135144
/* print WHD log (this routine will malloc/free a buffer
136145
* You need to enable printing with WHD_LOGGING_BUFFER_ENABLE
137146
*/
138-
int whd_log_print ( void );
147+
int whd_log_print(void);
139148

140149
/* read WHD log */
141-
int whd_log_read ( char *buffer, int buffer_size );
150+
int whd_log_read(char *buffer, int buffer_size);
142151

143152
/* Get EDCF AC params */
144-
nsapi_error_t wifi_get_ac_params_sta(void * ac_param );
153+
nsapi_error_t wifi_get_ac_params_sta(void *ac_param);
145154

146155
/* get iovar value */
147-
int wifi_get_iovar_value ( const char *iovar, uint32_t *value );
156+
int wifi_get_iovar_value(const char *iovar, uint32_t *value);
148157

149158
/* set iovar value */
150-
int wifi_set_iovar_value ( const char *iovar, uint32_t value );
159+
int wifi_set_iovar_value(const char *iovar, uint32_t value);
151160

152161
/* set ioctl value */
153-
int wifi_set_ioctl_value( uint32_t ioctl, uint32_t value ) ;
162+
int wifi_set_ioctl_value(uint32_t ioctl, uint32_t value) ;
154163

155164
/* set wifi interface up */
156-
int wifi_set_up (void );
165+
int wifi_set_up(void);
157166

158167
/* set wifi interface down */
159-
int wifi_set_down (void );
168+
int wifi_set_down(void);
160169

161170
/** Set Offload Manager Information
162171
* NOTE: Only allowed while disconnected
@@ -165,9 +174,9 @@ class WhdSTAInterface : public WiFiInterface, public EMACInterface
165174
* @return true if completed successfully
166175
* false if Interface is connected
167176
*/
168-
int set_olm(OlmInterface *olm) {
169-
if (get_connection_status() == NSAPI_STATUS_DISCONNECTED)
170-
{
177+
int set_olm(OlmInterface *olm)
178+
{
179+
if (get_connection_status() == NSAPI_STATUS_DISCONNECTED) {
171180
_olm = olm;
172181
return true;
173182
}
@@ -178,7 +187,8 @@ class WhdSTAInterface : public WiFiInterface, public EMACInterface
178187
*
179188
* @return 0 if successful
180189
*/
181-
int net_suspended() {
190+
int net_suspended()
191+
{
182192
int ret = _olm->sleep();
183193
return ret;
184194
}
@@ -187,7 +197,8 @@ class WhdSTAInterface : public WiFiInterface, public EMACInterface
187197
*
188198
* @return 0 if successful
189199
*/
190-
int net_resuming() {
200+
int net_resuming()
201+
{
191202
int ret = _olm->wake();
192203
return ret;
193204
}
@@ -196,9 +207,9 @@ class WhdSTAInterface : public WiFiInterface, public EMACInterface
196207
char _ssid[33]; /* The longest possible name (defined in 802.11) +1 for the \0 */
197208
char _pass[64]; /* The longest allowed passphrase + 1 */
198209
nsapi_security_t _security;
199-
WHD_EMAC& _whd_emac;
210+
WHD_EMAC &_whd_emac;
200211
OlmInterface *_olm;
201212
};
202213

203-
extern int wiced_leave_ap ( int interface );
214+
extern int wiced_leave_ap(int interface);
204215
#endif

features/netsocket/emac-drivers/TARGET_WHD/interface/WhdSoftAPInterface.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* Wiced implementation of NetworkInterfaceAPI
2-
* Copyright (c) 2017 ARM Limited
2+
* Copyright (c) 2017-2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -36,14 +37,14 @@ static uint16_t ap_event_entry = 2;
3637

3738
WhdSoftAPInterface::WhdSoftAPInterface(WHD_EMAC &emac, OnboardNetworkStack &stack)
3839
: EMACInterface(emac, stack),
39-
_whd_emac(emac)
40+
_whd_emac(emac)
4041
{
4142

4243
}
4344

4445

4546
int WhdSoftAPInterface::start(const char *ssid, const char *pass, nsapi_security_t security, uint8_t channel,
46-
bool start_dhcp_server, const whd_custom_ie_info_t* ie_info)
47+
bool start_dhcp_server, const whd_custom_ie_info_t *ie_info)
4748
{
4849
nsapi_error_t err;
4950

@@ -59,24 +60,24 @@ int WhdSoftAPInterface::start(const char *ssid, const char *pass, nsapi_security
5960

6061
// setup ssid
6162
whd_ssid_t whd_ssid;
62-
strncpy((char*)whd_ssid.value, ssid, SSID_NAME_SIZE);
63-
whd_ssid.value[SSID_NAME_SIZE-1] = '\0';
64-
whd_ssid.length = strlen((char*)whd_ssid.value);
63+
strncpy((char *)whd_ssid.value, ssid, SSID_NAME_SIZE);
64+
whd_ssid.value[SSID_NAME_SIZE - 1] = '\0';
65+
whd_ssid.length = strlen((char *)whd_ssid.value);
6566

6667
// choose network security
6768
whd_security_t whd_security = whd_fromsecurity(security);
6869

6970
/* set up the AP info */
70-
err = whd_wifi_init_ap(_whd_emac.ifp, &whd_ssid, whd_security, (const uint8_t*)pass,
71-
strlen(pass), channel);
71+
err = whd_wifi_init_ap(_whd_emac.ifp, &whd_ssid, whd_security, (const uint8_t *)pass,
72+
strlen(pass), channel);
7273
if (err != NSAPI_ERROR_OK) {
7374
printf("whd_wifi_init_ap() ERROR: %d\n", err);
7475
return err;
7576
}
7677

7778
if (ie_info) {
7879
err = whd_wifi_manage_custom_ie(_whd_emac.ifp, WHD_ADD_CUSTOM_IE, (const uint8_t *)ie_info->oui,
79-
ie_info->subtype, (const void *)ie_info->data, ie_info->length, ie_info->which_packets);
80+
ie_info->subtype, (const void *)ie_info->data, ie_info->length, ie_info->which_packets);
8081
if (err != NSAPI_ERROR_OK) {
8182
printf("whd_wifi_manage_custom_ie() ERROR: %d\n", err);
8283
return err;
@@ -88,20 +89,20 @@ int WhdSoftAPInterface::start(const char *ssid, const char *pass, nsapi_security
8889
printf("whd_wifi_start_ap() ERROR: %d\n", err);
8990
return err;
9091
}
91-
92+
9293
// Set static IP address for SoftAP and bring up
9394
set_dhcp(false);
9495

95-
if(whd_wifi_is_ready_to_transceive(_whd_emac.ifp) == WHD_SUCCESS) {
96+
if (whd_wifi_is_ready_to_transceive(_whd_emac.ifp) == WHD_SUCCESS) {
9697
whd_emac_wifi_link_state_changed(true, _whd_emac.ifp);
9798
}
9899

99100
// bring up
100101
err = _interface->bringup(_dhcp,
101-
_ip_address[0] ? _ip_address : 0,
102-
_netmask[0] ? _netmask : 0,
103-
_gateway[0] ? _gateway : 0,
104-
DEFAULT_STACK);
102+
_ip_address[0] ? _ip_address : 0,
103+
_netmask[0] ? _netmask : 0,
104+
_gateway[0] ? _gateway : 0,
105+
DEFAULT_STACK);
105106
if (err != NSAPI_ERROR_OK) {
106107
printf("bringup() ERROR: %d\n", err);
107108
}
@@ -115,15 +116,15 @@ int WhdSoftAPInterface::stop(void)
115116
return whd_wifi_stop_ap(_whd_emac.ifp);
116117
}
117118

118-
int WhdSoftAPInterface::remove_custom_ie(const whd_custom_ie_info_t* ie_info)
119+
int WhdSoftAPInterface::remove_custom_ie(const whd_custom_ie_info_t *ie_info)
119120
{
120121
return whd_wifi_manage_custom_ie(_whd_emac.ifp, WHD_REMOVE_CUSTOM_IE, (const uint8_t *)ie_info->oui,
121-
ie_info->subtype, (const void *)ie_info->data, ie_info->length, ie_info->which_packets);
122+
ie_info->subtype, (const void *)ie_info->data, ie_info->length, ie_info->which_packets);
122123
}
123124

124-
int WhdSoftAPInterface::get_associated_client_list(void* client_list_buffer, uint16_t buffer_length)
125+
int WhdSoftAPInterface::get_associated_client_list(void *client_list_buffer, uint16_t buffer_length)
125126
{
126-
127+
127128
return whd_wifi_get_associated_client_list(_whd_emac.ifp, client_list_buffer, buffer_length);
128129
}
129130

features/netsocket/emac-drivers/TARGET_WHD/interface/WhdSoftAPInterface.h

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* WHD SoftAP implementation of SoftAPInterface
2-
* Copyright (c) 2017 ARM Limited
2+
* Copyright (c) 2017-2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
34
*
45
* Licensed under the Apache License, Version 2.0 (the "License");
56
* you may not use this file except in compliance with the License.
@@ -17,20 +18,18 @@
1718
#ifndef WHD_SOFTAP_INTERFACE_H
1819
#define WHD_SOFTAP_INTERFACE_H
1920

20-
#include "mbed.h"
21-
#include "EthernetInterface.h"
21+
#include "netsocket/EMACInterface.h"
2222
#include "netsocket/OnboardNetworkStack.h"
2323
#include "whd_emac.h"
2424

2525

2626
/**
2727
* Vendor IE details
2828
*/
29-
typedef struct
30-
{
29+
typedef struct {
3130
uint8_t oui[WIFI_IE_OUI_LENGTH]; /**< Unique identifier for the IE */
3231
uint8_t subtype; /**< Sub-type of the IE */
33-
void* data; /**< Pointer to IE data */
32+
void *data; /**< Pointer to IE data */
3433
uint16_t length; /**< IE data length */
3534
uint16_t which_packets; /**< Mask of the packet in which this IE details to be included */
3635
} whd_custom_ie_info_t;
@@ -40,14 +39,13 @@ typedef struct
4039
/** WhdSoftAPInterface class
4140
* Implementation of the SoftAPInterface for the Whd
4241
*/
43-
class WhdSoftAPInterface : public EMACInterface
44-
{
42+
class WhdSoftAPInterface : public EMACInterface {
4543
public:
46-
/** Construct SoftAP interface
44+
/** Construct SoftAP interface
4745
* @return pointer to default WhdSoftAPInterface instance
4846
*/
4947
WhdSoftAPInterface(WHD_EMAC &emac = WHD_EMAC::get_instance(WHD_AP_ROLE),
50-
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance());
48+
OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance());
5149

5250
/** Get the default WhdSoftAPInterface instance.
5351
* @return pointer to default WhdSoftAPInterface instance
@@ -79,7 +77,7 @@ class WhdSoftAPInterface : public EMACInterface
7977
* see @a nsapi_error
8078
*/
8179
int start(const char *ssid, const char *pass, nsapi_security_t security, uint8_t channel,
82-
bool start_dhcp_server = true, const whd_custom_ie_info_t* ie_info = NULL);
80+
bool start_dhcp_server = true, const whd_custom_ie_info_t *ie_info = NULL);
8381

8482
/**
8583
* Remove Wi-Fi custom IE
@@ -89,15 +87,15 @@ class WhdSoftAPInterface : public EMACInterface
8987
* @return 0 on success, or error code on failure
9088
* see @a nsapi_error
9189
*/
92-
int remove_custom_ie(const whd_custom_ie_info_t* ie_info);
90+
int remove_custom_ie(const whd_custom_ie_info_t *ie_info);
9391

9492
/** Stop the Software Access Point
9593
*
9694
* @return 0 on success, or error code on failure
9795
* see @a nsapi_error
9896
*/
9997
int stop(void);
100-
98+
10199
/**
102100
* Gets information about associated clients.
103101
*
@@ -109,7 +107,7 @@ class WhdSoftAPInterface : public EMACInterface
109107
* @return 0 on success, or error code on failure
110108
* see @a nsapi_error
111109
*/
112-
int get_associated_client_list(void* client_list_buffer, uint16_t buffer_length);
110+
int get_associated_client_list(void *client_list_buffer, uint16_t buffer_length);
113111

114112

115113
/**
@@ -132,7 +130,7 @@ class WhdSoftAPInterface : public EMACInterface
132130

133131

134132
protected:
135-
WHD_EMAC& _whd_emac;
133+
WHD_EMAC &_whd_emac;
136134
};
137135

138136
#endif

features/netsocket/emac-drivers/TARGET_WHD/interface/default_wifi_interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, Arm Limited and affiliates.
2+
* Copyright (c) 2018-2019, Arm Limited and affiliates.
33
* SPDX-License-Identifier: Apache-2.0
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");

features/netsocket/emac-drivers/TARGET_WHD/interface/emac_eapol.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* You may obtain a copy of the License at
88
*
99
* http://www.apache.org/licenses/LICENSE-2.0
10-
*
10+
*
1111
* Unless required by applicable law or agreed to in writing, software
1212
* distributed under the License is distributed on an "AS IS" BASIS,
1313
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -43,7 +43,7 @@ extern "C"
4343

4444
typedef whd_buffer_t whd_eapol_packet_t;
4545

46-
typedef void (*eapol_packet_handler_t) (whd_interface_t interface, whd_buffer_t buffer);
46+
typedef void (*eapol_packet_handler_t)(whd_interface_t interface, whd_buffer_t buffer);
4747

4848
/******************************************************
4949
* Structures
@@ -56,8 +56,8 @@ typedef void (*eapol_packet_handler_t) (whd_interface_t interface, whd_buffer_t
5656
/******************************************************
5757
* Function Declarations
5858
******************************************************/
59-
whd_result_t emac_register_eapol_packet_handler ( eapol_packet_handler_t eapol_packet_handler );
60-
void emac_unregister_eapol_packet_handler( void );
59+
whd_result_t emac_register_eapol_packet_handler(eapol_packet_handler_t eapol_packet_handler);
60+
void emac_unregister_eapol_packet_handler(void);
6161

6262
#ifdef __cplusplus
6363
} /* extern "C" */

0 commit comments

Comments
 (0)