Skip to content

Commit 05776d6

Browse files
Update COMPONENT_SCL.
1 parent 6b6db89 commit 05776d6

File tree

13 files changed

+294
-499
lines changed

13 files changed

+294
-499
lines changed

features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_SCL/interface/SclSTAInterface.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,10 @@
4343
#include "scl_ipc.h"
4444
#include "mbed_wait_api.h"
4545

46-
#define PARAM_LEN (20)
4746

48-
struct network_params_t {
49-
char ip_address[PARAM_LEN];
50-
char netmask[PARAM_LEN];
51-
char gateway[PARAM_LEN];
52-
int connection_status;
53-
};
47+
/** @file
48+
* Provides SCL interface functions to be used with WiFiInterface or NetworkInterface Objects
49+
*/
5450

5551
struct scl_tx_nw_credentials {
5652
nsapi_security_t network_security_type;
@@ -59,7 +55,8 @@ struct scl_tx_nw_credentials {
5955
const char* network_ssid;
6056
const char* network_passphrase;
6157
} scl_tx_nw_credentials_t;
62-
struct network_params_t network_parameter;
58+
59+
network_params_t network_parameter;
6360

6461
int scl_toerror(scl_result_t res)
6562
{
@@ -217,7 +214,7 @@ nsapi_error_t SclSTAInterface::connect()
217214
//Get the network parameter from NP
218215
while ((network_parameter.connection_status != NSAPI_STATUS_GLOBAL_UP) && delay_timeout < NW_CONNECT_TIMEOUT) {
219216
ret_val = scl_get_nw_parameters(&network_parameter);
220-
wait_us(NW_DELAY_TIME);
217+
wait_us(NW_DELAY_TIME_US);
221218
delay_timeout++;
222219
}
223220

features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_SCL/interface/SclSTAInterface.h

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
#include "scl_emac.h"
4545
#include "scl_wifi_api.h"
4646
#include "scl_types.h"
47-
#define MAX_SSID_LENGTH (33)
48-
#define MAX_PASSWORD_LENGTH (64)
47+
#define MAX_SSID_LENGTH (33) /**< Maximum ssid length */
48+
#define MAX_PASSWORD_LENGTH (64) /**< Maximum password length */
4949

5050
/** SclSTAInterface class
51-
* Implementation of the NetworkStack for the SCL
51+
* Implementation of the Network Stack for the SCL
5252
*/
5353
class SclSTAInterface : public WiFiInterface, public EMACInterface {
5454
public:
@@ -63,16 +63,15 @@ class SclSTAInterface : public WiFiInterface, public EMACInterface {
6363
*/
6464
static SclSTAInterface *get_default_instance();
6565

66-
/** Turn ON the WiFi device
66+
/** Turns on the Wi-Fi device
6767
*
6868
* @return void
6969
*/
70-
/* Turns ON the WiFi device*/
7170
void wifi_on();
7271

7372
/** Starts the interface
7473
*
75-
* Attempts to connect to a WiFi network. Requires ssid and passphrase to be set.
74+
* Attempts to connect to a Wi-Fi network. Requires ssid and passphrase to be set.
7675
* If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned.
7776
*
7877
* @return 0 on success, negative error code on failure.
@@ -81,34 +80,35 @@ class SclSTAInterface : public WiFiInterface, public EMACInterface {
8180

8281
/** Starts the interface
8382
*
84-
* Attempts to connect to a WiFi network.
83+
* Attempts to connect to a Wi-Fi network.
8584
*
8685
* @param ssid Name of the network to connect to.
8786
* @param pass Security passphrase to connect to the network.
8887
* @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE).
8988
* @param channel This parameter is not supported, setting it to a value other than 0 will result in NSAPI_ERROR_UNSUPPORTED.
90-
* @return 0 on success, or error code on failure.
89+
* @return 0 on success, negative error code on failure.
9190
*/
9291
nsapi_error_t connect(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE, uint8_t channel = 0);
9392

94-
/** Stops the interface
95-
* @return 0 on success, negative on failure.
93+
/** Disconnects the interface
94+
*
95+
* @return 0 on success, negative error code on failure.
9696
*/
9797
nsapi_error_t disconnect();
9898

99-
/** Set the WiFi network credentials
99+
/** Set the Wi-Fi network credentials
100100
*
101101
* @param ssid Name of the network to connect to.
102102
* @param pass Security passphrase to connect to the network.
103103
* @param security Type of encryption for connection.
104104
* (defaults to NSAPI_SECURITY_NONE)
105-
* @return 0 on success, or error code on failure.
105+
* @return 0 on success, negative error code on failure.
106106
*/
107107
nsapi_error_t set_credentials(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE);
108108

109-
/** Sets the WiFi network channel - NOT SUPPORTED
109+
/** Sets the Wi-Fi network channel - NOT SUPPORTED
110110
*
111-
* This function is not supported and will return NSAPI_ERROR_UNSUPPORTED.
111+
* This function is not supported and will return NSAPI_ERROR_UNSUPPORTED.
112112
*
113113
* @param channel Channel on which the connection is to be made (Default: 0).
114114
* @return Not supported, returns NSAPI_ERROR_UNSUPPORTED.
@@ -149,11 +149,12 @@ class SclSTAInterface : public WiFiInterface, public EMACInterface {
149149
int scan(WiFiAccessPoint *res, unsigned count);
150150

151151
/** This function is used to indicate if the device is connected to the network.
152+
*
152153
* @return SCL_SUCCESS if device is connected.
153154
*/
154155
int is_interface_connected();
155156

156-
/** Gets the BSSID (MAC address of device connected to)
157+
/** Gets the BSSID (MAC address of device connected to).
157158
*
158159
* @param bssid Pointer to the BSSID value.
159160
* @return SCL_SUCCESS if BSSID is obtained successfully.
@@ -162,16 +163,18 @@ class SclSTAInterface : public WiFiInterface, public EMACInterface {
162163
*/
163164
int get_bssid(uint8_t *bssid);
164165

165-
/** This function is used to set up the WiFi interface after the WiFi on
166-
* @return SCL_SUCCESS if the WiFi interface is up successfully.
166+
/** This function is used to set up the Wi-Fi interface.
167+
* This function should be used after the wifi_on.
168+
*
169+
* @return SCL_SUCCESS if the Wi-Fi interface is set up successfully.
167170
*/
168171
int wifi_set_up(void);
169172

170173
private:
171174

172-
char _ssid[MAX_SSID_LENGTH]; /* The longest possible name (defined in 802.11) +1 for the \0 */
173-
char _pass[MAX_PASSWORD_LENGTH]; /* The longest allowed passphrase + 1 */
174-
nsapi_security_t _security;
175-
SCL_EMAC &_scl_emac;
175+
char _ssid[MAX_SSID_LENGTH]; /**< The longest possible name (defined in 802.11) +1 for the \0 */
176+
char _pass[MAX_PASSWORD_LENGTH]; /**< The longest allowed passphrase + 1 */
177+
nsapi_security_t _security; /**< Security type */
178+
SCL_EMAC &_scl_emac; /**< SCL_EMAC object */
176179
};
177-
#endif
180+
#endif /* ifndef SCL_STA_INTERFACE_H */

features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_SCL/interface/default_wifi_interface.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@
3232

3333
#include "SclSTAInterface.h"
3434

35+
/** @file
36+
* Provides function definition to override get_target_default_intance of WiFiInterface and NetworkInterface classes
37+
*/
38+
39+
/**
40+
* Returns the WiFiInterface Object
41+
* This function can be called using WiFiInterface or NetworkInterface objects
42+
*
43+
* @return pointer to WiFiInterface object.
44+
*/
45+
3546
WiFiInterface *WiFiInterface::get_target_default_instance()
3647
{
3748
static SclSTAInterface wifi;

features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_SCL/interface/emac_eapol.h

Lines changed: 0 additions & 78 deletions
This file was deleted.

features/netsocket/emac-drivers/TARGET_Cypress/COMPONENT_SCL/interface/scl_emac.cpp

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@
4141
#include "lwip/ethip6.h"
4242
#include "mbed_shared_queues.h"
4343
#include "scl_buffer_api.h"
44-
#include "emac_eapol.h"
4544
#include "cy_result.h"
4645
#include "cy_pdl.h"
4746
#include "scl_ipc.h"
4847

49-
extern "C"
50-
{
51-
eapol_packet_handler_t emac_eapol_packet_handler = NULL;
52-
} // extern "C"
48+
/** @file
49+
* Provides EMAC interface functions to be used with the SCL_EMAC object
50+
*/
5351

5452
SCL_EMAC::SCL_EMAC(scl_interface_role_t role)
5553
: interface_type(role)
@@ -107,7 +105,7 @@ bool SCL_EMAC::power_up()
107105
{
108106
if (!powered_up) {
109107
if (scl_wifi_on() != true) {
110-
SCL_LOG(("returning false in scl_wifi_on()\n"));
108+
SCL_LOG(("returning False in scl_wifi_on()\n"));
111109
return false;
112110
}
113111
powered_up = true;
@@ -127,7 +125,7 @@ bool SCL_EMAC::get_hwaddr(uint8_t *addr) const
127125
return true;
128126
}
129127
else {
130-
SCL_LOG(("return false in SCL_EMAC::gethwaddr\n"));
128+
SCL_LOG(("return False in SCL_EMAC::gethwaddr\n"));
131129
return false;
132130
}
133131

@@ -190,34 +188,6 @@ void SCL_EMAC::set_activity_cb(mbed::Callback<void(bool)> cb)
190188

191189
extern "C"
192190
{
193-
194-
void emac_receive_eapol_packet(scl_buffer_t buffer)
195-
{
196-
if (buffer != NULL) {
197-
if (emac_eapol_packet_handler != NULL) {
198-
emac_eapol_packet_handler(buffer);
199-
} else {
200-
scl_buffer_release(buffer, SCL_NETWORK_RX);
201-
}
202-
}
203-
}
204-
205-
scl_result_t emac_register_eapol_packet_handler(eapol_packet_handler_t eapol_packet_handler)
206-
{
207-
208-
if (emac_eapol_packet_handler == NULL) {
209-
emac_eapol_packet_handler = eapol_packet_handler;
210-
return SCL_SUCCESS;
211-
}
212-
213-
return SCL_HANDLER_ALREADY_REGISTERED;
214-
}
215-
216-
void emac_unregister_eapol_packet_handler(void)
217-
{
218-
emac_eapol_packet_handler = NULL;
219-
}
220-
221191
void scl_network_process_ethernet_data(scl_buffer_t buffer)
222192
{
223193
emac_mem_buf_t *mem_buf = NULL;

0 commit comments

Comments
 (0)