Skip to content

Commit 1c77790

Browse files
authored
allow the examples to build in a more strict env (#3299)
1 parent 5bff89f commit 1c77790

File tree

15 files changed

+31
-36
lines changed

15 files changed

+31
-36
lines changed

libraries/BLE/examples/BLE_client/BLE_client.ino

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ bool connectToServer() {
8787
pRemoteCharacteristic->registerForNotify(notifyCallback);
8888

8989
connected = true;
90+
return true;
9091
}
9192
/**
9293
* Scan for BLE servers and find the first one that advertises the service we are looking for.

libraries/BLE/src/BLECharacteristic.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -693,15 +693,13 @@ void BLECharacteristic::setValue(int& data32) {
693693
} // setValue
694694

695695
void BLECharacteristic::setValue(float& data32) {
696-
uint8_t temp[4];
697-
*((float*)temp) = data32;
698-
setValue(temp, 4);
696+
float temp = data32;
697+
setValue((uint8_t*)&temp, 4);
699698
} // setValue
700699

701700
void BLECharacteristic::setValue(double& data64) {
702-
uint8_t temp[8];
703-
*((double*)temp) = data64;
704-
setValue(temp, 8);
701+
double temp = data64;
702+
setValue((uint8_t*)&temp, 8);
705703
} // setValue
706704

707705

libraries/BLE/src/GeneralUtils.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,10 @@ bool GeneralUtils::base64Encode(const std::string& in, std::string* out) {
104104
* * Amount of free RAM
105105
*/
106106
void GeneralUtils::dumpInfo() {
107-
size_t freeHeap = heap_caps_get_free_size(MALLOC_CAP_8BIT);
108107
esp_chip_info_t chipInfo;
109108
esp_chip_info(&chipInfo);
110109
log_v("--- dumpInfo ---");
111-
log_v("Free heap: %d", freeHeap);
110+
log_v("Free heap: %d", heap_caps_get_free_size(MALLOC_CAP_8BIT));
112111
log_v("Chip Info: Model: %d, cores: %d, revision: %d", chipInfo.model, chipInfo.cores, chipInfo.revision);
113112
log_v("ESP-IDF version: %s", esp_get_idf_version());
114113
log_v("---");

libraries/EEPROM/examples/eeprom_class/eeprom_class.ino

+4-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ void setup() {
3737
ESP.restart();
3838
}
3939

40-
char* name = "Teo Swee Ann";
40+
const char* name = "Teo Swee Ann";
41+
char rname[32];
4142
double height = 5.8;
4243
uint32_t age = 47;
4344

@@ -60,10 +61,10 @@ void setup() {
6061
Serial.println("------------------------------------\n");
6162

6263
// Read: Variables <--- EEPROM stores
63-
NAMES.get(0, name);
64+
NAMES.get(0, rname);
6465
HEIGHT.get(0, height);
6566
AGE.get(0, age);
66-
Serial.print("name: "); Serial.println(name);
67+
Serial.print("name: "); Serial.println(rname);
6768
Serial.print("height: "); Serial.println(height);
6869
Serial.print("age: "); Serial.println(age);
6970

libraries/EEPROM/examples/eeprom_extra/eeprom_extra.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ void setup() {
4949
EEPROM.writeULong(address, 4294967295); // Same as writeUInt and readUInt
5050
address += sizeof(unsigned long);
5151

52-
int64_t value = -9223372036854775808; // -2^63
52+
int64_t value = -1223372036854775808LL; // -2^63
5353
EEPROM.writeLong64(address, value);
5454
address += sizeof(int64_t);
5555

56-
uint64_t Value = 18446744073709551615; // 2^64 - 1
56+
uint64_t Value = 18446744073709551615ULL; // 2^64 - 1
5757
EEPROM.writeULong64(address, Value);
5858
address += sizeof(uint64_t);
5959

libraries/ESP32/examples/DeepSleep/TouchWakeUp/TouchWakeUp.ino

-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ Method to print the touchpad by which ESP32
4040
has been awaken from sleep
4141
*/
4242
void print_wakeup_touchpad(){
43-
touch_pad_t pin;
44-
4543
touchPin = esp_sleep_get_touchpad_wakeup_status();
4644

4745
switch(touchPin)

libraries/ESP32/examples/ESPNow/Basic/Master/Master.ino

+4-8
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void ScanForSlave() {
8888
Serial.print(i + 1); Serial.print(": "); Serial.print(SSID); Serial.print(" ["); Serial.print(BSSIDstr); Serial.print("]"); Serial.print(" ("); Serial.print(RSSI); Serial.print(")"); Serial.println("");
8989
// Get BSSID => Mac Address of the Slave
9090
int mac[6];
91-
if ( 6 == sscanf(BSSIDstr.c_str(), "%x:%x:%x:%x:%x:%x%c", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5] ) ) {
91+
if ( 6 == sscanf(BSSIDstr.c_str(), "%x:%x:%x:%x:%x:%x", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5] ) ) {
9292
for (int ii = 0; ii < 6; ++ii ) {
9393
slave.peer_addr[ii] = (uint8_t) mac[ii];
9494
}
@@ -124,17 +124,15 @@ bool manageSlave() {
124124
}
125125

126126
Serial.print("Slave Status: ");
127-
const esp_now_peer_info_t *peer = &slave;
128-
const uint8_t *peer_addr = slave.peer_addr;
129127
// check if the peer exists
130-
bool exists = esp_now_is_peer_exist(peer_addr);
128+
bool exists = esp_now_is_peer_exist(slave.peer_addr);
131129
if ( exists) {
132130
// Slave already paired.
133131
Serial.println("Already Paired");
134132
return true;
135133
} else {
136134
// Slave not paired, attempt pair
137-
esp_err_t addStatus = esp_now_add_peer(peer);
135+
esp_err_t addStatus = esp_now_add_peer(&slave);
138136
if (addStatus == ESP_OK) {
139137
// Pair success
140138
Serial.println("Pair success");
@@ -168,9 +166,7 @@ bool manageSlave() {
168166
}
169167

170168
void deletePeer() {
171-
const esp_now_peer_info_t *peer = &slave;
172-
const uint8_t *peer_addr = slave.peer_addr;
173-
esp_err_t delStatus = esp_now_del_peer(peer_addr);
169+
esp_err_t delStatus = esp_now_del_peer(slave.peer_addr);
174170
Serial.print("Slave Delete Status: ");
175171
if (delStatus == ESP_OK) {
176172
// Delete success

libraries/ESP32/examples/ESPNow/Multi-Slave/Master/Master.ino

+3-5
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void ScanForSlave() {
100100
// Get BSSID => Mac Address of the Slave
101101
int mac[6];
102102

103-
if ( 6 == sscanf(BSSIDstr.c_str(), "%x:%x:%x:%x:%x:%x%c", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5] ) ) {
103+
if ( 6 == sscanf(BSSIDstr.c_str(), "%x:%x:%x:%x:%x:%x", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5] ) ) {
104104
for (int ii = 0; ii < 6; ++ii ) {
105105
slaves[SlaveCnt].peer_addr[ii] = (uint8_t) mac[ii];
106106
}
@@ -127,22 +127,20 @@ void ScanForSlave() {
127127
void manageSlave() {
128128
if (SlaveCnt > 0) {
129129
for (int i = 0; i < SlaveCnt; i++) {
130-
const esp_now_peer_info_t *peer = &slaves[i];
131-
const uint8_t *peer_addr = slaves[i].peer_addr;
132130
Serial.print("Processing: ");
133131
for (int ii = 0; ii < 6; ++ii ) {
134132
Serial.print((uint8_t) slaves[i].peer_addr[ii], HEX);
135133
if (ii != 5) Serial.print(":");
136134
}
137135
Serial.print(" Status: ");
138136
// check if the peer exists
139-
bool exists = esp_now_is_peer_exist(peer_addr);
137+
bool exists = esp_now_is_peer_exist(slaves[i].peer_addr);
140138
if (exists) {
141139
// Slave already paired.
142140
Serial.println("Already Paired");
143141
} else {
144142
// Slave not paired, attempt pair
145-
esp_err_t addStatus = esp_now_add_peer(peer);
143+
esp_err_t addStatus = esp_now_add_peer(&slaves[i]);
146144
if (addStatus == ESP_OK) {
147145
// Pair success
148146
Serial.println("Pair success");

libraries/ESP32/examples/RMT/RMTLoopback/RMTLoopback.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void loop()
5252
// Printout the received data plus the original values
5353
for (i=0; i<60; i++)
5454
{
55-
Serial.printf("%08x=%08x ", my_data[i], data[i] );
55+
Serial.printf("%08x=%08x ", my_data[i].val, data[i].val );
5656
if (!((i+1)%4)) Serial.println("\n");
5757
}
5858
Serial.println("\n");

libraries/ESP32/examples/RMT/RMTReadXJT/RMTReadXJT.ino

-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ static bool xjtReceiveBit(size_t index, bool bit){
141141
}
142142

143143
void parseRmt(rmt_data_t* items, size_t len, uint32_t* channels){
144-
size_t chan = 0;
145144
bool valid = true;
146145
rmt_data_t* it = NULL;
147146

libraries/FFat/examples/FFat_Test/FFat_Test.ino

+3-3
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ void setup(){
165165
return;
166166
}
167167

168-
Serial.printf("Total space: %10lu\n", FFat.totalBytes());
169-
Serial.printf("Free space: %10lu\n", FFat.freeBytes());
168+
Serial.printf("Total space: %10u\n", FFat.totalBytes());
169+
Serial.printf("Free space: %10u\n", FFat.freeBytes());
170170
listDir(FFat, "/", 0);
171171
writeFile(FFat, "/hello.txt", "Hello ");
172172
appendFile(FFat, "/hello.txt", "World!\r\n");
@@ -175,7 +175,7 @@ void setup(){
175175
readFile(FFat, "/foo.txt");
176176
deleteFile(FFat, "/foo.txt");
177177
testFileIO(FFat, "/test.txt");
178-
Serial.printf("Free space: %10lu\n", FFat.freeBytes());
178+
Serial.printf("Free space: %10u\n", FFat.freeBytes());
179179
deleteFile(FFat, "/test.txt");
180180
Serial.println( "Test complete" );
181181
}

libraries/WiFi/examples/ETH_LAN8720_internal_clock/ETH_LAN8720_internal_clock.ino

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
* ETH_CLOCK_GPIO16_OUT - 50MHz clock from internal APLL output on GPIO16 - possibly an inverter is needed for LAN8720
1111
* ETH_CLOCK_GPIO17_OUT - 50MHz clock from internal APLL inverted output on GPIO17 - tested with LAN8720
1212
*/
13+
#ifdef ETH_CLK_MODE
14+
#undef ETH_CLK_MODE
15+
#endif
1316
#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
1417

1518
// Pin# of the enable signal for the external crystal oscillator (-1 to disable for internal APLL source)

libraries/WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ void WiFiEvent(WiFiEvent_t event)
121121
case SYSTEM_EVENT_ETH_GOT_IP:
122122
Serial.println("Obtained IP address");
123123
break;
124+
default: break;
124125
}}
125126

126127
void WiFiGotIP(WiFiEvent_t event, WiFiEventInfo_t info)

libraries/WiFi/examples/WiFiUDPClient/WiFiUDPClient.ino

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void loop(){
3434
if(connected){
3535
//Send a packet
3636
udp.beginPacket(udpAddress,udpPort);
37-
udp.printf("Seconds since boot: %u", millis()/1000);
37+
udp.printf("Seconds since boot: %lu", millis()/1000);
3838
udp.endPacket();
3939
}
4040
//Wait for 1 second
@@ -71,5 +71,6 @@ void WiFiEvent(WiFiEvent_t event){
7171
Serial.println("WiFi lost connection");
7272
connected = false;
7373
break;
74+
default: break;
7475
}
7576
}

platform.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ compiler.sdk.path={runtime.platform.path}/tools/sdk
2525
compiler.cpreprocessor.flags=-DESP_PLATFORM -DMBEDTLS_CONFIG_FILE="mbedtls/esp_config.h" -DHAVE_CONFIG_H "-I{compiler.sdk.path}/include/config" "-I{compiler.sdk.path}/include/app_trace" "-I{compiler.sdk.path}/include/app_update" "-I{compiler.sdk.path}/include/asio" "-I{compiler.sdk.path}/include/bootloader_support" "-I{compiler.sdk.path}/include/bt" "-I{compiler.sdk.path}/include/coap" "-I{compiler.sdk.path}/include/console" "-I{compiler.sdk.path}/include/driver" "-I{compiler.sdk.path}/include/esp-tls" "-I{compiler.sdk.path}/include/esp32" "-I{compiler.sdk.path}/include/esp_adc_cal" "-I{compiler.sdk.path}/include/esp_event" "-I{compiler.sdk.path}/include/esp_http_client" "-I{compiler.sdk.path}/include/esp_http_server" "-I{compiler.sdk.path}/include/esp_https_ota" "-I{compiler.sdk.path}/include/esp_ringbuf" "-I{compiler.sdk.path}/include/ethernet" "-I{compiler.sdk.path}/include/expat" "-I{compiler.sdk.path}/include/fatfs" "-I{compiler.sdk.path}/include/freemodbus" "-I{compiler.sdk.path}/include/freertos" "-I{compiler.sdk.path}/include/heap" "-I{compiler.sdk.path}/include/idf_test" "-I{compiler.sdk.path}/include/jsmn" "-I{compiler.sdk.path}/include/json" "-I{compiler.sdk.path}/include/libsodium" "-I{compiler.sdk.path}/include/log" "-I{compiler.sdk.path}/include/lwip" "-I{compiler.sdk.path}/include/mbedtls" "-I{compiler.sdk.path}/include/mdns" "-I{compiler.sdk.path}/include/micro-ecc" "-I{compiler.sdk.path}/include/mqtt" "-I{compiler.sdk.path}/include/newlib" "-I{compiler.sdk.path}/include/nghttp" "-I{compiler.sdk.path}/include/nvs_flash" "-I{compiler.sdk.path}/include/openssl" "-I{compiler.sdk.path}/include/protobuf-c" "-I{compiler.sdk.path}/include/protocomm" "-I{compiler.sdk.path}/include/pthread" "-I{compiler.sdk.path}/include/sdmmc" "-I{compiler.sdk.path}/include/smartconfig_ack" "-I{compiler.sdk.path}/include/soc" "-I{compiler.sdk.path}/include/spi_flash" "-I{compiler.sdk.path}/include/spiffs" "-I{compiler.sdk.path}/include/tcp_transport" "-I{compiler.sdk.path}/include/tcpip_adapter" "-I{compiler.sdk.path}/include/ulp" "-I{compiler.sdk.path}/include/vfs" "-I{compiler.sdk.path}/include/wear_levelling" "-I{compiler.sdk.path}/include/wifi_provisioning" "-I{compiler.sdk.path}/include/wpa_supplicant" "-I{compiler.sdk.path}/include/xtensa-debug-module" "-I{compiler.sdk.path}/include/esp-face" "-I{compiler.sdk.path}/include/esp32-camera" "-I{compiler.sdk.path}/include/esp-face" "-I{compiler.sdk.path}/include/fb_gfx"
2626

2727
compiler.c.cmd=xtensa-esp32-elf-gcc
28-
compiler.c.flags=-std=gnu99 -Os -g3 -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wpointer-arith {compiler.warning_flags} -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -Wno-old-style-declaration -MMD -c
28+
compiler.c.flags=-std=gnu99 -Os -g3 -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wpointer-arith {compiler.warning_flags} -Wno-maybe-uninitialized -Wno-unused-function -Wno-unused-but-set-variable -Wno-unused-variable -Wno-deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -Wno-old-style-declaration -MMD -c
2929

3030
compiler.cpp.cmd=xtensa-esp32-elf-g++
31-
compiler.cpp.flags=-std=gnu++11 -fno-exceptions -Os -g3 -Wpointer-arith -fexceptions -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib {compiler.warning_flags} -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -fno-rtti -MMD -c
31+
compiler.cpp.flags=-std=gnu++11 -Os -g3 -Wpointer-arith -fexceptions -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib {compiler.warning_flags} -Wno-error=maybe-uninitialized -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-missing-field-initializers -Wno-sign-compare -fno-rtti -MMD -c
3232

3333
compiler.S.cmd=xtensa-esp32-elf-gcc
3434
compiler.S.flags=-c -g3 -x assembler-with-cpp -MMD -mlongcalls

0 commit comments

Comments
 (0)