Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6e1818e

Browse files
authoredFeb 24, 2025··
Merge branch 'main' into blockdev-fix
2 parents de96222 + f64f904 commit 6e1818e

20 files changed

+132
-151
lines changed
 

‎cores/arduino/analog.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,10 @@ void analogReference(uint8_t mode) {
558558
R_ADC_Open(&adc1.ctrl, &adc1.cfg);
559559
}
560560

561+
#if defined(AVCC_MEASURE_PIN)
561562
static float aref = 0;
563+
#endif
564+
562565
float analogReference() {
563566
switch (adc.cfg_extend.adc_vref_control) {
564567
case ADC_VREF_CONTROL_1_5V_OUTPUT:
@@ -817,4 +820,4 @@ void analogWrite(pin_size_t pinNumber, int value)
817820

818821
FspTimer* __get_timer_for_channel(int channel) {
819822
return pwms.get_from_channel(channel)->get_timer();
820-
}
823+
}

‎libraries/ESPhost/src/CMsg.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ void CMsg::reset_without_delete() {
8585

8686

8787
/* -------------------------------------------------------------------------- */
88-
CMsg::CMsg() : buf{nullptr}, dim{0}, payload_header{nullptr}, proto_dim{0}, tlv_size(esp_tlv_header_size) {
88+
CMsg::CMsg() : buf{nullptr}, dim{0}, proto_dim{0}, payload_header{nullptr}, tlv_size(esp_tlv_header_size) {
8989

9090
}
9191
/* -------------------------------------------------------------------------- */
9292

9393
/* -------------------------------------------------------------------------- */
94-
CMsg::CMsg(uint16_t proto_size, bool use_tlv /*= true*/) : buf{nullptr},
95-
dim{0},
96-
payload_header{nullptr},
97-
proto_dim{proto_size} {
94+
CMsg::CMsg(uint16_t proto_size, bool use_tlv /*= true*/) : buf{nullptr},
95+
dim{0},
96+
proto_dim{proto_size},
97+
payload_header{nullptr} {
9898
/* -------------------------------------------------------------------------- */
9999
uint16_t request_size = 0;
100100
if(use_tlv) {
@@ -204,6 +204,7 @@ CMsg& CMsg::operator=(CMsg&& m) {
204204
Serial.println(" bad!");
205205
#endif
206206
}
207+
return *this;
207208
}
208209

209210

@@ -442,6 +443,7 @@ void CMsg::debug_print(const char* title) {
442443
/* -------------------------------------------------------------------------- */
443444
bool CMsg::store_rx_buffer(const uint8_t *buffer, uint32_t d) {
444445
/* -------------------------------------------------------------------------- */
446+
(void)d;
445447
/* rx_payload_len is TLV + PROTO (tlv can be present or not) */
446448
uint16_t rx_payload_len = verify_payload_header(buffer);
447449

@@ -498,6 +500,7 @@ bool CMsg::add_msg(CMsg &msg) {
498500
return false;
499501
}
500502
}
503+
return true;
501504
}
502505

503506
/* -------------------------------------------------------------------------- */

‎libraries/ESPhost/src/EspSpiDriver.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ static spi_event_t _spi_cb_status = SPI_EVENT_TRANSFER_ABORTED;
124124
* ############################# */
125125

126126
static void spi_callback(spi_callback_args_t *p_args);
127-
static void ext_irq_callback(void);
128127

129128

130129
/* execute SPI communication, send the content of tx_buffer to ESP32, put the
@@ -534,9 +533,3 @@ static void spi_callback(spi_callback_args_t *p_args) {
534533
_spi_cb_status = SPI_EVENT_TRANSFER_ABORTED;
535534
}
536535
}
537-
538-
/* -------------------------------------------------------------------------- */
539-
static void ext_irq_callback(void) {
540-
/* -------------------------------------------------------------------------- */
541-
542-
}

‎libraries/Ethernet/src/Ethernet.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ int CEthernet::begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_ser
123123
/* -------------------------------------------------------------------------- */
124124
int CEthernet::begin(uint8_t *mac, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet, unsigned long timeout, unsigned long responseTimeout) {
125125
/* -------------------------------------------------------------------------- */
126+
(void)responseTimeout;
127+
(void)timeout;
126128
CLwipIf::getInstance().setMacAddress(NI_ETHERNET, mac);
127129
return begin(local_ip, dns_server, gateway, subnet);
128130
}

‎libraries/Ethernet/src/EthernetClock.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,14 @@ fsp_err_t EthernetClock::stop() {
4949
fsp_err_t err = R_AGT_Stop(&this->TIMER_ETHERNET_ctrl);
5050
if (err != FSP_SUCCESS) {
5151
return err;
52-
} else {
53-
err = R_AGT_Close(&this->TIMER_ETHERNET_ctrl);
54-
if (err != FSP_SUCCESS) {
55-
return err;
56-
} else {
57-
err = R_AGT_Disable(&this->TIMER_ETHERNET_ctrl);
58-
if (err != FSP_SUCCESS) {
59-
return err;
60-
}
61-
}
6252
}
53+
54+
err = R_AGT_Close(&this->TIMER_ETHERNET_ctrl);
55+
if (err != FSP_SUCCESS) {
56+
return err;
57+
}
58+
59+
return R_AGT_Disable(&this->TIMER_ETHERNET_ctrl);
6360
}
6461

6562
#else

‎libraries/Ethernet/src/EthernetDriver.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ void eth_reset_due_to_ADE_bit() {
195195
/* -------------------------------------------------------------------------- */
196196
void EthernetDriver::irq_callback(ether_callback_args_t * p_args) {
197197
/* -------------------------------------------------------------------------- */
198-
p_args->status_ecsr;
199198
uint32_t reg_eesr = p_args->status_eesr;
200199
if(p_args->channel == ETHERNET_CHANNEL) {
201200
if(p_args->event == ETHER_EVENT_WAKEON_LAN) {

‎libraries/SSLClient/src/SSLClient.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,9 @@ void SSLClient::setClient(Client& client)
9797

9898
void SSLClient::stop()
9999
{
100-
if (sslclient->client >= 0) {
101-
//sslclient->client->stop();
102-
_connected = false;
103-
_peek = -1;
104-
}
105-
stop_ssl_socket(sslclient, _CA_cert, _cert, _private_key);
100+
stop_ssl_socket(sslclient);
101+
_connected = false;
102+
_peek = -1;
106103
}
107104

108105
int SSLClient::connect(IPAddress ip, uint16_t port)
@@ -150,12 +147,12 @@ int SSLClient::connect(const char *host, uint16_t port, const char *_CA_cert, co
150147
}
151148

152149
int SSLClient::connect(IPAddress ip, uint16_t port, const char *pskIdent, const char *psKey) {
153-
return connect(ip.toString().c_str(), port,_pskIdent, _psKey);
150+
return connect(ip.toString().c_str(), port, pskIdent, psKey);
154151
}
155152

156153
int SSLClient::connect(const char *host, uint16_t port, const char *pskIdent, const char *psKey) {
157154
log_v("start_ssl_client with PSK");
158-
int ret = start_ssl_client(sslclient, host, port, _timeout, NULL, NULL, NULL, NULL, _pskIdent, _psKey, _use_insecure);
155+
int ret = start_ssl_client(sslclient, host, port, _timeout, NULL, NULL, NULL, NULL, pskIdent, psKey, _use_insecure);
159156
_lastError = ret;
160157
if (ret < 0) {
161158
log_e("start_ssl_client: %d", ret);

‎libraries/SSLClient/src/ssl_client.cpp

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static int _handle_error(int err, const char * file, int line)
3838

3939
#define handle_error(e) _handle_error(e, __FUNCTION__, __LINE__)
4040

41+
#if defined(SSL_CLIENT_RECV_DISABLE_TIMEOUT)
4142
/**
4243
* \brief Read at most 'len' characters. If no error occurs,
4344
* the actual amount read is returned.
@@ -52,11 +53,11 @@ static int _handle_error(int err, const char * file, int line)
5253
*/
5354
static int client_net_recv( void *ctx, unsigned char *buf, size_t len ) {
5455
Client *client = (Client*)ctx;
55-
if (!client) {
56+
if (!client) {
5657
log_e("Uninitialised!");
5758
return -1;
5859
}
59-
60+
6061
//if (!client->connected()) {
6162
// log_e("Not connected!");
6263
// return -2;
@@ -68,31 +69,31 @@ static int client_net_recv( void *ctx, unsigned char *buf, size_t len ) {
6869
if (result > 0) {
6970
//esp_log_buffer_hexdump_internal("SSL.RD", buf, (uint16_t)result, ESP_LOG_VERBOSE);
7071
}
71-
72+
7273
return result;
7374
}
74-
75-
int client_net_recv_timeout( void *ctx, unsigned char *buf,
75+
#else
76+
static int client_net_recv_timeout( void *ctx, unsigned char *buf,
7677
size_t len, uint32_t timeout ) {
7778
Client *client = (Client*)ctx;
78-
if (!client) {
79+
if (!client) {
7980
log_e("Uninitialised!");
8081
return -1;
8182
}
8283
unsigned long start = millis();
8384
unsigned long tms = start + timeout;
84-
int pending = client->available();
85+
uint16_t pending = client->available();
8586
// If there is data in the client, wait for message completion
8687
if((pending > 0) && (pending < len))
8788
do {
88-
int pending = client->available();
89+
uint16_t pending = client->available();
8990
if (pending < len && timeout > 0) {
9091
delay(1);
9192
} else break;
9293
} while (millis() < tms);
93-
94+
9495
int result = client->read(buf, len);
95-
96+
9697
// lwIP interface return -1 if there is no data to read
9798
// report without throwing errors or block
9899
if (result <= 0) return MBEDTLS_ERR_SSL_WANT_READ;
@@ -102,10 +103,10 @@ int client_net_recv_timeout( void *ctx, unsigned char *buf,
102103
if (result > 0) {
103104
//esp_log_buffer_hexdump_internal("SSL.RD", buf, (uint16_t)result, ESP_LOG_VERBOSE);
104105
}
105-
106+
106107
return result;
107108
}
108-
109+
#endif
109110

110111
/**
111112
* \brief Write at most 'len' characters. If no error occurs,
@@ -121,20 +122,20 @@ int client_net_recv_timeout( void *ctx, unsigned char *buf,
121122
*/
122123
static int client_net_send( void *ctx, const unsigned char *buf, size_t len ) {
123124
Client *client = (Client*)ctx;
124-
if (!client) {
125+
if (!client) {
125126
log_e("Uninitialised!");
126127
return -1;
127128
}
128-
129+
129130
//if (!client->connected()) {
130131
// log_e("Not connected!");
131132
// return -2;
132133
//}
133-
134+
134135
//esp_log_buffer_hexdump_internal("SSL.WR", buf, (uint16_t)len, ESP_LOG_VERBOSE);
135-
136+
136137
int result = client->write(buf, len);
137-
138+
138139
log_d("SSL client TX res=%d len=%d", result, len);
139140
return result;
140141
}
@@ -152,7 +153,7 @@ void ssl_init(sslclient_context *ssl_client, Client *client, const char * ca_pat
152153
mbedtls_ssl_conf_ciphersuites(&ssl_client->ssl_conf, mbedtls_ssl_list_ciphersuites());
153154

154155
mbedtls_ssl_conf_dbg(&ssl_client->ssl_conf, mbedtls_debug_print, NULL);
155-
mbedtls_debug_set_threshold(DEBUG_LEVEL);
156+
mbedtls_debug_set_threshold(SSL_DEBUG_LEVEL);
156157

157158
mbedtls_fs_init(ca_path);
158159
}
@@ -225,7 +226,7 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
225226
}
226227
unsigned char psk[MBEDTLS_PSK_MAX_LEN];
227228
size_t psk_len = strlen(psKey)/2;
228-
for (int j=0; j<strlen(psKey); j+= 2) {
229+
for (size_t j=0; j<strlen(psKey); j+= 2) {
229230
char c = psKey[j];
230231
if (c >= '0' && c <= '9') c -= '0';
231232
else if (c >= 'A' && c <= 'F') c -= 'A' - 10;
@@ -336,13 +337,13 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
336337
memset(buf, 0, sizeof(buf));
337338
mbedtls_x509_crt_verify_info(buf, sizeof(buf), " ! ", flags);
338339
log_e("Failed to verify peer certificate! verification info: %s", buf);
339-
stop_ssl_socket(ssl_client, rootCABuff, cli_cert, cli_key); //It's not safe continue.
340+
stop_ssl_socket(ssl_client); //It's not safe continue.
340341

341342
return handle_error(ret);
342343
} else {
343344
log_v("Certificate verified.");
344345
}
345-
346+
346347
if ((rootCABuff != NULL) || ((rootCAPath != NULL))) {
347348
log_d("free buffer");
348349
mbedtls_x509_crt_free(&ssl_client->ca_cert);
@@ -354,14 +355,14 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
354355

355356
if (cli_key != NULL) {
356357
mbedtls_pk_free(&ssl_client->client_key);
357-
}
358+
}
358359

359360
//return ssl_client->socket;
360361
return 1;
361362
}
362363

363364

364-
void stop_ssl_socket(sslclient_context *ssl_client, const char *rootCABuff, const char *cli_cert, const char *cli_key)
365+
void stop_ssl_socket(sslclient_context *ssl_client)
365366
{
366367
log_v("Cleaning SSL connection.");
367368

‎libraries/SSLClient/src/ssl_client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ typedef struct sslclient_context {
4343

4444
void ssl_init(sslclient_context *ssl_client, Client *client, const char *ca_path);
4545
int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t port, int timeout, const char *rootCABuff, const char *rootCAPath, const char *cli_cert, const char *cli_key, const char *pskIdent, const char *psKey, bool insecure);
46-
void stop_ssl_socket(sslclient_context *ssl_client, const char *rootCABuff, const char *cli_cert, const char *cli_key);
46+
void stop_ssl_socket(sslclient_context *ssl_client);
4747
int data_to_read(sslclient_context *ssl_client);
4848
int send_ssl_data(sslclient_context *ssl_client, const uint8_t *data, uint16_t len);
4949
int get_ssl_receive(sslclient_context *ssl_client, uint8_t *data, int length);

‎libraries/SSLClient/src/ssl_debug.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "ssl_debug.h"
2121

2222
void ssl_debug_print(const char *format, ...) {
23-
char debug_buf[1024];
23+
char debug_buf[1024];
2424
va_list argptr;
2525
va_start(argptr, format);
2626
vsnprintf(debug_buf, sizeof(debug_buf), format, argptr);
@@ -29,7 +29,7 @@ void ssl_debug_print(const char *format, ...) {
2929
}
3030

3131
void ssl_debug_println(const char *format, ...) {
32-
char debug_buf[1024];
32+
char debug_buf[1024];
3333
va_list argptr;
3434
va_start(argptr, format);
3535
vsnprintf(debug_buf, sizeof(debug_buf), format, argptr);
@@ -43,6 +43,7 @@ void ssl_debug_none(const char *format, ...) {
4343

4444
void mbedtls_debug_print(void *ctx, int level, const char *file, int line, const char *str)
4545
{
46+
((void) ctx);
4647
((void) level);
4748
ssl_debug_print("%s:%04d: %s", file, line, str);
4849
}

‎libraries/SSLClient/src/ssl_debug.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,33 @@
2929
* 4: DEBUG
3030
* 5: VERBOSE
3131
*/
32-
#define DEBUG_LEVEL 1
32+
#define SSL_DEBUG_LEVEL 1
3333

34-
#if DEBUG_LEVEL > 0
34+
#if SSL_DEBUG_LEVEL > 0
3535
#define log_e ssl_debug_println
3636
#else
3737
#define log_e ssl_debug_none
3838
#endif
3939

40-
#if DEBUG_LEVEL > 1
40+
#if SSL_DEBUG_LEVEL > 1
4141
#define log_w ssl_debug_println
4242
#else
4343
#define log_w ssl_debug_none
4444
#endif
4545

46-
#if DEBUG_LEVEL > 2
46+
#if SSL_DEBUG_LEVEL > 2
4747
#define log_i ssl_debug_println
4848
#else
4949
#define log_i ssl_debug_none
5050
#endif
5151

52-
#if DEBUG_LEVEL > 3
52+
#if SSL_DEBUG_LEVEL > 3
5353
#define log_d ssl_debug_println
5454
#else
5555
#define log_d ssl_debug_none
5656
#endif
57-
58-
#if DEBUG_LEVEL > 4
57+
58+
#if SSL_DEBUG_LEVEL > 4
5959
#define log_v ssl_debug_println
6060
#else
6161
#define log_v ssl_debug_none

‎libraries/WiFi/src/WiFi.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ void CWifi::setHostname(const char* name) {
156156
/* -------------------------------------------------------------------------- */
157157
int CWifi::disconnect() {
158158
/* -------------------------------------------------------------------------- */
159-
CLwipIf::getInstance().disconnectFromAp();
159+
if(CLwipIf::getInstance().disconnectFromAp() == ESP_CONTROL_OK) {
160+
return 1;
161+
}
162+
return 0;
160163
}
161164

162165
/* -------------------------------------------------------------------------- */

‎libraries/WiFiS3/src/WiFi.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
#define DEFAULT_GW_AP_ADDRESS IPAddress(192,168,1,1)
1818
#define DEFAULT_NM_AP_ADDRESS IPAddress(255,255,255,0)
1919

20-
2120
#define WIFI_FIRMWARE_LATEST_VERSION "0.4.1"
22-
#define WL_MAC_ADDR_LENGTH 6
2321

2422
class CAccessPoint {
2523
public:

‎libraries/WiFiS3/src/WiFiClient.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
using namespace std;
44

55
/* -------------------------------------------------------------------------- */
6-
WiFiClient::WiFiClient() : _sock(-1), destroy_at_distructor(true), rx_buffer(nullptr) {
6+
WiFiClient::WiFiClient() : _sock(-1), rx_buffer(nullptr) {
77
rx_buffer = std::shared_ptr<FifoBuffer<uint8_t,RX_BUFFER_DIM>>(new FifoBuffer<uint8_t,RX_BUFFER_DIM>());
88
}
99
/* -------------------------------------------------------------------------- */
1010

1111
/* -------------------------------------------------------------------------- */
12-
WiFiClient::WiFiClient(int s) : _sock(s), destroy_at_distructor(false), rx_buffer(nullptr) {
12+
WiFiClient::WiFiClient(int s) : _sock(s), rx_buffer(nullptr) {
1313
rx_buffer = std::shared_ptr<FifoBuffer<uint8_t,RX_BUFFER_DIM>>(new FifoBuffer<uint8_t,RX_BUFFER_DIM>());
1414
}
1515
/* -------------------------------------------------------------------------- */

‎libraries/WiFiS3/src/WiFiClient.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ class WiFiClient : public Client {
7070

7171
protected:
7272
int _sock;
73-
bool destroy_at_distructor;
7473
int _connectionTimeout = 0;
7574
void getSocket();
7675
static constexpr uint32_t RX_BUFFER_DIM = 1024;

‎libraries/WiFiS3/src/WiFiTypes.h

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
#ifndef WIFI_S3_TYPES_H
22
#define WIFI_S3_TYPES_H
33

4+
// Maximum size of a SSID
5+
#define WL_SSID_MAX_LENGTH 32
6+
// Length of passphrase. Valid lengths are 8-63.
7+
#define WL_WPA_KEY_MAX_LENGTH 63
8+
// Length of key in bytes. Valid values are 5 and 13.
9+
#define WL_WEP_KEY_MAX_LENGTH 13
10+
// Size of a MAC-address or BSSID
11+
#define WL_MAC_ADDR_LENGTH 6
12+
// Size of a IP4 address
13+
#define WL_IPV4_LENGTH 4
14+
415
typedef enum {
5-
WL_NO_SHIELD = 255,
6-
WL_NO_MODULE = WL_NO_SHIELD,
7-
WL_IDLE_STATUS = 0,
8-
WL_NO_SSID_AVAIL,
9-
WL_SCAN_COMPLETED,
10-
WL_CONNECTED,
11-
WL_CONNECT_FAILED,
12-
WL_CONNECTION_LOST,
13-
WL_DISCONNECTED,
14-
WL_AP_LISTENING,
15-
WL_AP_CONNECTED,
16-
WL_AP_FAILED
16+
WL_NO_SHIELD = 255,
17+
WL_NO_MODULE = WL_NO_SHIELD,
18+
WL_IDLE_STATUS = 0,
19+
WL_NO_SSID_AVAIL,
20+
WL_SCAN_COMPLETED,
21+
WL_CONNECTED,
22+
WL_CONNECT_FAILED,
23+
WL_CONNECTION_LOST,
24+
WL_DISCONNECTED,
25+
WL_AP_LISTENING,
26+
WL_AP_CONNECTED,
27+
WL_AP_FAILED
1728
} wl_status_t;
1829

1930
/* Encryption modes */
@@ -27,15 +38,14 @@ enum wl_enc_type {
2738
ENC_TYPE_WPA3,
2839
ENC_TYPE_NONE,
2940
ENC_TYPE_AUTO,
30-
3141
ENC_TYPE_UNKNOWN = 255
3242
};
3343

3444
typedef enum {
35-
WL_PING_DEST_UNREACHABLE = -1,
36-
WL_PING_TIMEOUT = -2,
37-
WL_PING_UNKNOWN_HOST = -3,
38-
WL_PING_ERROR = -4
39-
} wl_ping_result_t;
45+
WL_PING_DEST_UNREACHABLE = -1,
46+
WL_PING_TIMEOUT = -2,
47+
WL_PING_UNKNOWN_HOST = -3,
48+
WL_PING_ERROR = -4
49+
}wl_ping_result_t;
4050

4151
#endif

‎libraries/lwIpWrapper/src/CNetIf.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,11 @@ CNetIf* CLwipIf::get(NetIfType_t type,
224224
IPAddress _nm)
225225
{
226226
/* -------------------------------------------------------------------------- */
227-
static int id = 0;
228227
CNetIf* rv = nullptr;
229228
bool isStation = true;
230229
bool isEth = false;
231230

232-
if (type >= 0 && type < NETWORK_INTERFACES_MAX_NUM) {
231+
if (type == NI_WIFI_STATION || type == NI_WIFI_SOFTAP || type == NI_ETHERNET) {
233232
if (net_ifs[type] == nullptr) {
234233
switch (type) {
235234
case NI_WIFI_STATION:
@@ -537,17 +536,17 @@ int CLwipIf::getMacAddress(NetIfType_t type, uint8_t* mac)
537536
MAC.mode = WIFI_MODE_STA;
538537
if (CEspControl::getInstance().getWifiMacAddress(MAC) == ESP_CONTROL_OK) {
539538
CNetUtilities::macStr2macArray(mac, MAC.mac);
540-
rv = MAC_ADDRESS_DIM;
539+
rv = WL_MAC_ADDR_LENGTH;
541540
}
542541
} else if (type == NI_WIFI_SOFTAP) {
543542
MAC.mode = WIFI_MODE_AP;
544543
if (CEspControl::getInstance().getWifiMacAddress(MAC) == ESP_CONTROL_OK) {
545544
CNetUtilities::macStr2macArray(mac, MAC.mac);
546-
rv = MAC_ADDRESS_DIM;
545+
rv = WL_MAC_ADDR_LENGTH;
547546
}
548547
} else {
549548
eth_get_mac_address(mac);
550-
rv = MAC_ADDRESS_DIM;
549+
rv = WL_MAC_ADDR_LENGTH;
551550
}
552551

553552
CLwipIf::getInstance().restartAsyncRequest();
@@ -1025,11 +1024,11 @@ uint8_t CLwipIf::getEncryptionType(NetIfType_t type)
10251024

10261025
/* -------------------------------------------------------------------------- */
10271026
CNetIf::CNetIf()
1028-
: dhcp_timeout(30000)
1027+
: id(0)
1028+
, dhcp_timeout(30000)
1029+
, dhcp_st(DHCP_IDLE_STATUS)
10291030
, dhcp_started(false)
10301031
, dhcp_acquired(false)
1031-
, id(0)
1032-
, dhcp_st(DHCP_IDLE_STATUS)
10331032
, _dhcp_lease_state(DHCP_CHECK_NONE)
10341033
{
10351034
/* -------------------------------------------------------------------------- */

‎libraries/lwIpWrapper/src/CNetIf.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,21 @@
3434
#endif
3535

3636
#define MAX_SOFAT_CONNECTION_DEF 5
37-
38-
#define MAC_ADDRESS_DIM 6
3937
#define NETWORK_INTERFACES_MAX_NUM 3
4038
#define MAX_HOSTNAME_DIM 253
4139

4240
#define WIFI_INIT_TIMEOUT_MS 10000
4341

42+
// Maximum size of a SSID
43+
#define WL_SSID_MAX_LENGTH 32
44+
// Length of passphrase. Valid lengths are 8-63.
45+
#define WL_WPA_KEY_MAX_LENGTH 63
46+
// Length of key in bytes. Valid values are 5 and 13.
47+
#define WL_WEP_KEY_MAX_LENGTH 13
48+
// Size of a MAC-address or BSSID
4449
#define WL_MAC_ADDR_LENGTH 6
50+
// Size of a IP4 address
51+
#define WL_IPV4_LENGTH 4
4552

4653
/* DEFAULT ADDRESS FOR ETHERNET CONFIGURATION */
4754

@@ -208,7 +215,7 @@ class CNetIf {
208215

209216
/* default dummy implementation because ethernet does not have that */
210217
virtual const char* getSSID() { return nullptr; }
211-
virtual uint8_t* getBSSID(uint8_t* bssid) { return nullptr; }
218+
virtual uint8_t* getBSSID(uint8_t* bssid) { (void)bssid; return nullptr; }
212219
virtual int32_t getRSSI() { return 0; }
213220
virtual uint8_t getEncryptionType() { return 0; }
214221

‎libraries/lwIpWrapper/src/lwipClient.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ sketches but sock is ignored. */
1919
lwipClient::lwipClient(uint8_t sock)
2020
: _tcp_client(NULL)
2121
{
22+
(void)sock;
2223
}
2324
/* -------------------------------------------------------------------------- */
2425

‎libraries/lwIpWrapper/src/lwipDhcpServer.c

Lines changed: 19 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#include <stdlib.h>
22
#include <string.h>
3-
4-
5-
63
#include "lwipDhcpServer.h"
74
#include "lwipDhcpServerPriv.h"
85

@@ -11,37 +8,12 @@ static const u32_t magic_cookie = 0x63538263;
118

129
#define BOOTP_BROADCAST 0x8000
1310

14-
#define DHCP_REQUEST 1
15-
#define DHCP_REPLY 2
1611
#define DHCP_HTYPE_ETHERNET 1
17-
#define DHCP_HLEN_ETHERNET 6
18-
#define DHCP_MSG_LEN 236
1912

2013
#define DHCPS_SERVER_PORT 67
2114
#define DHCPS_CLIENT_PORT 68
2215

23-
#define DHCPDISCOVER 1
24-
#define DHCPOFFER 2
25-
#define DHCPREQUEST 3
26-
#define DHCPDECLINE 4
27-
#define DHCPACK 5
28-
#define DHCPNAK 6
29-
#define DHCPRELEASE 7
30-
31-
#define DHCP_OPTION_SUBNET_MASK 1
32-
#define DHCP_OPTION_ROUTER 3
33-
#define DHCP_OPTION_DNS_SERVER 6
34-
#define DHCP_OPTION_REQ_IPADDR 50
35-
#define DHCP_OPTION_LEASE_TIME 51
36-
#define DHCP_OPTION_MSG_TYPE 53
37-
#define DHCP_OPTION_SERVER_ID 54
38-
#define DHCP_OPTION_INTERFACE_MTU 26
3916
#define DHCP_OPTION_PERFORM_ROUTER_DISCOVERY 31
40-
#define DHCP_OPTION_BROADCAST_ADDRESS 28
41-
#define DHCP_OPTION_REQ_LIST 55
42-
#define DHCP_OPTION_END 255
43-
44-
4517

4618
#ifdef DHCPS_DEBUG
4719
/* function defined in CNetIf.cpp */
@@ -74,13 +46,6 @@ static struct netif *dhcps_netif = NULL;
7446
static struct udp_pcb *dhcps_pcb;
7547
static DHCP_Address dhcp_address;
7648

77-
78-
static uint8_t xid[4];
79-
80-
81-
//static list_node *plist = NULL;
82-
static bool renew = false;
83-
8449
static dhcps_lease_t dhcps_poll;
8550
static dhcps_time_t dhcps_lease_time = DHCPS_LEASE_TIME_DEF; //minute
8651
static dhcps_offer_t dhcps_offer = 0xFF;
@@ -191,7 +156,7 @@ void dhcps_set_option_info(uint8_t op_id, void *opt_info, u32_t opt_len)
191156
*******************************************************************************/
192157
static uint8_t *add_msg_type(uint8_t *optptr, uint8_t type)
193158
{
194-
*optptr++ = DHCP_OPTION_MSG_TYPE;
159+
*optptr++ = DHCP_OPTION_MESSAGE_TYPE;
195160
*optptr++ = 1;
196161
*optptr++ = type;
197162
return optptr;
@@ -260,7 +225,7 @@ static uint8_t *add_offer_options(uint8_t *optptr)
260225
}
261226

262227

263-
*optptr++ = DHCP_OPTION_INTERFACE_MTU;
228+
*optptr++ = DHCP_OPTION_MTU;
264229
*optptr++ = 2;
265230
*optptr++ = 0x05;
266231
*optptr++ = 0xdc;
@@ -301,7 +266,7 @@ static uint8_t *add_end(uint8_t *optptr)
301266
*******************************************************************************/
302267
static void create_msg(struct dhcps_msg *m)
303268
{
304-
m->op = DHCP_REPLY;
269+
m->op = DHCP_BOOTREPLY;
305270

306271
m->htype = DHCP_HTYPE_ETHERNET;
307272

@@ -346,18 +311,17 @@ struct pbuf * dhcps_pbuf_alloc(uint16_t len)
346311
*******************************************************************************/
347312
static void send_offer(struct dhcps_msg *msg, uint16_t len)
348313
{
314+
(void)len;
349315
uint8_t *end;
350316
struct pbuf *p, *q;
351317
uint8_t *data;
352318
uint16_t cnt = 0;
353-
uint8_t CopyFinished=0;
354319
uint16_t i;
355-
uint32_t endptr , dataptr = NULL;
356320
#if DHCPS_DEBUG
357321
err_t SendOffer_err_t;
358322
#endif
359323
create_msg(msg);
360-
end = add_msg_type(&msg->options[4], DHCPOFFER);
324+
end = add_msg_type(&msg->options[4], DHCP_OFFER);
361325
end = add_offer_options(end);
362326
end = add_end(end);
363327

@@ -417,6 +381,7 @@ static void send_offer(struct dhcps_msg *msg, uint16_t len)
417381
*******************************************************************************/
418382
static void send_nak(struct dhcps_msg *m, uint16_t len)
419383
{
384+
(void)len;
420385
uint8_t *end;
421386
struct pbuf *p, *q;
422387
uint8_t *data;
@@ -427,7 +392,7 @@ static void send_nak(struct dhcps_msg *m, uint16_t len)
427392
#endif
428393
create_msg(m);
429394

430-
end = add_msg_type(&m->options[4], DHCPNAK);
395+
end = add_msg_type(&m->options[4], DHCP_NAK);
431396
end = add_end(end);
432397

433398
p = dhcps_pbuf_alloc(len);
@@ -483,6 +448,7 @@ static void send_nak(struct dhcps_msg *m, uint16_t len)
483448
*******************************************************************************/
484449
static void send_ack(struct dhcps_msg *m, uint16_t len)
485450
{
451+
(void)len;
486452
uint8_t *end;
487453
struct pbuf *p, *q;
488454
uint8_t *data;
@@ -491,7 +457,7 @@ static void send_ack(struct dhcps_msg *m, uint16_t len)
491457
err_t SendAck_err_t;
492458
create_msg(m);
493459

494-
end = add_msg_type(&m->options[4], DHCPACK);
460+
end = add_msg_type(&m->options[4], DHCP_ACK);
495461
end = add_offer_options(end);
496462
end = add_end(end);
497463

@@ -573,10 +539,10 @@ static uint8_t parse_options(uint8_t *OptionsPtr, int16_t len)
573539
DHCPS_LOG("dhcps: (int16_t)*optptr = %d\n", (int16_t)*OptionsPtr);
574540
#endif
575541
switch ((int16_t) *OptionsPtr) {
576-
case DHCP_OPTION_MSG_TYPE: //53
542+
case DHCP_OPTION_MESSAGE_TYPE://53
577543
type = *(OptionsPtr + 2);
578544
break;
579-
case DHCP_OPTION_REQ_IPADDR://50
545+
case DHCP_OPTION_REQUESTED_IP://50
580546
s.state = DHCPS_STATE_ACK;
581547
break;
582548
case DHCP_OPTION_END: {
@@ -592,26 +558,26 @@ static uint8_t parse_options(uint8_t *OptionsPtr, int16_t len)
592558
}
593559

594560
switch (type) {
595-
case DHCPDISCOVER://1
561+
case DHCP_DISCOVER://1
596562
#if DHCPS_DEBUG
597563
DHCPS_LOG("dhcps: DHCPD_STATE_DHCPDISCOVER -- SEND_OFFER\n");
598564
#endif
599565
s.state = DHCPS_STATE_OFFER;
600566
break;
601-
case DHCPREQUEST://3
567+
case DHCP_REQUEST://3
602568
#if DHCPS_DEBUG
603569
DHCPS_LOG("dhcps: DHCPD_STATE_DHCPREQUEST -- SEND_ACK\n");
604570
#endif
605571
s.state = DHCPS_STATE_ACK;
606572

607573
break;
608-
case DHCPDECLINE://4
574+
case DHCP_DECLINE://4
609575
s.state = DHCPS_STATE_IDLE;
610576
#if DHCPS_DEBUG
611577
DHCPS_LOG("dhcps: DHCPD_STATE_IDLE\n");
612578
#endif
613579
break;
614-
case DHCPRELEASE://7
580+
case DHCP_RELEASE://7
615581
s.state = DHCPS_STATE_RELEASE;
616582
#if DHCPS_DEBUG
617583
DHCPS_LOG("dhcps: DHCPD_STATE_IDLE\n");
@@ -664,10 +630,12 @@ static void handle_dhcp(void *arg,
664630
const ip_addr_t *addr,
665631
uint16_t port)
666632
{
633+
(void)arg;
634+
(void)pcb;
635+
(void)addr;
636+
(void)port;
667637
struct dhcps_msg *pmsg_dhcps = NULL;
668638
int16_t tlen, malloc_len;
669-
uint16_t i;
670-
uint16_t dhcps_msg_cnt = 0;
671639
uint8_t *p_dhcps_msg = NULL;
672640
struct pbuf *q;
673641

0 commit comments

Comments
 (0)
Please sign in to comment.