diff --git a/libraries/Preferences/src/Preferences.cpp b/libraries/Preferences/src/Preferences.cpp index 3e689c95..7ad494fe 100644 --- a/libraries/Preferences/src/Preferences.cpp +++ b/libraries/Preferences/src/Preferences.cpp @@ -178,8 +178,8 @@ size_t Preferences::putBytes(const char* key, const void* value, size_t len) { string res = ""; if ( key != nullptr && strlen(key) > 0 && value != nullptr && len > 0) { modem.write_nowait(string(PROMPT(_PREF_PUT)), res, "%s%s,%d,%d\r\n", CMD_WRITE(_PREF_PUT), key, PT_BLOB, len); - if(modem.passthrough((uint8_t *)value, len)) { - return len; + if(modem.passthrough((uint8_t *)value, len, &res)) { + return atoi(res.c_str()); } } return 0; diff --git a/libraries/WiFiS3/src/Modem.cpp b/libraries/WiFiS3/src/Modem.cpp index 7aa34391..b3e4038b 100644 --- a/libraries/WiFiS3/src/Modem.cpp +++ b/libraries/WiFiS3/src/Modem.cpp @@ -48,13 +48,17 @@ void ModemClass::end(){ } /* -------------------------------------------------------------------------- */ -bool ModemClass::passthrough(const uint8_t *data, size_t size) { +bool ModemClass::passthrough(const uint8_t *data, size_t size, std::string *response) { /* -------------------------------------------------------------------------- */ _serial->write(data,size); std::string prompt = DO_NOT_CHECK_CMD, data_res; auto res = buf_read(prompt, data_res); + if(response != nullptr) { + *response = data_res; + } + if(_serial_debug && _debug_level >= 2) { _serial_debug->print(" ANSWER (passthrough): "); _serial_debug->println(data_res.c_str()); diff --git a/libraries/WiFiS3/src/Modem.h b/libraries/WiFiS3/src/Modem.h index 3f785bc9..f417cfb5 100644 --- a/libraries/WiFiS3/src/Modem.h +++ b/libraries/WiFiS3/src/Modem.h @@ -27,7 +27,7 @@ class ModemClass { bool write(const std::string &cmd, std::string &str, const char * fmt, ...); void write_nowait(const std::string &cmd, std::string &str, const char * fmt, ...); - bool passthrough(const uint8_t *data, size_t size); + bool passthrough(const uint8_t *data, size_t size, std::string *response=nullptr); void avoid_trim_results() { /* one shot - it works only 1 time the it is necessary to call again this funtion */