Skip to content

Commit 7bee09b

Browse files
committed
Sync with ESP3D latest code (227)
1 parent b86670a commit 7bee09b

File tree

13 files changed

+63
-44
lines changed

13 files changed

+63
-44
lines changed

src/core/commands/ESP170.cpp

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
// /awb/agc/aec/hmirror/vflip/awb_gain/agc_gain/aec_value/aec2/cw/bpc/wpc
3434
// /raw_gma/lenc/special_effect/wb_mode/ae_level
3535
void ESP3DCommands::ESP170(int cmd_params_pos, ESP3DMessage* msg) {
36-
const char* camcmd = [] = {
36+
const char* camcmd[] = {
3737
"framesize",
3838
"quality",
3939
"contrast",
@@ -63,13 +63,17 @@ void ESP3DCommands::ESP170(int cmd_params_pos, ESP3DMessage* msg) {
6363
"light",
6464
#endif // CAM_LED_PIN
6565
};
66+
bool hasError = false;
67+
String ok_msg;
68+
String error_msg;
6669
ESP3DClientType target = msg->origin;
6770
ESP3DRequest requestId = msg->request_id;
6871
msg->target = target;
6972
msg->origin = ESP3DClientType::command;
7073
bool json = hasTag(msg, cmd_params_pos, "json");
7174
String tmpstr;
72-
#if AUTHENTICATION_FEATURE
75+
76+
#ifdef AUTHENTICATION_FEATURE
7377
if (msg->authentication_level == ESP3DAuthenticationLevel::guest) {
7478
dispatchAuthenticationError(msg, COMMAND_ID, json);
7579
return;
@@ -102,146 +106,146 @@ void ESP3DCommands::ESP170(int cmd_params_pos, ESP3DMessage* msg) {
102106
// now send all settings one by one
103107
// framesize
104108
if (!dispatchIdValue(json, "framesize",
105-
String(status.framesize).c_str(), target,
109+
String(s->status.framesize).c_str(), target,
106110
requestId, true)) {
107111
return;
108112
}
109113

110114
// quality
111-
if (!dispatchIdValue(json, "quality", String(status.quality).c_str(),
115+
if (!dispatchIdValue(json, "quality", String(s->status.quality).c_str(),
112116
target, requestId)) {
113117
return;
114118
}
115119

116120
// brightness
117121
if (!dispatchIdValue(json, "brightness",
118-
String(status.brightness).c_str(), target,
122+
String(s->status.brightness).c_str(), target,
119123
requestId)) {
120124
return;
121125
}
122126

123127
// contrast
124-
if (!dispatchIdValue(json, "contrast", String(status.contrast).c_str(),
128+
if (!dispatchIdValue(json, "contrast", String(s->status.contrast).c_str(),
125129
target, requestId)) {
126130
return;
127131
}
128132

129133
// saturation
130134
if (!dispatchIdValue(json, "saturation",
131-
String(status.saturation).c_str(), target,
135+
String(s->status.saturation).c_str(), target,
132136
requestId)) {
133137
return;
134138

135139
// sharpness
136140
if (!dispatchIdValue(json, "sharpness",
137-
String(status.sharpness).c_str(), target,
141+
String(s->status.sharpness).c_str(), target,
138142
requestId)) {
139143
return;
140144
}
141145

142146
// special_effect
143147
if (!dispatchIdValue(json, "special_effect",
144-
String(status.special_effect).c_str(), target,
148+
String(s->status.special_effect).c_str(), target,
145149
requestId)) {
146150
return;
147151
}
148152

149153
// wb_mode
150-
if (!dispatchIdValue(json, "wb_mode", String(status.wb_mode).c_str(),
154+
if (!dispatchIdValue(json, "wb_mode", String(s->status.wb_mode).c_str(),
151155
target, requestId)) {
152156
return;
153157
}
154158

155159
// awb
156-
if (!dispatchIdValue(json, "awb", String(status.awb).c_str(), target,
160+
if (!dispatchIdValue(json, "awb", String(s->status.awb).c_str(), target,
157161
requestId)) {
158162
return;
159163
}
160164

161165
// awb_gain
162166
if (!dispatchIdValue(json, "awb_gain",
163-
String(status.awb_gain).c_str(), target,
167+
String(s->status.awb_gain).c_str(), target,
164168
requestId)) {
165169
return;
166170
}
167171

168172
// aec
169-
if (!dispatchIdValue(json, "aec", String(status.aec).c_str(), target,
173+
if (!dispatchIdValue(json, "aec", String(s->status.aec).c_str(), target,
170174
requestId)) {
171175
return;
172176
}
173177
// aec2
174-
if (!dispatchIdValue(json, "aec2", String(status.aec2).c_str(),
178+
if (!dispatchIdValue(json, "aec2", String(s->status.aec2).c_str(),
175179
target, requestId)) {
176180
return;
177181
}
178182
// ae_level
179183
if (!dispatchIdValue(json, "ae_level",
180-
String(status.ae_level).c_str(), target,
184+
String(s->status.ae_level).c_str(), target,
181185
requestId)) {
182186
return;
183187
}
184188
// aec_value
185189
if (!dispatchIdValue(json, "aec_value",
186-
String(status.aec_value).c_str(), target,
190+
String(s->status.aec_value).c_str(), target,
187191
requestId)) {
188192
return;
189193
}
190194
// agc
191-
if (!dispatchIdValue(json, "agc", String(status.agc).c_str(), target,
195+
if (!dispatchIdValue(json, "agc", String(s->status.agc).c_str(), target,
192196
requestId)) {
193197
return;
194198
}
195199
// agc_gain
196200
if (!dispatchIdValue(json, "agc_gain",
197-
String(status.agc_gain).c_str(), target,
201+
String(s->status.agc_gain).c_str(), target,
198202
requestId)) {
199203
return;
200204
}
201205
// gainceiling
202206
if (!dispatchIdValue(json, "gainceiling",
203-
String(status.gainceiling).c_str(), target,
207+
String(s->status.gainceiling).c_str(), target,
204208
requestId)) {
205209
return;
206210
}
207211
// bpc
208-
if (!dispatchIdValue(json, "bpc", String(status.bpc).c_str(), target,
212+
if (!dispatchIdValue(json, "bpc", String(s->status.bpc).c_str(), target,
209213
requestId)) {
210214
return;
211215
}
212216
// wpc
213-
if (!dispatchIdValue(json, "wpc", String(status.wpc).c_str(), target,
217+
if (!dispatchIdValue(json, "wpc", String(s->status.wpc).c_str(), target,
214218
requestId)) {
215219
return;
216220
}
217221
// raw_gma
218-
if (!dispatchIdValue(json, "raw_gma", String(status.raw_gma).c_str(),
222+
if (!dispatchIdValue(json, "raw_gma", String(s->status.raw_gma).c_str(),
219223
target, requestId)) {
220224
return;
221225
}
222226
// lenc
223-
if (!dispatchIdValue(json, "lenc", String(status.lenc).c_str(),
227+
if (!dispatchIdValue(json, "lenc", String(s->status.lenc).c_str(),
224228
target, requestId)) {
225229
return;
226230
}
227231
// vflip
228-
if (!dispatchIdValue(json, "vflip", String(status.vflip).c_str(),
232+
if (!dispatchIdValue(json, "vflip", String(s->status.vflip).c_str(),
229233
target, requestId)) {
230234
return;
231235
}
232236
// hmirror
233-
if (!dispatchIdValue(json, "hmirror", String(status.hmirror).c_str(),
237+
if (!dispatchIdValue(json, "hmirror", String(s->status.hmirror).c_str(),
234238
target, requestId)) {
235239
return;
236240
}
237241
// dcw
238-
if (!dispatchIdValue(json, "dcw", String(status.dcw).c_str(), target,
242+
if (!dispatchIdValue(json, "dcw", String(s->status.dcw).c_str(), target,
239243
requestId)) {
240244
return;
241245
}
242246
// colorbar
243247
if (!dispatchIdValue(json, "colorbar",
244-
String(status.colorbar).c_str(), target,
248+
String(s->status.colorbar).c_str(), target,
245249
requestId)) {
246250
return;
247251
}

src/core/commands/ESP999.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void ESP3DCommands::ESP999(int cmd_params_pos, ESP3DMessage* msg) {
5151
tmpstr = get_clean_param(msg, cmd_params_pos);
5252
if (tmpstr.length() == 0) {
5353
hasError = true;
54-
error_msg = "Missing parameter"
54+
error_msg = "Missing parameter";
5555
} else {
5656
if (quietboot) {
5757
if (esp_efuse_set_rom_log_scheme(ESP_EFUSE_ROM_LOG_ON_GPIO_HIGH) !=
@@ -70,4 +70,4 @@ void ESP3DCommands::ESP999(int cmd_params_pos, ESP3DMessage* msg) {
7070
}
7171

7272
#endif // defined(ARDUINO_ARCH_ESP32) && (CONFIG_IDF_TARGET_ESP32S3 ||
73-
// CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3)
73+
// CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3)

src/core/esp3d_commands.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,14 +609,14 @@ void ESP3DCommands::execute_internal_command(int cmd, int cmd_params_pos,
609609
ESP215(cmd_params_pos, msg);
610610
break;
611611
#endif // DISPLAY_TOUCH_DRIVER
612+
#endif // DISPLAY_DEVICE
612613
#ifdef BUZZER_DEVICE
613614
// Play sound
614615
//[ESP250]F=<frequency> D=<duration> [pwd=<user password>]
615616
case 250:
616617
ESP250(cmd_params_pos, msg);
617618
break;
618619
#endif // BUZZER_DEVICE
619-
#endif // DISPLAY_DEVICE
620620
// Show pins
621621
//[ESP220][pwd=<user password>]
622622
case 220:
@@ -880,7 +880,7 @@ bool ESP3DCommands::dispatchSetting(bool json, const char *filter,
880880
break;
881881
default: // String
882882
if (index == ESP_STA_PASSWORD || index == ESP_AP_PASSWORD ||
883-
#if ESP3D_NOTIFICATIONS_FEATURE
883+
#if defined (ESP3D_NOTIFICATIONS_FEATURE)
884884
index == ESP_NOTIFICATION_TOKEN1 ||
885885
index == ESP_NOTIFICATION_TOKEN2 ||
886886
#endif // ESP3D_NOTIFICATIONS_FEATURE

src/core/esp3d_settings.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#if defined(ESP_SAVE_SETTINGS)
2727
#include "esp3d_message.h"
2828
#include "esp3d_settings.h"
29+
#include "esp3d_string.h"
2930

3031
#if ESP_SAVE_SETTINGS == SETTINGS_IN_EEPROM
3132
#include <EEPROM.h>
@@ -386,7 +387,7 @@ bool ESP3DSettings::writeByte(int pos, const uint8_t value) {
386387

387388
bool ESP3DSettings::is_string(const char *s, uint len) {
388389
for (uint p = 0; p < len; p++) {
389-
if (!isPrintable(char(s[p]))) {
390+
if (!esp3d_string::isPrintableChar(char(s[p]))) {
390391
return false;
391392
}
392393
}
@@ -431,7 +432,7 @@ const char *ESP3DSettings::readString(int pos, bool *haserror) {
431432
// read until max size is reached or \0 is found
432433
while (i < size_max && b != 0) {
433434
b = EEPROM.read(pos + i);
434-
byte_buffer[i] = isPrintable(char(b)) ? b : 0;
435+
byte_buffer[i] = esp3d_string::isPrintableChar(char(b)) ? b : 0;
435436
i++;
436437
}
437438

@@ -778,7 +779,7 @@ bool ESP3DSettings::isValidStringSetting(const char *value,
778779
}
779780
// only printable char allowed
780781
for (size_t i = 0; i < strlen(value); i++) {
781-
if (!isPrintable(value[i])) {
782+
if (!esp3d_string::isPrintableChar(value[i])) {
782783
return false;
783784
}
784785
}

src/core/esp3d_string.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,12 @@ const char* esp3d_string::formatBytes(uint64_t bytes) {
178178
res = String((float)(bytes / 1024.0 / 1024.0 / 1024.0), 2) + " GB";
179179
}
180180
return res.c_str();
181-
}
181+
}
182+
183+
bool esp3d_string::isPrintableChar(char ch){
184+
int c = static_cast<int>(ch);
185+
if (c==9 || (c >= 32 && c <= 126) || c>=128) {
186+
return true;
187+
}
188+
return false;
189+
}

src/core/esp3d_string.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const char* generateUUID(const char* seed);
2727
const char* getContentType(const char* filename);
2828
const char* encodeString(const char* s);
2929
const char* formatBytes(uint64_t bytes);
30+
bool isPrintableChar(char c);
3031
} // namespace esp3d_string
3132

3233
#endif //_ESP3D_STRING_H

src/include/esp3d_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#define _VERSION_ESP3D_H
2323

2424
// version and sources location
25-
#define FW_VERSION "3.0.0.a226"
25+
#define FW_VERSION "3.0.0.a227"
2626
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
2727

2828
#endif //_VERSION_ESP3D_H

src/modules/bluetooth/BT_service.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#ifdef BLUETOOTH_FEATURE
2626
#include "../../core/esp3d_commands.h"
2727
#include "../../core/esp3d_settings.h"
28+
#include "../../esp3d_string.h"
2829
#include "../network/netconfig.h"
2930
#include "BT_service.h"
3031
#include "BluetoothSerial.h"
@@ -215,7 +216,7 @@ void BTService::push2buffer(uint8_t *sbuf, size_t len) {
215216
_buffer_size++;
216217
}
217218
flushbuffer();
218-
} else if (isPrintable(char(sbuf[i]))) {
219+
} else if (esp3d_string::isPrintableChar(char(sbuf[i]))) {
219220
if (_buffer_size < ESP3D_BT_BUFFER_SIZE) {
220221
_buffer[_buffer_size] = sbuf[i];
221222
_buffer_size++;

src/modules/notifications/notifications_service.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ NotificationsService::NotificationsService() {
158158
_started = false;
159159
_notificationType = 0;
160160
_token1 = "";
161-
_token1 = "";
161+
_token2 = "";
162162
_settings = "";
163163
}
164164
NotificationsService::~NotificationsService() { end(); }

src/modules/sensor/bmx280.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ uint8_t BMX280SensorDevice::GetModel(uint8_t i) {
117117
const char *BMX280SensorDevice::GetCurrentModelString() {
118118
uint8_t sensortype = ESP3DSettings::readByte(ESP_SENSOR_TYPE);
119119
for (uint8_t i = 0; i < NB_TYPE_SENSOR; i++) {
120-
if ((sensortype == SENSOR_TYPE[i]) {
120+
if (sensortype == SENSOR_ID[i]) {
121121
return SENSOR_NAME[i];
122122
}
123123
}
@@ -173,7 +173,7 @@ const char *BMX280SensorDevice::GetData() {
173173
}
174174
} else {
175175
s = "DISCONNECTED";
176-
log_esp3_ed("No valid data");
176+
esp3d_log_e("No valid data");
177177
}
178178
}
179179
} else {

0 commit comments

Comments
 (0)