diff --git a/.github/workflows/build-firmware.yml b/.github/workflows/build-firmware.yml index 66d8cd84..2630d709 100644 --- a/.github/workflows/build-firmware.yml +++ b/.github/workflows/build-firmware.yml @@ -1,5 +1,8 @@ name: Build Firmware -on: [push] +on: + push: + pull_request: + types: [opened, synchronize, reopened] permissions: read-all diff --git a/.github/workflows/build-sdk.yml b/.github/workflows/build-sdk.yml index 495af5be..6e9b2f36 100644 --- a/.github/workflows/build-sdk.yml +++ b/.github/workflows/build-sdk.yml @@ -1,5 +1,8 @@ name: Build SDK -on: [push] +on: + push: + pull_request: + types: [opened, synchronize, reopened] permissions: read-all diff --git a/.github/workflows/build-simulator.yml b/.github/workflows/build-simulator.yml index 17304102..aa4dcbc0 100644 --- a/.github/workflows/build-simulator.yml +++ b/.github/workflows/build-simulator.yml @@ -1,9 +1,12 @@ # Disabled because of issue: https://github.com/libsdl-org/setup-sdl/issues/23 name: Build Simulator -on: [push] +on: + push: + pull_request: + types: [opened, synchronize, reopened] jobs: Build-Simulator-Linux: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - name: "Build" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a7c0cf46..b33814e4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,5 +1,8 @@ name: Tests -on: [push] +on: + push: + pull_request: + types: [opened, synchronize, reopened] jobs: Run: runs-on: ubuntu-latest diff --git a/Boards/CYD-2432S024C/Source/hal/YellowDisplay.cpp b/Boards/CYD-2432S024C/Source/hal/YellowDisplay.cpp index fe5b9eae..035b1b7c 100644 --- a/Boards/CYD-2432S024C/Source/hal/YellowDisplay.cpp +++ b/Boards/CYD-2432S024C/Source/hal/YellowDisplay.cpp @@ -140,7 +140,7 @@ bool YellowDisplay::start() { } bool YellowDisplay::stop() { - tt_assert(displayHandle != nullptr); + assert(displayHandle != nullptr); lvgl_port_remove_disp(displayHandle); diff --git a/Boards/LilygoTdeck/Source/hal/TdeckDisplay.cpp b/Boards/LilygoTdeck/Source/hal/TdeckDisplay.cpp index d2cab120..16730b01 100644 --- a/Boards/LilygoTdeck/Source/hal/TdeckDisplay.cpp +++ b/Boards/LilygoTdeck/Source/hal/TdeckDisplay.cpp @@ -159,7 +159,7 @@ bool TdeckDisplay::start() { } bool TdeckDisplay::stop() { - tt_assert(displayHandle != nullptr); + assert(displayHandle != nullptr); lvgl_port_remove_disp(displayHandle); diff --git a/Boards/M5stackCore2/Source/hal/Core2Display.cpp b/Boards/M5stackCore2/Source/hal/Core2Display.cpp index b534bfee..f38620eb 100644 --- a/Boards/M5stackCore2/Source/hal/Core2Display.cpp +++ b/Boards/M5stackCore2/Source/hal/Core2Display.cpp @@ -102,7 +102,7 @@ bool Core2Display::start() { } bool Core2Display::stop() { - tt_assert(displayHandle != nullptr); + assert(displayHandle != nullptr); lvgl_port_remove_disp(displayHandle); diff --git a/Boards/M5stackCoreS3/Source/hal/CoreS3Display.cpp b/Boards/M5stackCoreS3/Source/hal/CoreS3Display.cpp index 4078ab8f..abce2a86 100644 --- a/Boards/M5stackCoreS3/Source/hal/CoreS3Display.cpp +++ b/Boards/M5stackCoreS3/Source/hal/CoreS3Display.cpp @@ -119,7 +119,7 @@ bool CoreS3Display::start() { } bool CoreS3Display::stop() { - tt_assert(displayHandle != nullptr); + assert(displayHandle != nullptr); lvgl_port_remove_disp(displayHandle); diff --git a/Boards/Simulator/Source/LvglTask.cpp b/Boards/Simulator/Source/LvglTask.cpp index 9375b6b4..579578d2 100644 --- a/Boards/Simulator/Source/LvglTask.cpp +++ b/Boards/Simulator/Source/LvglTask.cpp @@ -69,7 +69,7 @@ void lvgl_task_start() { nullptr ); - tt_assert(task_result == pdTRUE); + assert(task_result == pdTRUE); } lv_disp_t* displayHandle = nullptr; diff --git a/Boards/Simulator/Source/Main.cpp b/Boards/Simulator/Source/Main.cpp index a93fb1ed..86f64b23 100644 --- a/Boards/Simulator/Source/Main.cpp +++ b/Boards/Simulator/Source/Main.cpp @@ -33,7 +33,7 @@ void freertosMain() { nullptr ); - tt_assert(task_result == pdTRUE); + assert(task_result == pdTRUE); // Blocks forever vTaskStartScheduler(); diff --git a/Boards/UnPhone/Source/PowerOn.cpp b/Boards/UnPhone/Source/PowerOn.cpp index 509f5dd4..af16b5ec 100644 --- a/Boards/UnPhone/Source/PowerOn.cpp +++ b/Boards/UnPhone/Source/PowerOn.cpp @@ -1,3 +1,4 @@ +#include "Preferences.h" #include "TactilityCore.h" #include "UnPhoneFeatures.h" #include @@ -8,6 +9,55 @@ extern UnPhoneFeatures unPhoneFeatures; static std::unique_ptr powerThread; +static const char* bootCountKey = "boot_count"; +static const char* powerOffCountKey = "power_off_count"; +static const char* powerSleepKey = "power_sleep_key"; + +class DeviceStats { + +private: + + tt::Preferences preferences = tt::Preferences("unphone"); + + int32_t getValue(const char* key) { + int32_t value = 0; + preferences.optInt32(key, value); + return value; + } + + void setValue(const char* key, int32_t value) { + preferences.putInt32(key, value); + } + + void increaseValue(const char* key) { + int32_t new_value = getValue(key) + 1; + setValue(key, new_value); + } + +public: + + void notifyBootStart() { + increaseValue(bootCountKey); + } + + void notifyPowerOff() { + increaseValue(powerOffCountKey); + } + + void notifyPowerSleep() { + increaseValue(powerSleepKey); + } + + void printInfo() { + TT_LOG_I("TAG", "Device stats:"); + TT_LOG_I("TAG", " boot: %ld", getValue(bootCountKey)); + TT_LOG_I("TAG", " power off: %ld", getValue(powerOffCountKey)); + TT_LOG_I("TAG", " power sleep: %ld", getValue(powerSleepKey)); + } +}; + +DeviceStats bootStats; + enum class PowerState { Initial, On, @@ -16,6 +66,7 @@ enum class PowerState { #define DEBUG_POWER_STATES false +#if DEBUG_POWER_STATES /** Helper method to use the buzzer to signal the different power stages */ static void powerInfoBuzz(uint8_t count) { if (DEBUG_POWER_STATES) { @@ -33,6 +84,7 @@ static void powerInfoBuzz(uint8_t count) { } } } +#endif static void updatePowerSwitch() { static PowerState last_state = PowerState::Initial; @@ -46,19 +98,28 @@ static void updatePowerSwitch() { if (!unPhoneFeatures.isUsbPowerConnected()) { // and usb unplugged we go into shipping mode TT_LOG_W(TAG, "Shipping mode until USB connects"); +#if DEBUG_POWER_STATES unPhoneFeatures.setExpanderPower(true); powerInfoBuzz(3); unPhoneFeatures.setExpanderPower(false); +#endif unPhoneFeatures.turnPeripheralsOff(); + bootStats.notifyPowerOff(); + unPhoneFeatures.setShipping(true); // tell BM to stop supplying power until USB connects } else { // When power switch is off, but USB is plugged in, we wait (deep sleep) until USB is unplugged. TT_LOG_W(TAG, "Waiting for USB disconnect to power off"); +#if DEBUG_POWER_STATES powerInfoBuzz(2); +#endif + unPhoneFeatures.turnPeripheralsOff(); + bootStats.notifyPowerSleep(); + // Deep sleep for 1 minute, then awaken to check power state again // GPIO trigger from power switch also awakens the device unPhoneFeatures.wakeOnPowerSwitch(); @@ -70,9 +131,9 @@ static void updatePowerSwitch() { last_state = PowerState::On; TT_LOG_W(TAG, "Power on"); - unPhoneFeatures.setShipping(false); - unPhoneFeatures.setExpanderPower(true); +#if DEBUG_POWER_STATES powerInfoBuzz(1); +#endif } } } @@ -95,6 +156,11 @@ static void startPowerSwitchThread() { } static bool unPhonePowerOn() { + // Print early, in case of early crash (info will be from previous boot) + bootStats.printInfo(); + + bootStats.notifyBootStart(); + if (!unPhoneFeatures.init()) { TT_LOG_E(TAG, "UnPhoneFeatures init failed"); return false; diff --git a/Boards/UnPhone/Source/UnPhoneFeatures.cpp b/Boards/UnPhone/Source/UnPhoneFeatures.cpp index 6521a6d7..82aaa9bc 100644 --- a/Boards/UnPhone/Source/UnPhoneFeatures.cpp +++ b/Boards/UnPhone/Source/UnPhoneFeatures.cpp @@ -283,13 +283,11 @@ bool UnPhoneFeatures::setShipping(bool on) const { if (on) { TT_LOG_W(TAG, "setShipping: on"); batteryManagement.setWatchDogTimer(Bq24295::WatchDogTimer::Disabled); - // Set bit 5 to disable - batteryManagement.setOperationControlBitOn(1 << 5); + batteryManagement.setBatFetOn(false); } else { TT_LOG_W(TAG, "setShipping: off"); batteryManagement.setWatchDogTimer(Bq24295::WatchDogTimer::Enabled40s); - // Clear bit 5 to enable - batteryManagement.setOperationControlBitOff(1 << 5); + batteryManagement.setBatFetOn(true); } return true; } diff --git a/Boards/UnPhone/Source/bq24295/Bq24295.cpp b/Boards/UnPhone/Source/bq24295/Bq24295.cpp index a75e638d..43a036a7 100644 --- a/Boards/UnPhone/Source/bq24295/Bq24295.cpp +++ b/Boards/UnPhone/Source/bq24295/Bq24295.cpp @@ -60,18 +60,16 @@ bool Bq24295::setWatchDogTimer(WatchDogTimer in) const { // endregoin -// region Operation Control +// region Operation Control (REG07) -bool Bq24295::getOperationControl(uint8_t value) const { - return readRegister8(registers::OPERATION_CONTROL, value); -} - -bool Bq24295::setOperationControlBitOn(uint8_t mask) const { - return bitOn(registers::OPERATION_CONTROL, mask); -} - -bool Bq24295::setOperationControlBitOff(uint8_t mask) const { - return bitOff(registers::OPERATION_CONTROL, mask); +bool Bq24295::setBatFetOn(bool on) const { + if (on) { + // bit 5 low means bat fet is on + return bitOff(registers::OPERATION_CONTROL, BIT(5)); + } else { + // bit 5 high means bat fet is off + return bitOn(registers::OPERATION_CONTROL, BIT(5)); + } } // endregion diff --git a/Boards/UnPhone/Source/bq24295/Bq24295.h b/Boards/UnPhone/Source/bq24295/Bq24295.h index 096924b4..0d11402f 100644 --- a/Boards/UnPhone/Source/bq24295/Bq24295.h +++ b/Boards/UnPhone/Source/bq24295/Bq24295.h @@ -26,9 +26,7 @@ public: bool isUsbPowerConnected() const; - bool getOperationControl(uint8_t value) const; - bool setOperationControlBitOn(uint8_t mask) const; - bool setOperationControlBitOff(uint8_t mask) const; + bool setBatFetOn(bool on) const; bool getStatus(uint8_t& value) const; bool getVersion(uint8_t& value) const; diff --git a/Boards/UnPhone/Source/hal/UnPhoneDisplay.cpp b/Boards/UnPhone/Source/hal/UnPhoneDisplay.cpp index eed9ca32..09e19343 100644 --- a/Boards/UnPhone/Source/hal/UnPhoneDisplay.cpp +++ b/Boards/UnPhone/Source/hal/UnPhoneDisplay.cpp @@ -56,7 +56,7 @@ bool UnPhoneDisplay::start() { } bool UnPhoneDisplay::stop() { - tt_assert(displayHandle != nullptr); + assert(displayHandle != nullptr); lv_display_delete(displayHandle); displayHandle = nullptr; diff --git a/CODING_STYLE.md b/CODING_STYLE.md index 23cb0ac1..18c9d459 100644 --- a/CODING_STYLE.md +++ b/CODING_STYLE.md @@ -51,7 +51,7 @@ void getLimit() { Preprocessor functions are written in snake-case and prefixed with `tt_`, for example: ```c++ -#define tt_assert(x) __tt_assert_internal(x) +#define tt_check(x) if (!(x)) { /* .. */ } ``` ### Type names diff --git a/Documentation/ideas.md b/Documentation/ideas.md index 58e7af4b..3e7ce560 100644 --- a/Documentation/ideas.md +++ b/Documentation/ideas.md @@ -14,6 +14,7 @@ - M5Stack Core only shows 4MB of SPIRAM in use # TODOs +- Extend unPhone power driver: add charging status, usb connection status, etc. - Expose app::Paths to TactilityC - Refactor ServiceManifest into C++ class-based design like the App class - Experiment with what happens when using C++ code in an external app (without using standard library!) diff --git a/Tactility/Private/app/AppInstance.h b/Tactility/Private/app/AppInstance.h index 0b98b89f..ea1243e1 100644 --- a/Tactility/Private/app/AppInstance.h +++ b/Tactility/Private/app/AppInstance.h @@ -41,7 +41,7 @@ private: const std::shared_ptr& manifest ) { if (manifest->location.isInternal()) { - tt_assert(manifest->createApp != nullptr); + assert(manifest->createApp != nullptr); return manifest->createApp(); } else if (manifest->location.isExternal()) { if (manifest->createApp != nullptr) { diff --git a/Tactility/Source/Tactility.cpp b/Tactility/Source/Tactility.cpp index 247facfa..0eff769b 100644 --- a/Tactility/Source/Tactility.cpp +++ b/Tactility/Source/Tactility.cpp @@ -135,7 +135,7 @@ static void register_and_start_user_services(const std::vector AppInstance::getParameters() const { } std::unique_ptr AppInstance::getPaths() const { - tt_assert(manifest != nullptr); + assert(manifest != nullptr); return std::make_unique(*manifest); } diff --git a/Tactility/Source/app/ElfApp.cpp b/Tactility/Source/app/ElfApp.cpp index 71d2ad63..2e4a7e88 100644 --- a/Tactility/Source/app/ElfApp.cpp +++ b/Tactility/Source/app/ElfApp.cpp @@ -188,8 +188,8 @@ bool registerElfApp(const std::string& filePath) { std::shared_ptr createElfApp(const std::shared_ptr& manifest) { TT_LOG_I(TAG, "createElfApp"); - tt_assert(manifest != nullptr); - tt_assert(manifest->location.isExternal()); + assert(manifest != nullptr); + assert(manifest->location.isExternal()); return std::make_shared(manifest->location.getPath()); } diff --git a/Tactility/Source/app/alertdialog/AlertDialog.cpp b/Tactility/Source/app/alertdialog/AlertDialog.cpp index 53dce733..39f35a62 100644 --- a/Tactility/Source/app/alertdialog/AlertDialog.cpp +++ b/Tactility/Source/app/alertdialog/AlertDialog.cpp @@ -50,7 +50,7 @@ private: static void onButtonClickedCallback(lv_event_t* e) { auto appContext = service::loader::getCurrentAppContext(); - tt_assert(appContext != nullptr); + assert(appContext != nullptr); auto app = std::static_pointer_cast(appContext->getApp()); app->onButtonClicked(e); } diff --git a/Tactility/Source/app/boot/Boot.cpp b/Tactility/Source/app/boot/Boot.cpp index 57069d0e..f489c011 100644 --- a/Tactility/Source/app/boot/Boot.cpp +++ b/Tactility/Source/app/boot/Boot.cpp @@ -36,9 +36,9 @@ private: kernel::systemEventPublish(kernel::SystemEvent::BootSplash); auto* lvgl_display = lv_display_get_default(); - tt_assert(lvgl_display != nullptr); + assert(lvgl_display != nullptr); auto* hal_display = (hal::Display*)lv_display_get_user_data(lvgl_display); - tt_assert(hal_display != nullptr); + assert(hal_display != nullptr); if (hal_display->supportsBacklightDuty()) { int32_t backlight_duty = app::display::getBacklightDuty(); hal_display->setBacklightDuty(backlight_duty); diff --git a/Tactility/Source/app/display/Display.cpp b/Tactility/Source/app/display/Display.cpp index 0cb6cf47..8dbde04c 100644 --- a/Tactility/Source/app/display/Display.cpp +++ b/Tactility/Source/app/display/Display.cpp @@ -24,9 +24,9 @@ static uint8_t gamma = 255; static void onBacklightSliderEvent(lv_event_t* event) { auto* slider = static_cast(lv_event_get_target(event)); auto* lvgl_display = lv_display_get_default(); - tt_assert(lvgl_display != nullptr); + assert(lvgl_display != nullptr); auto* hal_display = (tt::hal::Display*)lv_display_get_user_data(lvgl_display); - tt_assert(hal_display != nullptr); + assert(hal_display != nullptr); if (hal_display->supportsBacklightDuty()) { int32_t slider_value = lv_slider_get_value(slider); @@ -41,9 +41,9 @@ static void onBacklightSliderEvent(lv_event_t* event) { static void onGammaSliderEvent(lv_event_t* event) { auto* slider = static_cast(lv_event_get_target(event)); auto* lvgl_display = lv_display_get_default(); - tt_assert(lvgl_display != nullptr); + assert(lvgl_display != nullptr); auto* hal_display = (tt::hal::Display*)lv_display_get_user_data(lvgl_display); - tt_assert(hal_display != nullptr); + assert(hal_display != nullptr); if (hal_display->getGammaCurveCount() > 0) { int32_t slider_value = lv_slider_get_value(slider); @@ -57,9 +57,9 @@ static void onGammaSliderEvent(lv_event_t* event) { static tt::hal::Display* getHalDisplay(lv_obj_t* widget) { auto* lvgl_display = lv_obj_get_display(widget); - tt_assert(lvgl_display != nullptr); + assert(lvgl_display != nullptr); auto* hal_display = (tt::hal::Display*)lv_display_get_user_data(lvgl_display); - tt_assert(hal_display != nullptr); + assert(hal_display != nullptr); return hal_display; } @@ -135,7 +135,7 @@ class DisplayApp : public App { lv_obj_add_event_cb(gamma_slider, onGammaSliderEvent, LV_EVENT_VALUE_CHANGED, nullptr); auto* hal_display = getHalDisplay(parent); - tt_assert(hal_display != nullptr); + assert(hal_display != nullptr); if (!hal_display->supportsBacklightDuty()) { lv_slider_set_value(brightness_slider, 255, LV_ANIM_OFF); diff --git a/Tactility/Source/app/gpio/Gpio.cpp b/Tactility/Source/app/gpio/Gpio.cpp index 0c01be70..cebde4a8 100644 --- a/Tactility/Source/app/gpio/Gpio.cpp +++ b/Tactility/Source/app/gpio/Gpio.cpp @@ -101,7 +101,7 @@ void GpioApp::onTimer(TT_UNUSED std::shared_ptr context) { void GpioApp::startTask() { lock(); - tt_assert(timer == nullptr); + assert(timer == nullptr); timer = std::make_unique( Timer::Type::Periodic, &onTimer @@ -111,7 +111,7 @@ void GpioApp::startTask() { } void GpioApp::stopTask() { - tt_assert(timer); + assert(timer); timer->stop(); timer = nullptr; diff --git a/Tactility/Source/app/i2cscanner/I2cScanner.cpp b/Tactility/Source/app/i2cscanner/I2cScanner.cpp index fc6bb5ab..44f2682f 100644 --- a/Tactility/Source/app/i2cscanner/I2cScanner.cpp +++ b/Tactility/Source/app/i2cscanner/I2cScanner.cpp @@ -160,7 +160,7 @@ void I2cScannerApp::onScanTimerCallback(TT_UNUSED std::shared_ptr context) bool I2cScannerApp::getPort(i2c_port_t* outPort) { if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) { *outPort = this->port; - tt_assert(mutex.release() == TtStatusOk); + assert(mutex.release() == TtStatusOk); return true; } else { TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "getPort"); @@ -171,7 +171,7 @@ bool I2cScannerApp::getPort(i2c_port_t* outPort) { bool I2cScannerApp::addAddressToList(uint8_t address) { if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) { scannedAddresses.push_back(address); - tt_assert(mutex.release() == TtStatusOk); + assert(mutex.release() == TtStatusOk); return true; } else { TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "addAddressToList"); @@ -257,7 +257,7 @@ void I2cScannerApp::startScanning() { } void I2cScannerApp::stopScanning() { if (mutex.acquire(250 / portTICK_PERIOD_MS) == TtStatusOk) { - tt_assert(scanTimer != nullptr); + assert(scanTimer != nullptr); scanState = ScanStateStopped; tt_check(mutex.release() == TtStatusOk); } else { diff --git a/Tactility/Source/app/inputdialog/InputDialog.cpp b/Tactility/Source/app/inputdialog/InputDialog.cpp index 58453a60..bfee2691 100644 --- a/Tactility/Source/app/inputdialog/InputDialog.cpp +++ b/Tactility/Source/app/inputdialog/InputDialog.cpp @@ -57,7 +57,7 @@ private: static void onButtonClickedCallback(lv_event_t* e) { auto appContext = service::loader::getCurrentAppContext(); - tt_assert(appContext != nullptr); + assert(appContext != nullptr); auto app = std::static_pointer_cast(appContext->getApp()); app->onButtonClicked(e); } diff --git a/Tactility/Source/app/selectiondialog/SelectionDialog.cpp b/Tactility/Source/app/selectiondialog/SelectionDialog.cpp index f3e0e8b7..cd6caf90 100644 --- a/Tactility/Source/app/selectiondialog/SelectionDialog.cpp +++ b/Tactility/Source/app/selectiondialog/SelectionDialog.cpp @@ -47,7 +47,7 @@ private: static void onListItemSelectedCallback(lv_event_t* e) { auto appContext = service::loader::getCurrentAppContext(); - tt_assert(appContext != nullptr); + assert(appContext != nullptr); auto app = std::static_pointer_cast(appContext->getApp()); app->onListItemSelected(e); } diff --git a/Tactility/Source/lvgl/Init.cpp b/Tactility/Source/lvgl/Init.cpp index eac0d536..a0a934e5 100644 --- a/Tactility/Source/lvgl/Init.cpp +++ b/Tactility/Source/lvgl/Init.cpp @@ -21,7 +21,7 @@ bool initDisplay(const hal::Configuration& config) { } lv_display_t* lvgl_display = display->getLvglDisplay(); - tt_assert(lvgl_display); + assert(lvgl_display); if (display->supportsBacklightDuty()) { display->setBacklightDuty(0); @@ -30,7 +30,7 @@ bool initDisplay(const hal::Configuration& config) { void* existing_display_user_data = lv_display_get_user_data(lvgl_display); // esp_lvgl_port users user_data by default, so we have to modify the source // this is a check for when we upgrade esp_lvgl_port and forget to modify it again - tt_assert(existing_display_user_data == nullptr); + assert(existing_display_user_data == nullptr); lv_display_set_user_data(lvgl_display, display); lv_display_rotation_t rotation = app::display::getRotation(); @@ -43,8 +43,8 @@ bool initDisplay(const hal::Configuration& config) { bool initTouch(hal::Display* display, hal::Touch* touch) { TT_LOG_I(TAG, "Touch init"); - tt_assert(display); - tt_assert(touch); + assert(display); + assert(touch); if (touch->start(display->getLvglDisplay())) { return true; } else { @@ -55,8 +55,8 @@ bool initTouch(hal::Display* display, hal::Touch* touch) { bool initKeyboard(hal::Display* display, hal::Keyboard* keyboard) { TT_LOG_I(TAG, "Keyboard init"); - tt_assert(display); - tt_assert(keyboard); + assert(display); + assert(keyboard); if (keyboard->isAttached()) { if (keyboard->start(display->getLvglDisplay())) { lv_indev_t* keyboard_indev = keyboard->getLvglIndev(); diff --git a/Tactility/Source/lvgl/LvglDisplay.cpp b/Tactility/Source/lvgl/LvglDisplay.cpp index 8605603f..8da38d85 100644 --- a/Tactility/Source/lvgl/LvglDisplay.cpp +++ b/Tactility/Source/lvgl/LvglDisplay.cpp @@ -5,9 +5,9 @@ namespace tt::lvgl { hal::Display* getDisplay() { auto* lvgl_display = lv_display_get_default(); - tt_assert(lvgl_display != nullptr); + assert(lvgl_display != nullptr); auto* hal_display = (tt::hal::Display*)lv_display_get_user_data(lvgl_display); - tt_assert(hal_display != nullptr); + assert(hal_display != nullptr); return hal_display; } diff --git a/Tactility/Source/service/gui/Gui.cpp b/Tactility/Source/service/gui/Gui.cpp index bb71f136..ab3ba0ab 100644 --- a/Tactility/Source/service/gui/Gui.cpp +++ b/Tactility/Source/service/gui/Gui.cpp @@ -66,7 +66,7 @@ Gui* gui_alloc() { } void gui_free(Gui* instance) { - tt_assert(instance != nullptr); + assert(instance != nullptr); delete instance->thread; lv_group_delete(instance->keyboardGroup); @@ -78,17 +78,17 @@ void gui_free(Gui* instance) { } void lock() { - tt_assert(gui); - tt_check(gui->mutex.acquire(configTICK_RATE_HZ) == TtStatusOk); + assert(gui); + tt_check(gui->mutex.lock(configTICK_RATE_HZ)); } void unlock() { - tt_assert(gui); - tt_check(gui->mutex.release() == TtStatusOk); + assert(gui); + tt_check(gui->mutex.unlock()); } void requestDraw() { - tt_assert(gui); + assert(gui); ThreadId thread_id = gui->thread->getId(); thread_flags_set(thread_id, GUI_THREAD_FLAG_DRAW); } @@ -147,7 +147,7 @@ class GuiService : public Service { public: void onStart(TT_UNUSED ServiceContext& service) override { - tt_assert(gui == nullptr); + assert(gui == nullptr); gui = gui_alloc(); gui->thread->setPriority(THREAD_PRIORITY_SERVICE); @@ -155,7 +155,7 @@ public: } void onStop(TT_UNUSED ServiceContext& service) override { - tt_assert(gui != nullptr); + assert(gui != nullptr); lock(); ThreadId thread_id = gui->thread->getId(); diff --git a/Tactility/Source/service/gui/GuiDraw.cpp b/Tactility/Source/service/gui/GuiDraw.cpp index c5302ec8..f6af3d3c 100644 --- a/Tactility/Source/service/gui/GuiDraw.cpp +++ b/Tactility/Source/service/gui/GuiDraw.cpp @@ -27,7 +27,7 @@ static lv_obj_t* createAppViews(Gui* gui, lv_obj_t* parent) { } void redraw(Gui* gui) { - tt_assert(gui); + assert(gui); // Lock GUI and LVGL lock(); diff --git a/Tactility/Source/service/loader/Loader.cpp b/Tactility/Source/service/loader/Loader.cpp index 786f3a95..c3cec50a 100644 --- a/Tactility/Source/service/loader/Loader.cpp +++ b/Tactility/Source/service/loader/Loader.cpp @@ -44,14 +44,14 @@ static Loader* loader_alloc() { } static void loader_free() { - tt_assert(loader_singleton != nullptr); + assert(loader_singleton != nullptr); delete loader_singleton; loader_singleton = nullptr; } void startApp(const std::string& id, std::shared_ptr parameters) { TT_LOG_I(TAG, "Start app %s", id.c_str()); - tt_assert(loader_singleton); + assert(loader_singleton); auto message = std::make_shared(id, std::move(parameters)); loader_singleton->dispatcherThread->dispatch(onStartAppMessage, message); } @@ -63,7 +63,7 @@ void stopApp() { } std::shared_ptr _Nullable getCurrentAppContext() { - tt_assert(loader_singleton); + assert(loader_singleton); if (loader_singleton->mutex.lock(10 / portTICK_PERIOD_MS)) { auto app = loader_singleton->appStack.top(); loader_singleton->mutex.unlock(); @@ -79,7 +79,7 @@ std::shared_ptr _Nullable getCurrentApp() { } std::shared_ptr getPubsub() { - tt_assert(loader_singleton); + assert(loader_singleton); // it's safe to return pubsub without locking // because it's never freed and loader is never exited // also the loader instance cannot be obtained until the pubsub is created @@ -256,7 +256,7 @@ static void stopAppInternal() { // If there's a previous app, resume it if (!loader_singleton->appStack.empty()) { instance_to_resume = loader_singleton->appStack.top(); - tt_assert(instance_to_resume); + assert(instance_to_resume); transitionAppToState(instance_to_resume, app::StateShowing); } diff --git a/TactilityC/Source/tt_app_manifest.cpp b/TactilityC/Source/tt_app_manifest.cpp index 96fadbdf..0be25b17 100644 --- a/TactilityC/Source/tt_app_manifest.cpp +++ b/TactilityC/Source/tt_app_manifest.cpp @@ -12,7 +12,7 @@ void tt_app_register( const ExternalAppManifest* manifest ) { #ifdef ESP_PLATFORM - tt_assert((manifest->createData == nullptr) == (manifest->destroyData == nullptr)); + assert((manifest->createData == nullptr) == (manifest->destroyData == nullptr)); tt::app::setElfAppManifest( manifest->name, manifest->icon, diff --git a/TactilityCore/Source/Check.h b/TactilityCore/Source/Check.h index e347f0a7..ceaddc98 100644 --- a/TactilityCore/Source/Check.h +++ b/TactilityCore/Source/Check.h @@ -1,7 +1,7 @@ /** * @file check.h * - * Tactility crash and assert functions. + * Tactility crash and check functions. * * The main problem with crashing is that you can't do anything without disturbing registers, * and if you disturb registers, you won't be able to see the correct register values in the debugger. @@ -65,30 +65,3 @@ namespace tt { */ #define tt_check(x, ...) if (!(x)) { TT_LOG_E("check", "Failed: %s", #x); tt::_crash(); } - -/** Only in debug build: Assert condition and crash if assert failed */ -#ifdef TT_DEBUG -#define tt_assert_internal(__e, __m) \ - do { \ - if (!(__e)) { \ - TT_LOG_E("assert", "%s", #__e); \ - if (__m) { \ - __tt_crash(#__m); \ - } else { \ - __tt_crash(""); \ - } \ - } \ - } while (0) -#else -#define __tt_assert(__e, __m) \ - do { \ - ((void)(__e)); \ - ((void)(__m)); \ - } while (0) -#endif - -/** Assert condition and crash if failed - * @warning only will do check if firmware compiled in debug mode - * @param[in] condition to check - */ -#define tt_assert(expression) assert(expression) diff --git a/TactilityCore/Source/EventFlag.cpp b/TactilityCore/Source/EventFlag.cpp index da0058d5..dc991d6b 100644 --- a/TactilityCore/Source/EventFlag.cpp +++ b/TactilityCore/Source/EventFlag.cpp @@ -9,19 +9,19 @@ namespace tt { EventFlag::EventFlag() { - tt_assert(!TT_IS_IRQ_MODE()); + assert(!TT_IS_IRQ_MODE()); handle = xEventGroupCreate(); tt_check(handle); } EventFlag::~EventFlag() { - tt_assert(!TT_IS_IRQ_MODE()); + assert(!TT_IS_IRQ_MODE()); vEventGroupDelete(handle); } uint32_t EventFlag::set(uint32_t flags) const { - tt_assert(handle); - tt_assert((flags & TT_EVENT_FLAG_INVALID_BITS) == 0U); + assert(handle); + assert((flags & TT_EVENT_FLAG_INVALID_BITS) == 0U); uint32_t rflags; BaseType_t yield; @@ -43,7 +43,7 @@ uint32_t EventFlag::set(uint32_t flags) const { } uint32_t EventFlag::clear(uint32_t flags) const { - tt_assert((flags & TT_EVENT_FLAG_INVALID_BITS) == 0U); + assert((flags & TT_EVENT_FLAG_INVALID_BITS) == 0U); uint32_t rflags; @@ -84,8 +84,8 @@ uint32_t EventFlag::wait( uint32_t options, uint32_t timeout ) const { - tt_assert(!TT_IS_IRQ_MODE()); - tt_assert((flags & TT_EVENT_FLAG_INVALID_BITS) == 0U); + assert(!TT_IS_IRQ_MODE()); + assert((flags & TT_EVENT_FLAG_INVALID_BITS) == 0U); BaseType_t wait_all; BaseType_t exit_clear; diff --git a/TactilityCore/Source/MessageQueue.cpp b/TactilityCore/Source/MessageQueue.cpp index 505bef12..369a3a48 100644 --- a/TactilityCore/Source/MessageQueue.cpp +++ b/TactilityCore/Source/MessageQueue.cpp @@ -5,13 +5,13 @@ namespace tt { MessageQueue::MessageQueue(uint32_t capacity, uint32_t msg_size) { - tt_assert(!TT_IS_ISR() && (capacity > 0U) && (msg_size > 0U)); + assert(!TT_IS_ISR() && (capacity > 0U) && (msg_size > 0U)); queue_handle = xQueueCreate(capacity, msg_size); tt_check(queue_handle); } MessageQueue::~MessageQueue() { - tt_assert(!TT_IS_ISR()); + assert(!TT_IS_ISR()); vQueueDelete(queue_handle); } diff --git a/TactilityCore/Source/Mutex.cpp b/TactilityCore/Source/Mutex.cpp index da2a06bc..d2c7b191 100644 --- a/TactilityCore/Source/Mutex.cpp +++ b/TactilityCore/Source/Mutex.cpp @@ -35,18 +35,18 @@ Mutex::Mutex(Type type) : type(type) { tt_crash("Mutex type unknown/corrupted"); } - tt_assert(semaphore != nullptr); + assert(semaphore != nullptr); } Mutex::~Mutex() { - tt_assert(!TT_IS_IRQ_MODE()); + assert(!TT_IS_IRQ_MODE()); vSemaphoreDelete(semaphore); semaphore = nullptr; // If the mutex is used after release, this might help debugging } TtStatus Mutex::acquire(TickType_t timeout) const { - tt_assert(!TT_IS_IRQ_MODE()); - tt_assert(semaphore != nullptr); + assert(!TT_IS_IRQ_MODE()); + assert(semaphore != nullptr); tt_mutex_info(mutex, "acquire"); @@ -78,7 +78,7 @@ TtStatus Mutex::acquire(TickType_t timeout) const { TtStatus Mutex::release() const { assert(!TT_IS_IRQ_MODE()); - tt_assert(semaphore); + assert(semaphore); tt_mutex_info(mutex, "release"); switch (type) { @@ -101,8 +101,8 @@ TtStatus Mutex::release() const { } ThreadId Mutex::getOwner() const { - tt_assert(!TT_IS_IRQ_MODE()); - tt_assert(semaphore); + assert(!TT_IS_IRQ_MODE()); + assert(semaphore); return (ThreadId)xSemaphoreGetMutexHolder(semaphore); } diff --git a/TactilityCore/Source/Pubsub.cpp b/TactilityCore/Source/Pubsub.cpp index 62f83072..31869eeb 100644 --- a/TactilityCore/Source/Pubsub.cpp +++ b/TactilityCore/Source/Pubsub.cpp @@ -20,8 +20,8 @@ PubSubSubscription* tt_pubsub_subscribe(std::shared_ptr pubsub, PubSubCa } void tt_pubsub_unsubscribe(std::shared_ptr pubsub, PubSubSubscription* pubsub_subscription) { - tt_assert(pubsub); - tt_assert(pubsub_subscription); + assert(pubsub); + assert(pubsub_subscription); tt_check(pubsub->mutex.acquire(TtWaitForever) == TtStatusOk); bool result = false; diff --git a/TactilityCore/Source/Semaphore.cpp b/TactilityCore/Source/Semaphore.cpp index f54a6624..2c306585 100644 --- a/TactilityCore/Source/Semaphore.cpp +++ b/TactilityCore/Source/Semaphore.cpp @@ -5,8 +5,8 @@ namespace tt { Semaphore::Semaphore(uint32_t maxCount, uint32_t initialCount) { - tt_assert(!TT_IS_IRQ_MODE()); - tt_assert((maxCount > 0U) && (initialCount <= maxCount)); + assert(!TT_IS_IRQ_MODE()); + assert((maxCount > 0U) && (initialCount <= maxCount)); if (maxCount == 1U) { handle = xSemaphoreCreateBinary(); @@ -24,7 +24,7 @@ Semaphore::Semaphore(uint32_t maxCount, uint32_t initialCount) { } Semaphore::~Semaphore() { - tt_assert(!TT_IS_IRQ_MODE()); + assert(!TT_IS_IRQ_MODE()); vSemaphoreDelete(handle); } diff --git a/TactilityCore/Source/StreamBuffer.cpp b/TactilityCore/Source/StreamBuffer.cpp index 47acde64..66fec595 100644 --- a/TactilityCore/Source/StreamBuffer.cpp +++ b/TactilityCore/Source/StreamBuffer.cpp @@ -7,7 +7,7 @@ namespace tt { StreamBuffer::StreamBuffer(size_t size, size_t triggerLevel) { - tt_assert(size != 0); + assert(size != 0); handle = xStreamBufferCreate(size, triggerLevel); tt_check(handle); }; diff --git a/TactilityCore/Source/Thread.cpp b/TactilityCore/Source/Thread.cpp index 06c06c9a..1f766a70 100644 --- a/TactilityCore/Source/Thread.cpp +++ b/TactilityCore/Source/Thread.cpp @@ -42,17 +42,17 @@ __attribute__((__noreturn__)) void thread_catch() { //-V1082 static void thread_body(void* context) { - tt_assert(context); + assert(context); auto* data = static_cast(context); // Store thread data instance to thread local storage - tt_assert(pvTaskGetThreadLocalStoragePointer(nullptr, 0) == nullptr); + assert(pvTaskGetThreadLocalStoragePointer(nullptr, 0) == nullptr); vTaskSetThreadLocalStoragePointer(nullptr, 0, data->thread); - tt_assert(data->state == Thread::State::Starting); + assert(data->state == Thread::State::Starting); setState(data, Thread::State::Running); data->callbackResult = data->callback(data->callbackContext); - tt_assert(data->state == Thread::State::Running); + assert(data->state == Thread::State::Running); setState(data, Thread::State::Stopped); @@ -102,36 +102,36 @@ Thread::Thread( Thread::~Thread() { // Ensure that use join before free - tt_assert(data.state == State::Stopped); - tt_assert(data.taskHandle == nullptr); + assert(data.state == State::Stopped); + assert(data.taskHandle == nullptr); } void Thread::setName(const std::string& newName) { - tt_assert(data.state == State::Stopped); + assert(data.state == State::Stopped); data.name = newName; } void Thread::setStackSize(size_t stackSize) { - tt_assert(data.state == State::Stopped); - tt_assert(stackSize % 4 == 0); + assert(data.state == State::Stopped); + assert(stackSize % 4 == 0); data.stackSize = stackSize; } void Thread::setCallback(Callback callback, _Nullable void* callbackContext) { - tt_assert(data.state == State::Stopped); + assert(data.state == State::Stopped); data.callback = callback; data.callbackContext = callbackContext; } void Thread::setPriority(Priority priority) { - tt_assert(data.state == State::Stopped); + assert(data.state == State::Stopped); data.priority = priority; } void Thread::setStateCallback(StateCallback callback, _Nullable void* callbackContext) { - tt_assert(data.state == State::Stopped); + assert(data.state == State::Stopped); data.stateCallback = callback; data.stateCallbackContext = callbackContext; } @@ -141,9 +141,9 @@ Thread::State Thread::getState() const { } void Thread::start() { - tt_assert(data.callback); - tt_assert(data.state == State::Stopped); - tt_assert(data.stackSize > 0U && data.stackSize < (UINT16_MAX * sizeof(StackType_t))); + assert(data.callback); + assert(data.state == State::Stopped); + assert(data.stackSize > 0U && data.stackSize < (UINT16_MAX * sizeof(StackType_t))); setState(&data, State::Starting); @@ -210,7 +210,7 @@ ThreadId Thread::getId() const { } int32_t Thread::getReturnCode() const { - tt_assert(data.state == State::Stopped); + assert(data.state == State::Stopped); return data.callbackResult; } @@ -232,7 +232,7 @@ Thread::Priority thread_get_current_priority() { } void thread_yield() { - tt_assert(!TT_IS_IRQ_MODE()); + assert(!TT_IS_IRQ_MODE()); taskYIELD(); } diff --git a/TactilityCore/Source/Timer.cpp b/TactilityCore/Source/Timer.cpp index c8b7bc7c..997a8b2e 100644 --- a/TactilityCore/Source/Timer.cpp +++ b/TactilityCore/Source/Timer.cpp @@ -15,7 +15,7 @@ static void timer_callback(TimerHandle_t hTimer) { } Timer::Timer(Type type, Callback callback, std::shared_ptr callbackContext) { - tt_assert((!TT_IS_ISR()) && (callback != nullptr)); + assert((!TT_IS_ISR()) && (callback != nullptr)); this->callback = callback; this->callbackContext = std::move(callbackContext); @@ -28,39 +28,39 @@ Timer::Timer(Type type, Callback callback, std::shared_ptr callbackContext } this->timerHandle = xTimerCreate(nullptr, portMAX_DELAY, (BaseType_t)reload, this, timer_callback); - tt_assert(this->timerHandle); + assert(this->timerHandle); } Timer::~Timer() { - tt_assert(!TT_IS_ISR()); + assert(!TT_IS_ISR()); tt_check(xTimerDelete(timerHandle, portMAX_DELAY) == pdPASS); } bool Timer::start(TickType_t interval) { - tt_assert(!TT_IS_ISR()); - tt_assert(interval < portMAX_DELAY); + assert(!TT_IS_ISR()); + assert(interval < portMAX_DELAY); return xTimerChangePeriod(timerHandle, interval, portMAX_DELAY) == pdPASS; } bool Timer::restart(TickType_t interval) { - tt_assert(!TT_IS_ISR()); - tt_assert(interval < portMAX_DELAY); + assert(!TT_IS_ISR()); + assert(interval < portMAX_DELAY); return xTimerChangePeriod(timerHandle, interval, portMAX_DELAY) == pdPASS && xTimerReset(timerHandle, portMAX_DELAY) == pdPASS; } bool Timer::stop() { - tt_assert(!TT_IS_ISR()); + assert(!TT_IS_ISR()); return xTimerStop(timerHandle, portMAX_DELAY) == pdPASS; } bool Timer::isRunning() { - tt_assert(!TT_IS_ISR()); + assert(!TT_IS_ISR()); return xTimerIsTimerActive(timerHandle) == pdTRUE; } TickType_t Timer::getExpireTime() { - tt_assert(!TT_IS_ISR()); + assert(!TT_IS_ISR()); return xTimerGetExpiryTime(timerHandle); } @@ -74,10 +74,10 @@ bool Timer::setPendingCallback(PendingCallback callback, void* callbackContext, } void Timer::setThreadPriority(Thread::Priority priority) { - tt_assert(!TT_IS_ISR()); + assert(!TT_IS_ISR()); TaskHandle_t task_handle = xTimerGetTimerDaemonTaskHandle(); - tt_assert(task_handle); // Don't call this method before timer task start + assert(task_handle); // Don't call this method before timer task start vTaskPrioritySet(task_handle, static_cast(priority)); } diff --git a/TactilityCore/Source/kernel/Kernel.cpp b/TactilityCore/Source/kernel/Kernel.cpp index e5180be1..75180237 100644 --- a/TactilityCore/Source/kernel/Kernel.cpp +++ b/TactilityCore/Source/kernel/Kernel.cpp @@ -17,7 +17,7 @@ bool isRunning() { } int32_t lock() { - tt_assert(!TT_IS_ISR()); + assert(!TT_IS_ISR()); int32_t lock; @@ -42,7 +42,7 @@ int32_t lock() { } int32_t unlock() { - tt_assert(!TT_IS_ISR()); + assert(!TT_IS_ISR()); int32_t lock; @@ -72,7 +72,7 @@ int32_t unlock() { } int32_t restoreLock(int32_t lock) { - tt_assert(!TT_IS_ISR()); + assert(!TT_IS_ISR()); switch (xTaskGetSchedulerState()) { case taskSCHEDULER_SUSPENDED: @@ -108,7 +108,7 @@ uint32_t getTickFrequency() { } void delayTicks(TickType_t ticks) { - tt_assert(!TT_IS_ISR()); + assert(!TT_IS_ISR()); if (ticks == 0U) { taskYIELD(); } else { @@ -117,7 +117,7 @@ void delayTicks(TickType_t ticks) { } TtStatus delayUntilTick(TickType_t tick) { - tt_assert(!TT_IS_ISR()); + assert(!TT_IS_ISR()); TickType_t tcnt, delay; TtStatus stat; diff --git a/TactilityHeadless/Source/service/sdcard/Sdcard.cpp b/TactilityHeadless/Source/service/sdcard/Sdcard.cpp index 7e27c979..59c6e72f 100644 --- a/TactilityHeadless/Source/service/sdcard/Sdcard.cpp +++ b/TactilityHeadless/Source/service/sdcard/Sdcard.cpp @@ -29,7 +29,7 @@ private: void update() { auto sdcard = tt::hal::getConfiguration()->sdcard; - tt_assert(sdcard); + assert(sdcard); if (lock(50)) { auto new_state = sdcard->getState(); diff --git a/TactilityHeadless/Source/service/wifi/WifiEsp.cpp b/TactilityHeadless/Source/service/wifi/WifiEsp.cpp index 8ddac1bc..a5f79dcf 100644 --- a/TactilityHeadless/Source/service/wifi/WifiEsp.cpp +++ b/TactilityHeadless/Source/service/wifi/WifiEsp.cpp @@ -312,7 +312,7 @@ bool isConnectionSecure() { } int getRssi() { - tt_assert(wifi_singleton); + assert(wifi_singleton); static int rssi = 0; if (esp_wifi_sta_get_rssi(&rssi) == ESP_OK) { return rssi; @@ -326,7 +326,7 @@ int getRssi() { static void scan_list_alloc(std::shared_ptr wifi) { auto lockable = wifi->dataMutex.scoped(); if (lockable->lock(TtWaitForever)) { - tt_assert(wifi->scan_list == nullptr); + assert(wifi->scan_list == nullptr); wifi->scan_list = static_cast(malloc(sizeof(wifi_ap_record_t) * wifi->scan_list_limit)); wifi->scan_list_count = 0; } @@ -344,7 +344,7 @@ static void scan_list_alloc_safely(std::shared_ptr wifi) { static void scan_list_free(std::shared_ptr wifi) { auto lockable = wifi->dataMutex.scoped(); if (lockable->lock(TtWaitForever)) { - tt_assert(wifi->scan_list != nullptr); + assert(wifi->scan_list != nullptr); free(wifi->scan_list); wifi->scan_list = nullptr; wifi->scan_list_count = 0; @@ -643,7 +643,7 @@ static void dispatchDisable(std::shared_ptr context) { TT_LOG_E(TAG, "Failed to deinit"); } - tt_assert(wifi->netif != nullptr); + assert(wifi->netif != nullptr); esp_netif_destroy(wifi->netif); wifi->netif = nullptr; wifi->setScanActive(false); @@ -941,7 +941,7 @@ class WifiService final : public Service { public: void onStart(ServiceContext& service) override { - tt_assert(wifi_singleton == nullptr); + assert(wifi_singleton == nullptr); wifi_singleton = std::make_shared(); wifi_singleton->autoConnectTimer = std::make_unique(Timer::Type::Periodic, onAutoConnectTimer, wifi_singleton); @@ -956,7 +956,7 @@ public: void onStop(ServiceContext& service) override { auto wifi = wifi_singleton; - tt_assert(wifi != nullptr); + assert(wifi != nullptr); RadioState state = wifi->getRadioState(); if (state != RadioState::Off) { diff --git a/TactilityHeadless/Source/service/wifi/WifiMock.cpp b/TactilityHeadless/Source/service/wifi/WifiMock.cpp index 54f5da88..0a3edc0a 100644 --- a/TactilityHeadless/Source/service/wifi/WifiMock.cpp +++ b/TactilityHeadless/Source/service/wifi/WifiMock.cpp @@ -44,7 +44,7 @@ static void publish_event_simple(Wifi* wifi, EventType type) { // region Public functions std::shared_ptr getPubsub() { - tt_assert(wifi); + assert(wifi); return wifi->pubsub; } @@ -57,26 +57,26 @@ std::string getConnectionTarget() { } void scan() { - tt_assert(wifi); + assert(wifi); wifi->scan_active = false; // TODO: enable and then later disable automatically } bool isScanning() { - tt_assert(wifi); + assert(wifi); return wifi->scan_active; } void connect(const settings::WifiApSettings* ap, bool remember) { - tt_assert(wifi); + assert(wifi); // TODO: implement } void disconnect() { - tt_assert(wifi); + assert(wifi); } void setScanRecords(uint16_t records) { - tt_assert(wifi); + assert(wifi); // TODO: implement } @@ -114,7 +114,7 @@ std::vector getScanResults() { } void setEnabled(bool enabled) { - tt_assert(wifi != nullptr); + assert(wifi != nullptr); if (enabled) { wifi->radio_state = RadioState::On; wifi->secure_connection = true;