mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
Fixes and improvements (#185)
- unPhone improvements related to power and boot (add boot count logging) - Cleanup of Mutex acquire/release - Removed `tt_assert()` in favour of `assert()` - Fix sim build (likely failed due to migration of GitHub Actions to Ubuntu 24.04)
This commit is contained in:
parent
3be251d8fb
commit
d86dc40472
5
.github/workflows/build-firmware.yml
vendored
5
.github/workflows/build-firmware.yml
vendored
@ -1,5 +1,8 @@
|
|||||||
name: Build Firmware
|
name: Build Firmware
|
||||||
on: [push]
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
|
||||||
permissions: read-all
|
permissions: read-all
|
||||||
|
|
||||||
|
|||||||
5
.github/workflows/build-sdk.yml
vendored
5
.github/workflows/build-sdk.yml
vendored
@ -1,5 +1,8 @@
|
|||||||
name: Build SDK
|
name: Build SDK
|
||||||
on: [push]
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
|
||||||
permissions: read-all
|
permissions: read-all
|
||||||
|
|
||||||
|
|||||||
7
.github/workflows/build-simulator.yml
vendored
7
.github/workflows/build-simulator.yml
vendored
@ -1,9 +1,12 @@
|
|||||||
# Disabled because of issue: https://github.com/libsdl-org/setup-sdl/issues/23
|
# Disabled because of issue: https://github.com/libsdl-org/setup-sdl/issues/23
|
||||||
name: Build Simulator
|
name: Build Simulator
|
||||||
on: [push]
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
jobs:
|
jobs:
|
||||||
Build-Simulator-Linux:
|
Build-Simulator-Linux:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: "Build"
|
- name: "Build"
|
||||||
|
|||||||
5
.github/workflows/tests.yml
vendored
5
.github/workflows/tests.yml
vendored
@ -1,5 +1,8 @@
|
|||||||
name: Tests
|
name: Tests
|
||||||
on: [push]
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
jobs:
|
jobs:
|
||||||
Run:
|
Run:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@ -140,7 +140,7 @@ bool YellowDisplay::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool YellowDisplay::stop() {
|
bool YellowDisplay::stop() {
|
||||||
tt_assert(displayHandle != nullptr);
|
assert(displayHandle != nullptr);
|
||||||
|
|
||||||
lvgl_port_remove_disp(displayHandle);
|
lvgl_port_remove_disp(displayHandle);
|
||||||
|
|
||||||
|
|||||||
@ -159,7 +159,7 @@ bool TdeckDisplay::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TdeckDisplay::stop() {
|
bool TdeckDisplay::stop() {
|
||||||
tt_assert(displayHandle != nullptr);
|
assert(displayHandle != nullptr);
|
||||||
|
|
||||||
lvgl_port_remove_disp(displayHandle);
|
lvgl_port_remove_disp(displayHandle);
|
||||||
|
|
||||||
|
|||||||
@ -102,7 +102,7 @@ bool Core2Display::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Core2Display::stop() {
|
bool Core2Display::stop() {
|
||||||
tt_assert(displayHandle != nullptr);
|
assert(displayHandle != nullptr);
|
||||||
|
|
||||||
lvgl_port_remove_disp(displayHandle);
|
lvgl_port_remove_disp(displayHandle);
|
||||||
|
|
||||||
|
|||||||
@ -119,7 +119,7 @@ bool CoreS3Display::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CoreS3Display::stop() {
|
bool CoreS3Display::stop() {
|
||||||
tt_assert(displayHandle != nullptr);
|
assert(displayHandle != nullptr);
|
||||||
|
|
||||||
lvgl_port_remove_disp(displayHandle);
|
lvgl_port_remove_disp(displayHandle);
|
||||||
|
|
||||||
|
|||||||
@ -69,7 +69,7 @@ void lvgl_task_start() {
|
|||||||
nullptr
|
nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
tt_assert(task_result == pdTRUE);
|
assert(task_result == pdTRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
lv_disp_t* displayHandle = nullptr;
|
lv_disp_t* displayHandle = nullptr;
|
||||||
|
|||||||
@ -33,7 +33,7 @@ void freertosMain() {
|
|||||||
nullptr
|
nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
tt_assert(task_result == pdTRUE);
|
assert(task_result == pdTRUE);
|
||||||
|
|
||||||
// Blocks forever
|
// Blocks forever
|
||||||
vTaskStartScheduler();
|
vTaskStartScheduler();
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#include "Preferences.h"
|
||||||
#include "TactilityCore.h"
|
#include "TactilityCore.h"
|
||||||
#include "UnPhoneFeatures.h"
|
#include "UnPhoneFeatures.h"
|
||||||
#include <esp_sleep.h>
|
#include <esp_sleep.h>
|
||||||
@ -8,6 +9,55 @@ extern UnPhoneFeatures unPhoneFeatures;
|
|||||||
|
|
||||||
static std::unique_ptr<tt::Thread> powerThread;
|
static std::unique_ptr<tt::Thread> 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 {
|
enum class PowerState {
|
||||||
Initial,
|
Initial,
|
||||||
On,
|
On,
|
||||||
@ -16,6 +66,7 @@ enum class PowerState {
|
|||||||
|
|
||||||
#define DEBUG_POWER_STATES false
|
#define DEBUG_POWER_STATES false
|
||||||
|
|
||||||
|
#if DEBUG_POWER_STATES
|
||||||
/** Helper method to use the buzzer to signal the different power stages */
|
/** Helper method to use the buzzer to signal the different power stages */
|
||||||
static void powerInfoBuzz(uint8_t count) {
|
static void powerInfoBuzz(uint8_t count) {
|
||||||
if (DEBUG_POWER_STATES) {
|
if (DEBUG_POWER_STATES) {
|
||||||
@ -33,6 +84,7 @@ static void powerInfoBuzz(uint8_t count) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void updatePowerSwitch() {
|
static void updatePowerSwitch() {
|
||||||
static PowerState last_state = PowerState::Initial;
|
static PowerState last_state = PowerState::Initial;
|
||||||
@ -46,19 +98,28 @@ static void updatePowerSwitch() {
|
|||||||
if (!unPhoneFeatures.isUsbPowerConnected()) { // and usb unplugged we go into shipping mode
|
if (!unPhoneFeatures.isUsbPowerConnected()) { // and usb unplugged we go into shipping mode
|
||||||
TT_LOG_W(TAG, "Shipping mode until USB connects");
|
TT_LOG_W(TAG, "Shipping mode until USB connects");
|
||||||
|
|
||||||
|
#if DEBUG_POWER_STATES
|
||||||
unPhoneFeatures.setExpanderPower(true);
|
unPhoneFeatures.setExpanderPower(true);
|
||||||
powerInfoBuzz(3);
|
powerInfoBuzz(3);
|
||||||
unPhoneFeatures.setExpanderPower(false);
|
unPhoneFeatures.setExpanderPower(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
unPhoneFeatures.turnPeripheralsOff();
|
unPhoneFeatures.turnPeripheralsOff();
|
||||||
|
|
||||||
|
bootStats.notifyPowerOff();
|
||||||
|
|
||||||
unPhoneFeatures.setShipping(true); // tell BM to stop supplying power until USB connects
|
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.
|
} 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");
|
TT_LOG_W(TAG, "Waiting for USB disconnect to power off");
|
||||||
|
|
||||||
|
#if DEBUG_POWER_STATES
|
||||||
powerInfoBuzz(2);
|
powerInfoBuzz(2);
|
||||||
|
#endif
|
||||||
|
|
||||||
unPhoneFeatures.turnPeripheralsOff();
|
unPhoneFeatures.turnPeripheralsOff();
|
||||||
|
|
||||||
|
bootStats.notifyPowerSleep();
|
||||||
|
|
||||||
// Deep sleep for 1 minute, then awaken to check power state again
|
// Deep sleep for 1 minute, then awaken to check power state again
|
||||||
// GPIO trigger from power switch also awakens the device
|
// GPIO trigger from power switch also awakens the device
|
||||||
unPhoneFeatures.wakeOnPowerSwitch();
|
unPhoneFeatures.wakeOnPowerSwitch();
|
||||||
@ -70,9 +131,9 @@ static void updatePowerSwitch() {
|
|||||||
last_state = PowerState::On;
|
last_state = PowerState::On;
|
||||||
TT_LOG_W(TAG, "Power on");
|
TT_LOG_W(TAG, "Power on");
|
||||||
|
|
||||||
unPhoneFeatures.setShipping(false);
|
#if DEBUG_POWER_STATES
|
||||||
unPhoneFeatures.setExpanderPower(true);
|
|
||||||
powerInfoBuzz(1);
|
powerInfoBuzz(1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,6 +156,11 @@ static void startPowerSwitchThread() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool unPhonePowerOn() {
|
static bool unPhonePowerOn() {
|
||||||
|
// Print early, in case of early crash (info will be from previous boot)
|
||||||
|
bootStats.printInfo();
|
||||||
|
|
||||||
|
bootStats.notifyBootStart();
|
||||||
|
|
||||||
if (!unPhoneFeatures.init()) {
|
if (!unPhoneFeatures.init()) {
|
||||||
TT_LOG_E(TAG, "UnPhoneFeatures init failed");
|
TT_LOG_E(TAG, "UnPhoneFeatures init failed");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -283,13 +283,11 @@ bool UnPhoneFeatures::setShipping(bool on) const {
|
|||||||
if (on) {
|
if (on) {
|
||||||
TT_LOG_W(TAG, "setShipping: on");
|
TT_LOG_W(TAG, "setShipping: on");
|
||||||
batteryManagement.setWatchDogTimer(Bq24295::WatchDogTimer::Disabled);
|
batteryManagement.setWatchDogTimer(Bq24295::WatchDogTimer::Disabled);
|
||||||
// Set bit 5 to disable
|
batteryManagement.setBatFetOn(false);
|
||||||
batteryManagement.setOperationControlBitOn(1 << 5);
|
|
||||||
} else {
|
} else {
|
||||||
TT_LOG_W(TAG, "setShipping: off");
|
TT_LOG_W(TAG, "setShipping: off");
|
||||||
batteryManagement.setWatchDogTimer(Bq24295::WatchDogTimer::Enabled40s);
|
batteryManagement.setWatchDogTimer(Bq24295::WatchDogTimer::Enabled40s);
|
||||||
// Clear bit 5 to enable
|
batteryManagement.setBatFetOn(true);
|
||||||
batteryManagement.setOperationControlBitOff(1 << 5);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,18 +60,16 @@ bool Bq24295::setWatchDogTimer(WatchDogTimer in) const {
|
|||||||
|
|
||||||
// endregoin
|
// endregoin
|
||||||
|
|
||||||
// region Operation Control
|
// region Operation Control (REG07)
|
||||||
|
|
||||||
bool Bq24295::getOperationControl(uint8_t value) const {
|
bool Bq24295::setBatFetOn(bool on) const {
|
||||||
return readRegister8(registers::OPERATION_CONTROL, value);
|
if (on) {
|
||||||
}
|
// bit 5 low means bat fet is on
|
||||||
|
return bitOff(registers::OPERATION_CONTROL, BIT(5));
|
||||||
bool Bq24295::setOperationControlBitOn(uint8_t mask) const {
|
} else {
|
||||||
return bitOn(registers::OPERATION_CONTROL, mask);
|
// bit 5 high means bat fet is off
|
||||||
}
|
return bitOn(registers::OPERATION_CONTROL, BIT(5));
|
||||||
|
}
|
||||||
bool Bq24295::setOperationControlBitOff(uint8_t mask) const {
|
|
||||||
return bitOff(registers::OPERATION_CONTROL, mask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|||||||
@ -26,9 +26,7 @@ public:
|
|||||||
|
|
||||||
bool isUsbPowerConnected() const;
|
bool isUsbPowerConnected() const;
|
||||||
|
|
||||||
bool getOperationControl(uint8_t value) const;
|
bool setBatFetOn(bool on) const;
|
||||||
bool setOperationControlBitOn(uint8_t mask) const;
|
|
||||||
bool setOperationControlBitOff(uint8_t mask) const;
|
|
||||||
|
|
||||||
bool getStatus(uint8_t& value) const;
|
bool getStatus(uint8_t& value) const;
|
||||||
bool getVersion(uint8_t& value) const;
|
bool getVersion(uint8_t& value) const;
|
||||||
|
|||||||
@ -56,7 +56,7 @@ bool UnPhoneDisplay::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool UnPhoneDisplay::stop() {
|
bool UnPhoneDisplay::stop() {
|
||||||
tt_assert(displayHandle != nullptr);
|
assert(displayHandle != nullptr);
|
||||||
|
|
||||||
lv_display_delete(displayHandle);
|
lv_display_delete(displayHandle);
|
||||||
displayHandle = nullptr;
|
displayHandle = nullptr;
|
||||||
|
|||||||
@ -51,7 +51,7 @@ void getLimit() {
|
|||||||
Preprocessor functions are written in snake-case and prefixed with `tt_`, for example:
|
Preprocessor functions are written in snake-case and prefixed with `tt_`, for example:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
#define tt_assert(x) __tt_assert_internal(x)
|
#define tt_check(x) if (!(x)) { /* .. */ }
|
||||||
```
|
```
|
||||||
|
|
||||||
### Type names
|
### Type names
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
- M5Stack Core only shows 4MB of SPIRAM in use
|
- M5Stack Core only shows 4MB of SPIRAM in use
|
||||||
|
|
||||||
# TODOs
|
# TODOs
|
||||||
|
- Extend unPhone power driver: add charging status, usb connection status, etc.
|
||||||
- Expose app::Paths to TactilityC
|
- Expose app::Paths to TactilityC
|
||||||
- Refactor ServiceManifest into C++ class-based design like the App class
|
- 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!)
|
- Experiment with what happens when using C++ code in an external app (without using standard library!)
|
||||||
|
|||||||
@ -41,7 +41,7 @@ private:
|
|||||||
const std::shared_ptr<app::AppManifest>& manifest
|
const std::shared_ptr<app::AppManifest>& manifest
|
||||||
) {
|
) {
|
||||||
if (manifest->location.isInternal()) {
|
if (manifest->location.isInternal()) {
|
||||||
tt_assert(manifest->createApp != nullptr);
|
assert(manifest->createApp != nullptr);
|
||||||
return manifest->createApp();
|
return manifest->createApp();
|
||||||
} else if (manifest->location.isExternal()) {
|
} else if (manifest->location.isExternal()) {
|
||||||
if (manifest->createApp != nullptr) {
|
if (manifest->createApp != nullptr) {
|
||||||
|
|||||||
@ -135,7 +135,7 @@ static void register_and_start_user_services(const std::vector<const service::Se
|
|||||||
void run(const Configuration& config) {
|
void run(const Configuration& config) {
|
||||||
TT_LOG_D(TAG, "run");
|
TT_LOG_D(TAG, "run");
|
||||||
|
|
||||||
tt_assert(config.hardware);
|
assert(config.hardware);
|
||||||
const hal::Configuration& hardware = *config.hardware;
|
const hal::Configuration& hardware = *config.hardware;
|
||||||
|
|
||||||
// Assign early so starting services can use it
|
// Assign early so starting services can use it
|
||||||
|
|||||||
@ -25,7 +25,7 @@ State AppInstance::getState() const {
|
|||||||
* Consider not exposing bundle, but expose `app_get_bundle_int(key)` methods with locking in it.
|
* Consider not exposing bundle, but expose `app_get_bundle_int(key)` methods with locking in it.
|
||||||
*/
|
*/
|
||||||
const AppManifest& AppInstance::getManifest() const {
|
const AppManifest& AppInstance::getManifest() const {
|
||||||
tt_assert(manifest != nullptr);
|
assert(manifest != nullptr);
|
||||||
return *manifest;
|
return *manifest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ std::shared_ptr<const Bundle> AppInstance::getParameters() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Paths> AppInstance::getPaths() const {
|
std::unique_ptr<Paths> AppInstance::getPaths() const {
|
||||||
tt_assert(manifest != nullptr);
|
assert(manifest != nullptr);
|
||||||
return std::make_unique<AppInstancePaths>(*manifest);
|
return std::make_unique<AppInstancePaths>(*manifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -188,8 +188,8 @@ bool registerElfApp(const std::string& filePath) {
|
|||||||
|
|
||||||
std::shared_ptr<App> createElfApp(const std::shared_ptr<AppManifest>& manifest) {
|
std::shared_ptr<App> createElfApp(const std::shared_ptr<AppManifest>& manifest) {
|
||||||
TT_LOG_I(TAG, "createElfApp");
|
TT_LOG_I(TAG, "createElfApp");
|
||||||
tt_assert(manifest != nullptr);
|
assert(manifest != nullptr);
|
||||||
tt_assert(manifest->location.isExternal());
|
assert(manifest->location.isExternal());
|
||||||
return std::make_shared<ElfApp>(manifest->location.getPath());
|
return std::make_shared<ElfApp>(manifest->location.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,7 @@ private:
|
|||||||
|
|
||||||
static void onButtonClickedCallback(lv_event_t* e) {
|
static void onButtonClickedCallback(lv_event_t* e) {
|
||||||
auto appContext = service::loader::getCurrentAppContext();
|
auto appContext = service::loader::getCurrentAppContext();
|
||||||
tt_assert(appContext != nullptr);
|
assert(appContext != nullptr);
|
||||||
auto app = std::static_pointer_cast<AlertDialogApp>(appContext->getApp());
|
auto app = std::static_pointer_cast<AlertDialogApp>(appContext->getApp());
|
||||||
app->onButtonClicked(e);
|
app->onButtonClicked(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,9 +36,9 @@ private:
|
|||||||
kernel::systemEventPublish(kernel::SystemEvent::BootSplash);
|
kernel::systemEventPublish(kernel::SystemEvent::BootSplash);
|
||||||
|
|
||||||
auto* lvgl_display = lv_display_get_default();
|
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);
|
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()) {
|
if (hal_display->supportsBacklightDuty()) {
|
||||||
int32_t backlight_duty = app::display::getBacklightDuty();
|
int32_t backlight_duty = app::display::getBacklightDuty();
|
||||||
hal_display->setBacklightDuty(backlight_duty);
|
hal_display->setBacklightDuty(backlight_duty);
|
||||||
|
|||||||
@ -24,9 +24,9 @@ static uint8_t gamma = 255;
|
|||||||
static void onBacklightSliderEvent(lv_event_t* event) {
|
static void onBacklightSliderEvent(lv_event_t* event) {
|
||||||
auto* slider = static_cast<lv_obj_t*>(lv_event_get_target(event));
|
auto* slider = static_cast<lv_obj_t*>(lv_event_get_target(event));
|
||||||
auto* lvgl_display = lv_display_get_default();
|
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);
|
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()) {
|
if (hal_display->supportsBacklightDuty()) {
|
||||||
int32_t slider_value = lv_slider_get_value(slider);
|
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) {
|
static void onGammaSliderEvent(lv_event_t* event) {
|
||||||
auto* slider = static_cast<lv_obj_t*>(lv_event_get_target(event));
|
auto* slider = static_cast<lv_obj_t*>(lv_event_get_target(event));
|
||||||
auto* lvgl_display = lv_display_get_default();
|
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);
|
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) {
|
if (hal_display->getGammaCurveCount() > 0) {
|
||||||
int32_t slider_value = lv_slider_get_value(slider);
|
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) {
|
static tt::hal::Display* getHalDisplay(lv_obj_t* widget) {
|
||||||
auto* lvgl_display = lv_obj_get_display(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);
|
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;
|
return hal_display;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ class DisplayApp : public App {
|
|||||||
lv_obj_add_event_cb(gamma_slider, onGammaSliderEvent, LV_EVENT_VALUE_CHANGED, nullptr);
|
lv_obj_add_event_cb(gamma_slider, onGammaSliderEvent, LV_EVENT_VALUE_CHANGED, nullptr);
|
||||||
|
|
||||||
auto* hal_display = getHalDisplay(parent);
|
auto* hal_display = getHalDisplay(parent);
|
||||||
tt_assert(hal_display != nullptr);
|
assert(hal_display != nullptr);
|
||||||
|
|
||||||
if (!hal_display->supportsBacklightDuty()) {
|
if (!hal_display->supportsBacklightDuty()) {
|
||||||
lv_slider_set_value(brightness_slider, 255, LV_ANIM_OFF);
|
lv_slider_set_value(brightness_slider, 255, LV_ANIM_OFF);
|
||||||
|
|||||||
@ -101,7 +101,7 @@ void GpioApp::onTimer(TT_UNUSED std::shared_ptr<void> context) {
|
|||||||
|
|
||||||
void GpioApp::startTask() {
|
void GpioApp::startTask() {
|
||||||
lock();
|
lock();
|
||||||
tt_assert(timer == nullptr);
|
assert(timer == nullptr);
|
||||||
timer = std::make_unique<Timer>(
|
timer = std::make_unique<Timer>(
|
||||||
Timer::Type::Periodic,
|
Timer::Type::Periodic,
|
||||||
&onTimer
|
&onTimer
|
||||||
@ -111,7 +111,7 @@ void GpioApp::startTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GpioApp::stopTask() {
|
void GpioApp::stopTask() {
|
||||||
tt_assert(timer);
|
assert(timer);
|
||||||
|
|
||||||
timer->stop();
|
timer->stop();
|
||||||
timer = nullptr;
|
timer = nullptr;
|
||||||
|
|||||||
@ -160,7 +160,7 @@ void I2cScannerApp::onScanTimerCallback(TT_UNUSED std::shared_ptr<void> context)
|
|||||||
bool I2cScannerApp::getPort(i2c_port_t* outPort) {
|
bool I2cScannerApp::getPort(i2c_port_t* outPort) {
|
||||||
if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) {
|
if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) {
|
||||||
*outPort = this->port;
|
*outPort = this->port;
|
||||||
tt_assert(mutex.release() == TtStatusOk);
|
assert(mutex.release() == TtStatusOk);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "getPort");
|
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) {
|
bool I2cScannerApp::addAddressToList(uint8_t address) {
|
||||||
if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) {
|
if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) {
|
||||||
scannedAddresses.push_back(address);
|
scannedAddresses.push_back(address);
|
||||||
tt_assert(mutex.release() == TtStatusOk);
|
assert(mutex.release() == TtStatusOk);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "addAddressToList");
|
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "addAddressToList");
|
||||||
@ -257,7 +257,7 @@ void I2cScannerApp::startScanning() {
|
|||||||
}
|
}
|
||||||
void I2cScannerApp::stopScanning() {
|
void I2cScannerApp::stopScanning() {
|
||||||
if (mutex.acquire(250 / portTICK_PERIOD_MS) == TtStatusOk) {
|
if (mutex.acquire(250 / portTICK_PERIOD_MS) == TtStatusOk) {
|
||||||
tt_assert(scanTimer != nullptr);
|
assert(scanTimer != nullptr);
|
||||||
scanState = ScanStateStopped;
|
scanState = ScanStateStopped;
|
||||||
tt_check(mutex.release() == TtStatusOk);
|
tt_check(mutex.release() == TtStatusOk);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -57,7 +57,7 @@ private:
|
|||||||
|
|
||||||
static void onButtonClickedCallback(lv_event_t* e) {
|
static void onButtonClickedCallback(lv_event_t* e) {
|
||||||
auto appContext = service::loader::getCurrentAppContext();
|
auto appContext = service::loader::getCurrentAppContext();
|
||||||
tt_assert(appContext != nullptr);
|
assert(appContext != nullptr);
|
||||||
auto app = std::static_pointer_cast<InputDialogApp>(appContext->getApp());
|
auto app = std::static_pointer_cast<InputDialogApp>(appContext->getApp());
|
||||||
app->onButtonClicked(e);
|
app->onButtonClicked(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,7 @@ private:
|
|||||||
|
|
||||||
static void onListItemSelectedCallback(lv_event_t* e) {
|
static void onListItemSelectedCallback(lv_event_t* e) {
|
||||||
auto appContext = service::loader::getCurrentAppContext();
|
auto appContext = service::loader::getCurrentAppContext();
|
||||||
tt_assert(appContext != nullptr);
|
assert(appContext != nullptr);
|
||||||
auto app = std::static_pointer_cast<SelectionDialogApp>(appContext->getApp());
|
auto app = std::static_pointer_cast<SelectionDialogApp>(appContext->getApp());
|
||||||
app->onListItemSelected(e);
|
app->onListItemSelected(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ bool initDisplay(const hal::Configuration& config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lv_display_t* lvgl_display = display->getLvglDisplay();
|
lv_display_t* lvgl_display = display->getLvglDisplay();
|
||||||
tt_assert(lvgl_display);
|
assert(lvgl_display);
|
||||||
|
|
||||||
if (display->supportsBacklightDuty()) {
|
if (display->supportsBacklightDuty()) {
|
||||||
display->setBacklightDuty(0);
|
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);
|
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
|
// 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
|
// 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_set_user_data(lvgl_display, display);
|
||||||
|
|
||||||
lv_display_rotation_t rotation = app::display::getRotation();
|
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) {
|
bool initTouch(hal::Display* display, hal::Touch* touch) {
|
||||||
TT_LOG_I(TAG, "Touch init");
|
TT_LOG_I(TAG, "Touch init");
|
||||||
tt_assert(display);
|
assert(display);
|
||||||
tt_assert(touch);
|
assert(touch);
|
||||||
if (touch->start(display->getLvglDisplay())) {
|
if (touch->start(display->getLvglDisplay())) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -55,8 +55,8 @@ bool initTouch(hal::Display* display, hal::Touch* touch) {
|
|||||||
|
|
||||||
bool initKeyboard(hal::Display* display, hal::Keyboard* keyboard) {
|
bool initKeyboard(hal::Display* display, hal::Keyboard* keyboard) {
|
||||||
TT_LOG_I(TAG, "Keyboard init");
|
TT_LOG_I(TAG, "Keyboard init");
|
||||||
tt_assert(display);
|
assert(display);
|
||||||
tt_assert(keyboard);
|
assert(keyboard);
|
||||||
if (keyboard->isAttached()) {
|
if (keyboard->isAttached()) {
|
||||||
if (keyboard->start(display->getLvglDisplay())) {
|
if (keyboard->start(display->getLvglDisplay())) {
|
||||||
lv_indev_t* keyboard_indev = keyboard->getLvglIndev();
|
lv_indev_t* keyboard_indev = keyboard->getLvglIndev();
|
||||||
|
|||||||
@ -5,9 +5,9 @@ namespace tt::lvgl {
|
|||||||
|
|
||||||
hal::Display* getDisplay() {
|
hal::Display* getDisplay() {
|
||||||
auto* lvgl_display = lv_display_get_default();
|
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);
|
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;
|
return hal_display;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -66,7 +66,7 @@ Gui* gui_alloc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void gui_free(Gui* instance) {
|
void gui_free(Gui* instance) {
|
||||||
tt_assert(instance != nullptr);
|
assert(instance != nullptr);
|
||||||
delete instance->thread;
|
delete instance->thread;
|
||||||
|
|
||||||
lv_group_delete(instance->keyboardGroup);
|
lv_group_delete(instance->keyboardGroup);
|
||||||
@ -78,17 +78,17 @@ void gui_free(Gui* instance) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void lock() {
|
void lock() {
|
||||||
tt_assert(gui);
|
assert(gui);
|
||||||
tt_check(gui->mutex.acquire(configTICK_RATE_HZ) == TtStatusOk);
|
tt_check(gui->mutex.lock(configTICK_RATE_HZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
void unlock() {
|
void unlock() {
|
||||||
tt_assert(gui);
|
assert(gui);
|
||||||
tt_check(gui->mutex.release() == TtStatusOk);
|
tt_check(gui->mutex.unlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
void requestDraw() {
|
void requestDraw() {
|
||||||
tt_assert(gui);
|
assert(gui);
|
||||||
ThreadId thread_id = gui->thread->getId();
|
ThreadId thread_id = gui->thread->getId();
|
||||||
thread_flags_set(thread_id, GUI_THREAD_FLAG_DRAW);
|
thread_flags_set(thread_id, GUI_THREAD_FLAG_DRAW);
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ class GuiService : public Service {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
void onStart(TT_UNUSED ServiceContext& service) override {
|
void onStart(TT_UNUSED ServiceContext& service) override {
|
||||||
tt_assert(gui == nullptr);
|
assert(gui == nullptr);
|
||||||
gui = gui_alloc();
|
gui = gui_alloc();
|
||||||
|
|
||||||
gui->thread->setPriority(THREAD_PRIORITY_SERVICE);
|
gui->thread->setPriority(THREAD_PRIORITY_SERVICE);
|
||||||
@ -155,7 +155,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onStop(TT_UNUSED ServiceContext& service) override {
|
void onStop(TT_UNUSED ServiceContext& service) override {
|
||||||
tt_assert(gui != nullptr);
|
assert(gui != nullptr);
|
||||||
lock();
|
lock();
|
||||||
|
|
||||||
ThreadId thread_id = gui->thread->getId();
|
ThreadId thread_id = gui->thread->getId();
|
||||||
|
|||||||
@ -27,7 +27,7 @@ static lv_obj_t* createAppViews(Gui* gui, lv_obj_t* parent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void redraw(Gui* gui) {
|
void redraw(Gui* gui) {
|
||||||
tt_assert(gui);
|
assert(gui);
|
||||||
|
|
||||||
// Lock GUI and LVGL
|
// Lock GUI and LVGL
|
||||||
lock();
|
lock();
|
||||||
|
|||||||
@ -44,14 +44,14 @@ static Loader* loader_alloc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void loader_free() {
|
static void loader_free() {
|
||||||
tt_assert(loader_singleton != nullptr);
|
assert(loader_singleton != nullptr);
|
||||||
delete loader_singleton;
|
delete loader_singleton;
|
||||||
loader_singleton = nullptr;
|
loader_singleton = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void startApp(const std::string& id, std::shared_ptr<const Bundle> parameters) {
|
void startApp(const std::string& id, std::shared_ptr<const Bundle> parameters) {
|
||||||
TT_LOG_I(TAG, "Start app %s", id.c_str());
|
TT_LOG_I(TAG, "Start app %s", id.c_str());
|
||||||
tt_assert(loader_singleton);
|
assert(loader_singleton);
|
||||||
auto message = std::make_shared<LoaderMessageAppStart>(id, std::move(parameters));
|
auto message = std::make_shared<LoaderMessageAppStart>(id, std::move(parameters));
|
||||||
loader_singleton->dispatcherThread->dispatch(onStartAppMessage, message);
|
loader_singleton->dispatcherThread->dispatch(onStartAppMessage, message);
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ void stopApp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<app::AppContext> _Nullable getCurrentAppContext() {
|
std::shared_ptr<app::AppContext> _Nullable getCurrentAppContext() {
|
||||||
tt_assert(loader_singleton);
|
assert(loader_singleton);
|
||||||
if (loader_singleton->mutex.lock(10 / portTICK_PERIOD_MS)) {
|
if (loader_singleton->mutex.lock(10 / portTICK_PERIOD_MS)) {
|
||||||
auto app = loader_singleton->appStack.top();
|
auto app = loader_singleton->appStack.top();
|
||||||
loader_singleton->mutex.unlock();
|
loader_singleton->mutex.unlock();
|
||||||
@ -79,7 +79,7 @@ std::shared_ptr<app::App> _Nullable getCurrentApp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<PubSub> getPubsub() {
|
std::shared_ptr<PubSub> getPubsub() {
|
||||||
tt_assert(loader_singleton);
|
assert(loader_singleton);
|
||||||
// it's safe to return pubsub without locking
|
// it's safe to return pubsub without locking
|
||||||
// because it's never freed and loader is never exited
|
// because it's never freed and loader is never exited
|
||||||
// also the loader instance cannot be obtained until the pubsub is created
|
// 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 there's a previous app, resume it
|
||||||
if (!loader_singleton->appStack.empty()) {
|
if (!loader_singleton->appStack.empty()) {
|
||||||
instance_to_resume = loader_singleton->appStack.top();
|
instance_to_resume = loader_singleton->appStack.top();
|
||||||
tt_assert(instance_to_resume);
|
assert(instance_to_resume);
|
||||||
transitionAppToState(instance_to_resume, app::StateShowing);
|
transitionAppToState(instance_to_resume, app::StateShowing);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ void tt_app_register(
|
|||||||
const ExternalAppManifest* manifest
|
const ExternalAppManifest* manifest
|
||||||
) {
|
) {
|
||||||
#ifdef ESP_PLATFORM
|
#ifdef ESP_PLATFORM
|
||||||
tt_assert((manifest->createData == nullptr) == (manifest->destroyData == nullptr));
|
assert((manifest->createData == nullptr) == (manifest->destroyData == nullptr));
|
||||||
tt::app::setElfAppManifest(
|
tt::app::setElfAppManifest(
|
||||||
manifest->name,
|
manifest->name,
|
||||||
manifest->icon,
|
manifest->icon,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* @file check.h
|
* @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,
|
* 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.
|
* 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(); }
|
#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)
|
|
||||||
|
|||||||
@ -9,19 +9,19 @@
|
|||||||
namespace tt {
|
namespace tt {
|
||||||
|
|
||||||
EventFlag::EventFlag() {
|
EventFlag::EventFlag() {
|
||||||
tt_assert(!TT_IS_IRQ_MODE());
|
assert(!TT_IS_IRQ_MODE());
|
||||||
handle = xEventGroupCreate();
|
handle = xEventGroupCreate();
|
||||||
tt_check(handle);
|
tt_check(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
EventFlag::~EventFlag() {
|
EventFlag::~EventFlag() {
|
||||||
tt_assert(!TT_IS_IRQ_MODE());
|
assert(!TT_IS_IRQ_MODE());
|
||||||
vEventGroupDelete(handle);
|
vEventGroupDelete(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t EventFlag::set(uint32_t flags) const {
|
uint32_t EventFlag::set(uint32_t flags) const {
|
||||||
tt_assert(handle);
|
assert(handle);
|
||||||
tt_assert((flags & TT_EVENT_FLAG_INVALID_BITS) == 0U);
|
assert((flags & TT_EVENT_FLAG_INVALID_BITS) == 0U);
|
||||||
|
|
||||||
uint32_t rflags;
|
uint32_t rflags;
|
||||||
BaseType_t yield;
|
BaseType_t yield;
|
||||||
@ -43,7 +43,7 @@ uint32_t EventFlag::set(uint32_t flags) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t EventFlag::clear(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;
|
uint32_t rflags;
|
||||||
|
|
||||||
@ -84,8 +84,8 @@ uint32_t EventFlag::wait(
|
|||||||
uint32_t options,
|
uint32_t options,
|
||||||
uint32_t timeout
|
uint32_t timeout
|
||||||
) const {
|
) const {
|
||||||
tt_assert(!TT_IS_IRQ_MODE());
|
assert(!TT_IS_IRQ_MODE());
|
||||||
tt_assert((flags & TT_EVENT_FLAG_INVALID_BITS) == 0U);
|
assert((flags & TT_EVENT_FLAG_INVALID_BITS) == 0U);
|
||||||
|
|
||||||
BaseType_t wait_all;
|
BaseType_t wait_all;
|
||||||
BaseType_t exit_clear;
|
BaseType_t exit_clear;
|
||||||
|
|||||||
@ -5,13 +5,13 @@
|
|||||||
namespace tt {
|
namespace tt {
|
||||||
|
|
||||||
MessageQueue::MessageQueue(uint32_t capacity, uint32_t msg_size) {
|
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);
|
queue_handle = xQueueCreate(capacity, msg_size);
|
||||||
tt_check(queue_handle);
|
tt_check(queue_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageQueue::~MessageQueue() {
|
MessageQueue::~MessageQueue() {
|
||||||
tt_assert(!TT_IS_ISR());
|
assert(!TT_IS_ISR());
|
||||||
vQueueDelete(queue_handle);
|
vQueueDelete(queue_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,18 +35,18 @@ Mutex::Mutex(Type type) : type(type) {
|
|||||||
tt_crash("Mutex type unknown/corrupted");
|
tt_crash("Mutex type unknown/corrupted");
|
||||||
}
|
}
|
||||||
|
|
||||||
tt_assert(semaphore != nullptr);
|
assert(semaphore != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mutex::~Mutex() {
|
Mutex::~Mutex() {
|
||||||
tt_assert(!TT_IS_IRQ_MODE());
|
assert(!TT_IS_IRQ_MODE());
|
||||||
vSemaphoreDelete(semaphore);
|
vSemaphoreDelete(semaphore);
|
||||||
semaphore = nullptr; // If the mutex is used after release, this might help debugging
|
semaphore = nullptr; // If the mutex is used after release, this might help debugging
|
||||||
}
|
}
|
||||||
|
|
||||||
TtStatus Mutex::acquire(TickType_t timeout) const {
|
TtStatus Mutex::acquire(TickType_t timeout) const {
|
||||||
tt_assert(!TT_IS_IRQ_MODE());
|
assert(!TT_IS_IRQ_MODE());
|
||||||
tt_assert(semaphore != nullptr);
|
assert(semaphore != nullptr);
|
||||||
|
|
||||||
tt_mutex_info(mutex, "acquire");
|
tt_mutex_info(mutex, "acquire");
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ TtStatus Mutex::acquire(TickType_t timeout) const {
|
|||||||
|
|
||||||
TtStatus Mutex::release() const {
|
TtStatus Mutex::release() const {
|
||||||
assert(!TT_IS_IRQ_MODE());
|
assert(!TT_IS_IRQ_MODE());
|
||||||
tt_assert(semaphore);
|
assert(semaphore);
|
||||||
tt_mutex_info(mutex, "release");
|
tt_mutex_info(mutex, "release");
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -101,8 +101,8 @@ TtStatus Mutex::release() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ThreadId Mutex::getOwner() const {
|
ThreadId Mutex::getOwner() const {
|
||||||
tt_assert(!TT_IS_IRQ_MODE());
|
assert(!TT_IS_IRQ_MODE());
|
||||||
tt_assert(semaphore);
|
assert(semaphore);
|
||||||
return (ThreadId)xSemaphoreGetMutexHolder(semaphore);
|
return (ThreadId)xSemaphoreGetMutexHolder(semaphore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,8 +20,8 @@ PubSubSubscription* tt_pubsub_subscribe(std::shared_ptr<PubSub> pubsub, PubSubCa
|
|||||||
}
|
}
|
||||||
|
|
||||||
void tt_pubsub_unsubscribe(std::shared_ptr<PubSub> pubsub, PubSubSubscription* pubsub_subscription) {
|
void tt_pubsub_unsubscribe(std::shared_ptr<PubSub> pubsub, PubSubSubscription* pubsub_subscription) {
|
||||||
tt_assert(pubsub);
|
assert(pubsub);
|
||||||
tt_assert(pubsub_subscription);
|
assert(pubsub_subscription);
|
||||||
|
|
||||||
tt_check(pubsub->mutex.acquire(TtWaitForever) == TtStatusOk);
|
tt_check(pubsub->mutex.acquire(TtWaitForever) == TtStatusOk);
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
namespace tt {
|
namespace tt {
|
||||||
|
|
||||||
Semaphore::Semaphore(uint32_t maxCount, uint32_t initialCount) {
|
Semaphore::Semaphore(uint32_t maxCount, uint32_t initialCount) {
|
||||||
tt_assert(!TT_IS_IRQ_MODE());
|
assert(!TT_IS_IRQ_MODE());
|
||||||
tt_assert((maxCount > 0U) && (initialCount <= maxCount));
|
assert((maxCount > 0U) && (initialCount <= maxCount));
|
||||||
|
|
||||||
if (maxCount == 1U) {
|
if (maxCount == 1U) {
|
||||||
handle = xSemaphoreCreateBinary();
|
handle = xSemaphoreCreateBinary();
|
||||||
@ -24,7 +24,7 @@ Semaphore::Semaphore(uint32_t maxCount, uint32_t initialCount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Semaphore::~Semaphore() {
|
Semaphore::~Semaphore() {
|
||||||
tt_assert(!TT_IS_IRQ_MODE());
|
assert(!TT_IS_IRQ_MODE());
|
||||||
vSemaphoreDelete(handle);
|
vSemaphoreDelete(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
namespace tt {
|
namespace tt {
|
||||||
|
|
||||||
StreamBuffer::StreamBuffer(size_t size, size_t triggerLevel) {
|
StreamBuffer::StreamBuffer(size_t size, size_t triggerLevel) {
|
||||||
tt_assert(size != 0);
|
assert(size != 0);
|
||||||
handle = xStreamBufferCreate(size, triggerLevel);
|
handle = xStreamBufferCreate(size, triggerLevel);
|
||||||
tt_check(handle);
|
tt_check(handle);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -42,17 +42,17 @@ __attribute__((__noreturn__)) void thread_catch() { //-V1082
|
|||||||
|
|
||||||
|
|
||||||
static void thread_body(void* context) {
|
static void thread_body(void* context) {
|
||||||
tt_assert(context);
|
assert(context);
|
||||||
auto* data = static_cast<Thread::Data*>(context);
|
auto* data = static_cast<Thread::Data*>(context);
|
||||||
|
|
||||||
// Store thread data instance to thread local storage
|
// Store thread data instance to thread local storage
|
||||||
tt_assert(pvTaskGetThreadLocalStoragePointer(nullptr, 0) == nullptr);
|
assert(pvTaskGetThreadLocalStoragePointer(nullptr, 0) == nullptr);
|
||||||
vTaskSetThreadLocalStoragePointer(nullptr, 0, data->thread);
|
vTaskSetThreadLocalStoragePointer(nullptr, 0, data->thread);
|
||||||
|
|
||||||
tt_assert(data->state == Thread::State::Starting);
|
assert(data->state == Thread::State::Starting);
|
||||||
setState(data, Thread::State::Running);
|
setState(data, Thread::State::Running);
|
||||||
data->callbackResult = data->callback(data->callbackContext);
|
data->callbackResult = data->callback(data->callbackContext);
|
||||||
tt_assert(data->state == Thread::State::Running);
|
assert(data->state == Thread::State::Running);
|
||||||
|
|
||||||
setState(data, Thread::State::Stopped);
|
setState(data, Thread::State::Stopped);
|
||||||
|
|
||||||
@ -102,36 +102,36 @@ Thread::Thread(
|
|||||||
|
|
||||||
Thread::~Thread() {
|
Thread::~Thread() {
|
||||||
// Ensure that use join before free
|
// Ensure that use join before free
|
||||||
tt_assert(data.state == State::Stopped);
|
assert(data.state == State::Stopped);
|
||||||
tt_assert(data.taskHandle == nullptr);
|
assert(data.taskHandle == nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::setName(const std::string& newName) {
|
void Thread::setName(const std::string& newName) {
|
||||||
tt_assert(data.state == State::Stopped);
|
assert(data.state == State::Stopped);
|
||||||
data.name = newName;
|
data.name = newName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::setStackSize(size_t stackSize) {
|
void Thread::setStackSize(size_t stackSize) {
|
||||||
tt_assert(data.state == State::Stopped);
|
assert(data.state == State::Stopped);
|
||||||
tt_assert(stackSize % 4 == 0);
|
assert(stackSize % 4 == 0);
|
||||||
data.stackSize = stackSize;
|
data.stackSize = stackSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::setCallback(Callback callback, _Nullable void* callbackContext) {
|
void Thread::setCallback(Callback callback, _Nullable void* callbackContext) {
|
||||||
tt_assert(data.state == State::Stopped);
|
assert(data.state == State::Stopped);
|
||||||
data.callback = callback;
|
data.callback = callback;
|
||||||
data.callbackContext = callbackContext;
|
data.callbackContext = callbackContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Thread::setPriority(Priority priority) {
|
void Thread::setPriority(Priority priority) {
|
||||||
tt_assert(data.state == State::Stopped);
|
assert(data.state == State::Stopped);
|
||||||
data.priority = priority;
|
data.priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Thread::setStateCallback(StateCallback callback, _Nullable void* callbackContext) {
|
void Thread::setStateCallback(StateCallback callback, _Nullable void* callbackContext) {
|
||||||
tt_assert(data.state == State::Stopped);
|
assert(data.state == State::Stopped);
|
||||||
data.stateCallback = callback;
|
data.stateCallback = callback;
|
||||||
data.stateCallbackContext = callbackContext;
|
data.stateCallbackContext = callbackContext;
|
||||||
}
|
}
|
||||||
@ -141,9 +141,9 @@ Thread::State Thread::getState() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Thread::start() {
|
void Thread::start() {
|
||||||
tt_assert(data.callback);
|
assert(data.callback);
|
||||||
tt_assert(data.state == State::Stopped);
|
assert(data.state == State::Stopped);
|
||||||
tt_assert(data.stackSize > 0U && data.stackSize < (UINT16_MAX * sizeof(StackType_t)));
|
assert(data.stackSize > 0U && data.stackSize < (UINT16_MAX * sizeof(StackType_t)));
|
||||||
|
|
||||||
setState(&data, State::Starting);
|
setState(&data, State::Starting);
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ ThreadId Thread::getId() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t Thread::getReturnCode() const {
|
int32_t Thread::getReturnCode() const {
|
||||||
tt_assert(data.state == State::Stopped);
|
assert(data.state == State::Stopped);
|
||||||
return data.callbackResult;
|
return data.callbackResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ Thread::Priority thread_get_current_priority() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void thread_yield() {
|
void thread_yield() {
|
||||||
tt_assert(!TT_IS_IRQ_MODE());
|
assert(!TT_IS_IRQ_MODE());
|
||||||
taskYIELD();
|
taskYIELD();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ static void timer_callback(TimerHandle_t hTimer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Timer::Timer(Type type, Callback callback, std::shared_ptr<void> callbackContext) {
|
Timer::Timer(Type type, Callback callback, std::shared_ptr<void> callbackContext) {
|
||||||
tt_assert((!TT_IS_ISR()) && (callback != nullptr));
|
assert((!TT_IS_ISR()) && (callback != nullptr));
|
||||||
|
|
||||||
this->callback = callback;
|
this->callback = callback;
|
||||||
this->callbackContext = std::move(callbackContext);
|
this->callbackContext = std::move(callbackContext);
|
||||||
@ -28,39 +28,39 @@ Timer::Timer(Type type, Callback callback, std::shared_ptr<void> callbackContext
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->timerHandle = xTimerCreate(nullptr, portMAX_DELAY, (BaseType_t)reload, this, timer_callback);
|
this->timerHandle = xTimerCreate(nullptr, portMAX_DELAY, (BaseType_t)reload, this, timer_callback);
|
||||||
tt_assert(this->timerHandle);
|
assert(this->timerHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer::~Timer() {
|
Timer::~Timer() {
|
||||||
tt_assert(!TT_IS_ISR());
|
assert(!TT_IS_ISR());
|
||||||
tt_check(xTimerDelete(timerHandle, portMAX_DELAY) == pdPASS);
|
tt_check(xTimerDelete(timerHandle, portMAX_DELAY) == pdPASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Timer::start(TickType_t interval) {
|
bool Timer::start(TickType_t interval) {
|
||||||
tt_assert(!TT_IS_ISR());
|
assert(!TT_IS_ISR());
|
||||||
tt_assert(interval < portMAX_DELAY);
|
assert(interval < portMAX_DELAY);
|
||||||
return xTimerChangePeriod(timerHandle, interval, portMAX_DELAY) == pdPASS;
|
return xTimerChangePeriod(timerHandle, interval, portMAX_DELAY) == pdPASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Timer::restart(TickType_t interval) {
|
bool Timer::restart(TickType_t interval) {
|
||||||
tt_assert(!TT_IS_ISR());
|
assert(!TT_IS_ISR());
|
||||||
tt_assert(interval < portMAX_DELAY);
|
assert(interval < portMAX_DELAY);
|
||||||
return xTimerChangePeriod(timerHandle, interval, portMAX_DELAY) == pdPASS &&
|
return xTimerChangePeriod(timerHandle, interval, portMAX_DELAY) == pdPASS &&
|
||||||
xTimerReset(timerHandle, portMAX_DELAY) == pdPASS;
|
xTimerReset(timerHandle, portMAX_DELAY) == pdPASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Timer::stop() {
|
bool Timer::stop() {
|
||||||
tt_assert(!TT_IS_ISR());
|
assert(!TT_IS_ISR());
|
||||||
return xTimerStop(timerHandle, portMAX_DELAY) == pdPASS;
|
return xTimerStop(timerHandle, portMAX_DELAY) == pdPASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Timer::isRunning() {
|
bool Timer::isRunning() {
|
||||||
tt_assert(!TT_IS_ISR());
|
assert(!TT_IS_ISR());
|
||||||
return xTimerIsTimerActive(timerHandle) == pdTRUE;
|
return xTimerIsTimerActive(timerHandle) == pdTRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
TickType_t Timer::getExpireTime() {
|
TickType_t Timer::getExpireTime() {
|
||||||
tt_assert(!TT_IS_ISR());
|
assert(!TT_IS_ISR());
|
||||||
return xTimerGetExpiryTime(timerHandle);
|
return xTimerGetExpiryTime(timerHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,10 +74,10 @@ bool Timer::setPendingCallback(PendingCallback callback, void* callbackContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Timer::setThreadPriority(Thread::Priority priority) {
|
void Timer::setThreadPriority(Thread::Priority priority) {
|
||||||
tt_assert(!TT_IS_ISR());
|
assert(!TT_IS_ISR());
|
||||||
|
|
||||||
TaskHandle_t task_handle = xTimerGetTimerDaemonTaskHandle();
|
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<UBaseType_t>(priority));
|
vTaskPrioritySet(task_handle, static_cast<UBaseType_t>(priority));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ bool isRunning() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t lock() {
|
int32_t lock() {
|
||||||
tt_assert(!TT_IS_ISR());
|
assert(!TT_IS_ISR());
|
||||||
|
|
||||||
int32_t lock;
|
int32_t lock;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ int32_t lock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t unlock() {
|
int32_t unlock() {
|
||||||
tt_assert(!TT_IS_ISR());
|
assert(!TT_IS_ISR());
|
||||||
|
|
||||||
int32_t lock;
|
int32_t lock;
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ int32_t unlock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t restoreLock(int32_t lock) {
|
int32_t restoreLock(int32_t lock) {
|
||||||
tt_assert(!TT_IS_ISR());
|
assert(!TT_IS_ISR());
|
||||||
|
|
||||||
switch (xTaskGetSchedulerState()) {
|
switch (xTaskGetSchedulerState()) {
|
||||||
case taskSCHEDULER_SUSPENDED:
|
case taskSCHEDULER_SUSPENDED:
|
||||||
@ -108,7 +108,7 @@ uint32_t getTickFrequency() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void delayTicks(TickType_t ticks) {
|
void delayTicks(TickType_t ticks) {
|
||||||
tt_assert(!TT_IS_ISR());
|
assert(!TT_IS_ISR());
|
||||||
if (ticks == 0U) {
|
if (ticks == 0U) {
|
||||||
taskYIELD();
|
taskYIELD();
|
||||||
} else {
|
} else {
|
||||||
@ -117,7 +117,7 @@ void delayTicks(TickType_t ticks) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TtStatus delayUntilTick(TickType_t tick) {
|
TtStatus delayUntilTick(TickType_t tick) {
|
||||||
tt_assert(!TT_IS_ISR());
|
assert(!TT_IS_ISR());
|
||||||
|
|
||||||
TickType_t tcnt, delay;
|
TickType_t tcnt, delay;
|
||||||
TtStatus stat;
|
TtStatus stat;
|
||||||
|
|||||||
@ -29,7 +29,7 @@ private:
|
|||||||
|
|
||||||
void update() {
|
void update() {
|
||||||
auto sdcard = tt::hal::getConfiguration()->sdcard;
|
auto sdcard = tt::hal::getConfiguration()->sdcard;
|
||||||
tt_assert(sdcard);
|
assert(sdcard);
|
||||||
|
|
||||||
if (lock(50)) {
|
if (lock(50)) {
|
||||||
auto new_state = sdcard->getState();
|
auto new_state = sdcard->getState();
|
||||||
|
|||||||
@ -312,7 +312,7 @@ bool isConnectionSecure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int getRssi() {
|
int getRssi() {
|
||||||
tt_assert(wifi_singleton);
|
assert(wifi_singleton);
|
||||||
static int rssi = 0;
|
static int rssi = 0;
|
||||||
if (esp_wifi_sta_get_rssi(&rssi) == ESP_OK) {
|
if (esp_wifi_sta_get_rssi(&rssi) == ESP_OK) {
|
||||||
return rssi;
|
return rssi;
|
||||||
@ -326,7 +326,7 @@ int getRssi() {
|
|||||||
static void scan_list_alloc(std::shared_ptr<Wifi> wifi) {
|
static void scan_list_alloc(std::shared_ptr<Wifi> wifi) {
|
||||||
auto lockable = wifi->dataMutex.scoped();
|
auto lockable = wifi->dataMutex.scoped();
|
||||||
if (lockable->lock(TtWaitForever)) {
|
if (lockable->lock(TtWaitForever)) {
|
||||||
tt_assert(wifi->scan_list == nullptr);
|
assert(wifi->scan_list == nullptr);
|
||||||
wifi->scan_list = static_cast<wifi_ap_record_t*>(malloc(sizeof(wifi_ap_record_t) * wifi->scan_list_limit));
|
wifi->scan_list = static_cast<wifi_ap_record_t*>(malloc(sizeof(wifi_ap_record_t) * wifi->scan_list_limit));
|
||||||
wifi->scan_list_count = 0;
|
wifi->scan_list_count = 0;
|
||||||
}
|
}
|
||||||
@ -344,7 +344,7 @@ static void scan_list_alloc_safely(std::shared_ptr<Wifi> wifi) {
|
|||||||
static void scan_list_free(std::shared_ptr<Wifi> wifi) {
|
static void scan_list_free(std::shared_ptr<Wifi> wifi) {
|
||||||
auto lockable = wifi->dataMutex.scoped();
|
auto lockable = wifi->dataMutex.scoped();
|
||||||
if (lockable->lock(TtWaitForever)) {
|
if (lockable->lock(TtWaitForever)) {
|
||||||
tt_assert(wifi->scan_list != nullptr);
|
assert(wifi->scan_list != nullptr);
|
||||||
free(wifi->scan_list);
|
free(wifi->scan_list);
|
||||||
wifi->scan_list = nullptr;
|
wifi->scan_list = nullptr;
|
||||||
wifi->scan_list_count = 0;
|
wifi->scan_list_count = 0;
|
||||||
@ -643,7 +643,7 @@ static void dispatchDisable(std::shared_ptr<void> context) {
|
|||||||
TT_LOG_E(TAG, "Failed to deinit");
|
TT_LOG_E(TAG, "Failed to deinit");
|
||||||
}
|
}
|
||||||
|
|
||||||
tt_assert(wifi->netif != nullptr);
|
assert(wifi->netif != nullptr);
|
||||||
esp_netif_destroy(wifi->netif);
|
esp_netif_destroy(wifi->netif);
|
||||||
wifi->netif = nullptr;
|
wifi->netif = nullptr;
|
||||||
wifi->setScanActive(false);
|
wifi->setScanActive(false);
|
||||||
@ -941,7 +941,7 @@ class WifiService final : public Service {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
void onStart(ServiceContext& service) override {
|
void onStart(ServiceContext& service) override {
|
||||||
tt_assert(wifi_singleton == nullptr);
|
assert(wifi_singleton == nullptr);
|
||||||
wifi_singleton = std::make_shared<Wifi>();
|
wifi_singleton = std::make_shared<Wifi>();
|
||||||
|
|
||||||
wifi_singleton->autoConnectTimer = std::make_unique<Timer>(Timer::Type::Periodic, onAutoConnectTimer, wifi_singleton);
|
wifi_singleton->autoConnectTimer = std::make_unique<Timer>(Timer::Type::Periodic, onAutoConnectTimer, wifi_singleton);
|
||||||
@ -956,7 +956,7 @@ public:
|
|||||||
|
|
||||||
void onStop(ServiceContext& service) override {
|
void onStop(ServiceContext& service) override {
|
||||||
auto wifi = wifi_singleton;
|
auto wifi = wifi_singleton;
|
||||||
tt_assert(wifi != nullptr);
|
assert(wifi != nullptr);
|
||||||
|
|
||||||
RadioState state = wifi->getRadioState();
|
RadioState state = wifi->getRadioState();
|
||||||
if (state != RadioState::Off) {
|
if (state != RadioState::Off) {
|
||||||
|
|||||||
@ -44,7 +44,7 @@ static void publish_event_simple(Wifi* wifi, EventType type) {
|
|||||||
// region Public functions
|
// region Public functions
|
||||||
|
|
||||||
std::shared_ptr<PubSub> getPubsub() {
|
std::shared_ptr<PubSub> getPubsub() {
|
||||||
tt_assert(wifi);
|
assert(wifi);
|
||||||
return wifi->pubsub;
|
return wifi->pubsub;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,26 +57,26 @@ std::string getConnectionTarget() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void scan() {
|
void scan() {
|
||||||
tt_assert(wifi);
|
assert(wifi);
|
||||||
wifi->scan_active = false; // TODO: enable and then later disable automatically
|
wifi->scan_active = false; // TODO: enable and then later disable automatically
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isScanning() {
|
bool isScanning() {
|
||||||
tt_assert(wifi);
|
assert(wifi);
|
||||||
return wifi->scan_active;
|
return wifi->scan_active;
|
||||||
}
|
}
|
||||||
|
|
||||||
void connect(const settings::WifiApSettings* ap, bool remember) {
|
void connect(const settings::WifiApSettings* ap, bool remember) {
|
||||||
tt_assert(wifi);
|
assert(wifi);
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
}
|
}
|
||||||
|
|
||||||
void disconnect() {
|
void disconnect() {
|
||||||
tt_assert(wifi);
|
assert(wifi);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setScanRecords(uint16_t records) {
|
void setScanRecords(uint16_t records) {
|
||||||
tt_assert(wifi);
|
assert(wifi);
|
||||||
// TODO: implement
|
// TODO: implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ std::vector<ApRecord> getScanResults() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setEnabled(bool enabled) {
|
void setEnabled(bool enabled) {
|
||||||
tt_assert(wifi != nullptr);
|
assert(wifi != nullptr);
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
wifi->radio_state = RadioState::On;
|
wifi->radio_state = RadioState::On;
|
||||||
wifi->secure_connection = true;
|
wifi->secure_connection = true;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user