From 7a1044309cfb77581d7ca50ba0b4cab94acbfb21 Mon Sep 17 00:00:00 2001 From: bugobliterator Date: Mon, 8 Nov 2021 19:50:30 +0530 Subject: [PATCH] AP_HAL_ESP32: add get_storage_ptr method --- libraries/AP_HAL_ESP32/Storage.cpp | 13 +++++++++++++ libraries/AP_HAL_ESP32/Storage.h | 1 + 2 files changed, 14 insertions(+) diff --git a/libraries/AP_HAL_ESP32/Storage.cpp b/libraries/AP_HAL_ESP32/Storage.cpp index 58d0181a72..61faf15fb2 100644 --- a/libraries/AP_HAL_ESP32/Storage.cpp +++ b/libraries/AP_HAL_ESP32/Storage.cpp @@ -215,3 +215,16 @@ bool Storage::healthy(void) #endif return _initialised && AP_HAL::millis() - _last_empty_ms < 2000; } + +/* + get storage size and ptr + */ +bool Storage::get_storage_ptr(void *&ptr, size_t &size) +{ + if (!_initialised) { + return false; + } + ptr = _buffer; + size = sizeof(_buffer); + return true; +} diff --git a/libraries/AP_HAL_ESP32/Storage.h b/libraries/AP_HAL_ESP32/Storage.h index 81a4aa573e..45f8376e69 100644 --- a/libraries/AP_HAL_ESP32/Storage.h +++ b/libraries/AP_HAL_ESP32/Storage.h @@ -39,6 +39,7 @@ public: void _timer_tick(void) override; bool healthy(void) override; + bool get_storage_ptr(void *&ptr, size_t &size) override; private: volatile bool _initialised;