feat(ble): expose isInitialized and reclaim memory before radios start
The controller and the WiFi driver each need a large aggregate allocation, which a live app sitting on garbage can deny - that is why a failed connect often succeeded on retry. Both bindings now collect before initializing, and the tree reserves its node and spec capacity so a build does not reallocate into a tight heap.
This commit is contained in:
@@ -131,10 +131,17 @@ public:
|
||||
const char* error = nullptr;
|
||||
uint16_t focus = NONE;
|
||||
|
||||
// Growth doubling needs the old and new buffers live at once, which is the
|
||||
// allocation that fails first on a tight heap. One reservation covers a
|
||||
// typical screen so a build reallocates only if it genuinely gets large.
|
||||
static constexpr size_t RESERVE = 64;
|
||||
|
||||
void reset() {
|
||||
focus = NONE;
|
||||
nodes.clear();
|
||||
specs.clear();
|
||||
nodes.reserve(RESERVE);
|
||||
specs.reserve(RESERVE);
|
||||
labelAt.clear();
|
||||
labels.clear();
|
||||
styles.clear();
|
||||
|
||||
@@ -231,6 +231,7 @@ public:
|
||||
virtual ~BleProvider() = default;
|
||||
virtual Status init(const std::string* name) = 0;
|
||||
virtual void deinit() = 0;
|
||||
virtual bool isInitialized() const = 0;
|
||||
virtual Status scan(int32_t durationMs, std::vector<BleDevice>& devices) = 0;
|
||||
virtual Status connect(const std::string& address) = 0;
|
||||
virtual void disconnect() = 0;
|
||||
|
||||
Reference in New Issue
Block a user