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:
@@ -275,9 +275,14 @@ struct Wifi : WifiProvider {
|
||||
struct Ble : BleProvider {
|
||||
int32_t duration = 0;
|
||||
std::string value;
|
||||
bool initialized = false;
|
||||
|
||||
Status init(const std::string*) override { return Status::success(); }
|
||||
void deinit() override {}
|
||||
Status init(const std::string*) override {
|
||||
initialized = true;
|
||||
return Status::success();
|
||||
}
|
||||
void deinit() override { initialized = false; }
|
||||
bool isInitialized() const override { return initialized; }
|
||||
Status scan(int32_t durationMs, std::vector<BleDevice>& devices) override {
|
||||
duration = durationMs;
|
||||
const BleDevice device = {"tag", "aa:bb", -60};
|
||||
|
||||
@@ -96,7 +96,10 @@ int main() {
|
||||
"assert(wifi.connect())");
|
||||
assert(bench.wifi.savedReconnect);
|
||||
|
||||
run(state, "assert(ble.scan()[1].address == 'aa:bb')\n"
|
||||
run(state, "assert(not ble.isInitialized())\n"
|
||||
"assert(ble.init())\n"
|
||||
"assert(ble.isInitialized())\n"
|
||||
"assert(ble.scan()[1].address == 'aa:bb')\n"
|
||||
"assert(#ble.read('svc', 'chr') == 3)\n"
|
||||
"assert(ble.write('svc', 'chr', 'x\\0y'))");
|
||||
assert(bench.ble.duration == 3000);
|
||||
|
||||
Reference in New Issue
Block a user