Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A background loader for Flipper Zero Apps

License

NotificationsYou must be signed in to change notification settings

twisted-pear/bgloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a plugin for the Flipper Zero that allows compatible apps to be loadedand to remain running in the background.

Once started the plugin will display a file browser that allows you to selectan application's FAP file. If the application is not already running, it willbe loaded. The application then has the choice of terminating normally, inwhich case the loader will unload the application as normal, or to relinquishcontrol of the GUI and to keep active in the background, in which case theloader will not unload the application.

If an already running application is selected, the loader will inform theapplication that it can reassert control over the GUI and continue in theforeground. Once again, the reattached application can chose to terminatenormally or to keep active in the background.

Make sure you only select compatible applications (see below) and that younever start an application more than once at the same time (by launching it inthe background and then selecting it in the Flipper's apps menu).

Warning

This plugin is in the early stages of development. It will inevitably havebugs. You have been warned.

Writing Compatible Apps

An application needs to be compatible with this loader. Compatible apps mustcheck their startup parameters to determine if they have been launched via thebackground loader. If so, they must inform the loader when they wish to keeprunning in the background. If they decide to keep running in the background,they must listen for the loader's signal that they are being reopened and thusallowed to use the GUI again.

The loader's API can be found inbgloader_api.h. In the simplest case, theapp will need to do the following:

  1. Check for the loader's special parameter. The parameter will have the formrun_in_background:<path to the app's FAP file>.
  2. Retrieve the FAP file path from the parameter and use it to access theBGLoaderApp structure. This can be done by callingfuri_record_open(<FAP file path>).
  3. Once the app is ready to go into the background it needs to detach from theGUI and send aBGLoaderMessage with typeBGLoaderMessageType_LoaderBackground to theto_loader queue in theBGLoaderApp structure.
  4. While in the background the app need to check theto_app queue in theBGLoaderApp structure for a message of the typeBGLoaderMessageType_AppReattached. This message informs the app that it isbeing reattached and can attach itself to the GUI again.
  5. To terminate, the app just exits normally.

An example of what a compatible app might look like is given below:

static const char *get_bgloader_app_path(const char *args){size_t base_args_len = strlen(APP_BASE_ARGS);return (args + base_args_len + 1);}static bool run_with_bgloader(const char *args){size_t base_args_len = strlen(APP_BASE_ARGS);if (args == NULL) {return false;}if (strncmp(args, APP_BASE_ARGS, base_args_len) != 0) {return false;}if (strlen(args) < base_args_len + 2) {return false;}if (args[base_args_len] != ':') {return false;}const char *app_path = get_bgloader_app_path(args);return furi_record_exists(app_path);}static void bgloader_loop(AppState *state, const char *bg_app_path){while (true) {view_dispatcher_run(state->view_dispatcher);// 2.BGLoaderApp *bg_app = furi_record_open(bg_app_path);// exit_for_real is set elsewhere to indicate the app is ready// to terminateif (state->exit_for_real) {// 5.// exit normallyfuri_record_close(bg_app_path);break;}// 3.// signal loader that we're ready to go to backgroundBGLoaderMessage msg;msg.type = BGLoaderMessageType_LoaderBackground;furi_check(furi_message_queue_put(bg_app->to_loader, &msg,FuriWaitForever) == FuriStatusOk);detach_from_gui(state);// 4.// wait for loader to wake us up againfuri_check(furi_message_queue_get(bg_app->to_app, &msg,FuriWaitForever) == FuriStatusOk);switch(msg.type) {case BGLoaderMessageType_AppReattached:break;default:furi_check(0);}furi_record_close(bg_app_path);attach_to_gui(state);}}int32_t app_entry_point(const char *args){...// regular setup...// 1.bool run_with_bgl = run_with_bgloader(args);...if (run_with_bgl) {const char *bg_app_path = get_bgloader_app_path(args);bgloader_loop(state, bg_app_path);} else {// regular main loop (e.g. view_dispatcher_run())}...// regular teardown...}

For examples of compatible apps check outf0forth orESubGhz Chat.

Acknowledgements

Thanks toWilly-JL for coming up with an ideafor how to store the pointers to an application's data structures and for howto signal an application's thread to terminate.

The app icon was made byxMasterX.

About

A background loader for Flipper Zero Apps

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp