-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add wifi service * updates for service/app registry changes * wifi wip * basic wifi functionality radio on/off is working scanning state is working * fix for wifi switch state * reduce singleton usage * various improvements * improved error handling for low memory issues * working scanning * various improvements * various improvements and fixes + added auto-start support in Config * allow hardwareconfig customizations * fix for rgb format * increased lvgl fps 17ms works but 16ms makes the touch events hang for some reason * layout improvements * wip on multi-screen view * basic connection dialog * more connection logic * created proper app stack and lifecycle * cleanup * cleanup * cleanup lv widgets * proper toolbar implementation * split up wifi apps * wip * revert naming * wip * temp fix for internal disconnect * added bundle * app/service vs appdata/servicedata * working wifi connect parameters
- Loading branch information
1 parent
83e226f
commit 64a01df
Showing
90 changed files
with
2,655 additions
and
914 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,128 @@ | ||
#include "app_i.h" | ||
#include "furi_core.h" | ||
#include "log.h" | ||
#include "furi_string.h" | ||
|
||
#define TAG "app" | ||
#include <stdio.h> | ||
|
||
App* furi_app_alloc(const AppManifest* _Nonnull manifest) { | ||
App app = { | ||
static AppFlags app_get_flags_default(AppType type); | ||
|
||
// region Alloc/free | ||
|
||
App app_alloc(const AppManifest* manifest, Bundle* _Nullable parameters) { | ||
AppData* data = malloc(sizeof(AppData)); | ||
*data = (AppData) { | ||
.mutex = furi_mutex_alloc(FuriMutexTypeRecursive), | ||
.state = APP_STATE_INITIAL, | ||
.flags = app_get_flags_default(manifest->type), | ||
.manifest = manifest, | ||
.context = { | ||
.data = NULL | ||
} | ||
.parameters = parameters, | ||
.data = NULL | ||
}; | ||
App* app_ptr = malloc(sizeof(App)); | ||
return memcpy(app_ptr, &app, sizeof(App)); | ||
return (App*)data; | ||
} | ||
|
||
void furi_app_free(App* app) { | ||
furi_assert(app); | ||
free(app); | ||
void app_free(App app) { | ||
AppData* data = (AppData*)app; | ||
if (data->parameters) { | ||
bundle_free(data->parameters); | ||
} | ||
furi_mutex_free(data->mutex); | ||
free(data); | ||
} | ||
|
||
// endregion | ||
|
||
// region Internal | ||
|
||
static void app_lock(AppData* data) { | ||
furi_mutex_acquire(data->mutex, FuriMutexTypeRecursive); | ||
} | ||
|
||
static void app_unlock(AppData* data) { | ||
furi_mutex_release(data->mutex); | ||
} | ||
|
||
static AppFlags app_get_flags_default(AppType type) { | ||
static const AppFlags DEFAULT_DESKTOP_FLAGS = { | ||
.show_toolbar = false, | ||
.show_statusbar = true | ||
}; | ||
|
||
static const AppFlags DEFAULT_APP_FLAGS = { | ||
.show_toolbar = true, | ||
.show_statusbar = true | ||
}; | ||
|
||
return type == AppTypeDesktop | ||
? DEFAULT_DESKTOP_FLAGS | ||
: DEFAULT_APP_FLAGS; | ||
} | ||
|
||
// endregion Internal | ||
|
||
// region Public getters & setters | ||
|
||
void app_set_state(App app, AppState state) { | ||
AppData* data = (AppData*)app; | ||
app_lock(data); | ||
data->state = state; | ||
app_unlock(data); | ||
} | ||
|
||
AppState app_get_state(App app) { | ||
AppData* data = (AppData*)app; | ||
app_lock(data); | ||
AppState state = data->state; | ||
app_unlock(data); | ||
return state; | ||
} | ||
|
||
const AppManifest* app_get_manifest(App app) { | ||
AppData* data = (AppData*)app; | ||
// No need to lock const data; | ||
return data->manifest; | ||
} | ||
|
||
AppFlags app_get_flags(App app) { | ||
AppData* data = (AppData*)app; | ||
app_lock(data); | ||
AppFlags flags = data->flags; | ||
app_unlock(data); | ||
return flags; | ||
} | ||
|
||
void app_set_flags(App app, AppFlags flags) { | ||
AppData* data = (AppData*)app; | ||
app_lock(data); | ||
data->flags = flags; | ||
app_unlock(data); | ||
} | ||
|
||
void* app_get_data(App app) { | ||
AppData* data = (AppData*)app; | ||
app_lock(data); | ||
void* value = data->data; | ||
app_unlock(data); | ||
return value; | ||
} | ||
|
||
void app_set_data(App app, void* value) { | ||
AppData* data = (AppData*)app; | ||
app_lock(data); | ||
data->data = value; | ||
app_unlock(data); | ||
} | ||
|
||
/** TODO: Make this thread-safe. | ||
* In practice, the bundle is writeable, so someone could be writing to it | ||
* while it is being accessed from another thread. | ||
* Consider creating MutableBundle vs Bundle. | ||
* Consider not exposing bundle, but expose `app_get_bundle_int(key)` methods with locking in it. | ||
*/ | ||
Bundle* _Nullable app_get_parameters(App app) { | ||
AppData* data = (AppData*)app; | ||
app_lock(data); | ||
Bundle* bundle = data->parameters; | ||
app_unlock(data); | ||
return bundle; | ||
} | ||
|
||
// endregion Public getters & setters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
#include "app_manifest.h" | ||
#include "bundle.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef enum { | ||
APP_STATE_INITIAL, // App is being activated in loader | ||
APP_STATE_STARTED, // App is in memory | ||
APP_STATE_SHOWING, // App view is created | ||
APP_STATE_HIDING, // App view is destroyed | ||
APP_STATE_STOPPED // App is not in memory | ||
} AppState; | ||
|
||
typedef union { | ||
struct { | ||
bool show_statusbar : 1; | ||
bool show_toolbar : 1; | ||
}; | ||
unsigned char flags; | ||
} AppFlags; | ||
|
||
typedef void* App; | ||
|
||
/** @brief Create an app | ||
* @param manifest | ||
* @param parameters optional bundle. memory ownership is transferred to App | ||
* @return | ||
*/ | ||
App app_alloc(const AppManifest* manifest, Bundle* _Nullable parameters); | ||
void app_free(App app); | ||
|
||
void app_set_state(App app, AppState state); | ||
AppState app_get_state(App app); | ||
|
||
const AppManifest* app_get_manifest(App app); | ||
|
||
AppFlags app_get_flags(App app); | ||
void app_set_flags(App app, AppFlags flags); | ||
|
||
void* _Nullable app_get_data(App app); | ||
void app_set_data(App app, void* data); | ||
|
||
Bundle* _Nullable app_get_parameters(App app); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#include "app_manifest_registry.h" | ||
|
||
#include "furi_core.h" | ||
#include "m-dict.h" | ||
#include "m_cstr_dup.h" | ||
|
Oops, something went wrong.