Skip to content

Commit

Permalink
CLI: More commands as plugins on SD -6KB DFU, refactor plugin wrapper, (
Browse files Browse the repository at this point in the history
#276)

* Unused icons to check later

* Exclude disabled icons from firmware

* Format

* CLI: Test moving more cmds to plugins

* CLI: Macro template for plugin wrapper

* Fix plugin filenames

* Retrofit older cli wrappers

* Fix unused

* Fix manifests

* Add explanation

* Revert "Unused icons to check later"

This reverts commit b7f98e3.

* Revert "Exclude disabled icons from firmware"

This reverts commit ab62e99.

* Add back toplevel chat command

* Add DFU size to github comment

* Fix build

* Fix BT CLI preload fail

* Add these back

* Fix CLI command gpio preload fail

* Fix input command

* These can stay

* Fix negative size rounding

* Update changelog

* Fix DFU size calc
  • Loading branch information
Willy-JL authored Nov 4, 2024
1 parent 30d7589 commit 2e7eedf
Show file tree
Hide file tree
Showing 37 changed files with 305 additions and 390 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ jobs:
tar czpf "artifacts/flipper-z-any-scripts-${SUFFIX}.tgz" scripts
cp build/core2_firmware.tgz "artifacts/flipper-z-any-core2_firmware-${SUFFIX}.tgz"
- name: "Calculate DFU sizes"
env:
INDEXER_URL: ${{ secrets.INDEXER_URL }}
if: ${{ env.INDEXER_URL != '' && github.event.pull_request && matrix.target == env.DEFAULT_TARGET }}
run: |
curl -L "${{ secrets.INDEXER_URL }}"/firmware/development/f7/full_dfu -o dev.dfu
dfu_size_new=$(du --apparent-size -B 1 artifacts/flipper-z-${TARGET}-full-*.dfu | cut -f1)
dfu_size_dev=$(du --apparent-size -B 1 dev.dfu | cut -f1)
dfu_size_diff=$((dfu_size_new - dfu_size_dev))
DFU_SIZE=$(echo ${dfu_size_new}B | sed -r 's/^([0-9]+)([0-9]{2})([0-9])B/\1.\2K/')
DFU_DIFF=$(echo ${dfu_size_diff}B | sed -r 's/^(-?[0-9]+)([0-9]{2})([0-9])B/\1.\2K/' | sed -r 's/^([^-])/+\1/')
echo "DFU_SIZE=$DFU_SIZE" >> $GITHUB_ENV
echo "DFU_DIFF=$DFU_DIFF" >> $GITHUB_ENV
- name: "Upload artifacts to update server"
env:
INDEXER_URL: ${{ secrets.INDEXER_URL }}
Expand Down Expand Up @@ -155,6 +169,7 @@ jobs:
**Compiled ${{ matrix.target }} firmware for commit `${{steps.names.outputs.commit_sha}}`:**
- [☁️ Flipper Lab/App](https://lab.flipper.net/?url=${{secrets.INDEXER_URL}}/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz&channel=mntm-${{steps.names.outputs.branch_name}}&version=${{steps.names.outputs.commit_sha}})
- [📦 qFlipper Package](${{secrets.INDEXER_URL}}/builds/firmware/${{steps.names.outputs.branch_name}}/flipper-z-${{steps.names.outputs.default_target}}-update-${{steps.names.outputs.suffix}}.tgz)
- DFU Size: `${{ env.DFU_SIZE }}` (`${{ env.DFU_DIFF }}` from dev)
edit-mode: replace

- name: Send devbuild webhook
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@
- UL: W5500 Ethernet: Various fixes and improvements (by @xMasterX)
- OFW: SPI Mem Manager: Fixed UI rendering bug related to line breaks (by @portasynthinca3)
- OFW: USB/BT Remote: Mouse clicker option to click as fast as possible (by @sumukhj1219)
- CLI: Print plugin name on load fail (by @Willy-JL)
- CLI:
- Print plugin name on load fail (by @Willy-JL)
- Move more commands as plugins on SD, refactor plugin wrapper (#276 by @Willy-JL)
- NFC:
- NDEF Parser:
- Mifare Classic support (#265 by @luu176), protocol-agnostic rewrite and more improvements (#265 by @Willy-JL)
Expand Down
2 changes: 1 addition & 1 deletion applications/main/ibutton/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ App(
apptype=FlipperAppType.STARTUP,
targets=["f7"],
entry_point="ibutton_on_system_start",
sources=["ibutton_start.c"],
sources=["ibutton_cli.c"],
order=60,
)
29 changes: 16 additions & 13 deletions applications/main/ibutton/ibutton_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
#include <ibutton/ibutton_worker.h>
#include <ibutton/ibutton_protocols.h>

static void ibutton_cli(Cli* cli, FuriString* args, void* context);

#include <cli/cli_i.h>
CLI_PLUGIN_WRAPPER("ibutton", ibutton_cli)

// app cli function
void ibutton_on_system_start(void) {
#ifdef SRV_CLI
Cli* cli = furi_record_open(RECORD_CLI);
cli_add_command(cli, "ikey", CliCommandFlagDefault, ibutton_cli_wrapper, cli);
furi_record_close(RECORD_CLI);
#else
UNUSED(ibutton_cli);
#endif
}

static void ibutton_cli_print_usage(void) {
printf("Usage:\r\n");
printf("ikey read\r\n");
Expand Down Expand Up @@ -239,16 +255,3 @@ void ibutton_cli(Cli* cli, FuriString* args, void* context) {

furi_string_free(cmd);
}

#include <flipper_application/flipper_application.h>
#include <cli/cli_i.h>

static const FlipperAppPluginDescriptor plugin_descriptor = {
.appid = CLI_PLUGIN_APP_ID,
.ep_api_version = CLI_PLUGIN_API_VERSION,
.entry_point = &ibutton_cli,
};

const FlipperAppPluginDescriptor* ibutton_cli_plugin_ep(void) {
return &plugin_descriptor;
}
11 changes: 0 additions & 11 deletions applications/main/ibutton/ibutton_start.c

This file was deleted.

4 changes: 2 additions & 2 deletions applications/main/infrared/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ App(
appid="infrared_cli",
targets=["f7"],
apptype=FlipperAppType.PLUGIN,
entry_point="infrared_cli_plugin_ep",
entry_point="infrared_cli_start_ir_plugin_ep",
requires=["cli"],
sources=[
"infrared_cli.c",
Expand All @@ -31,6 +31,6 @@ App(
apptype=FlipperAppType.STARTUP,
targets=["f7"],
entry_point="infrared_on_system_start",
sources=["infrared_start.c"],
sources=["infrared_cli.c"],
order=20,
)
20 changes: 10 additions & 10 deletions applications/main/infrared/infrared_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,15 +555,15 @@ static void infrared_cli_start_ir(Cli* cli, FuriString* args, void* context) {
furi_string_free(command);
}

#include <flipper_application/flipper_application.h>
#include <cli/cli_i.h>

static const FlipperAppPluginDescriptor plugin_descriptor = {
.appid = CLI_PLUGIN_APP_ID,
.ep_api_version = CLI_PLUGIN_API_VERSION,
.entry_point = &infrared_cli_start_ir,
};

const FlipperAppPluginDescriptor* infrared_cli_plugin_ep(void) {
return &plugin_descriptor;
CLI_PLUGIN_WRAPPER("infrared", infrared_cli_start_ir)

void infrared_on_system_start(void) {
#ifdef SRV_CLI
Cli* cli = (Cli*)furi_record_open(RECORD_CLI);
cli_add_command(cli, "ir", CliCommandFlagDefault, infrared_cli_start_ir_wrapper, NULL);
furi_record_close(RECORD_CLI);
#else
UNUSED(infrared_cli_start_ir);
#endif
}
11 changes: 0 additions & 11 deletions applications/main/infrared/infrared_start.c

This file was deleted.

2 changes: 1 addition & 1 deletion applications/main/lfrfid/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ App(
targets=["f7"],
apptype=FlipperAppType.STARTUP,
entry_point="lfrfid_on_system_start",
sources=["lfrfid_start.c"],
sources=["lfrfid_cli.c"],
order=50,
)
25 changes: 12 additions & 13 deletions applications/main/lfrfid/lfrfid_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
#include <lfrfid/lfrfid_raw_file.h>
#include <toolbox/pulse_protocols/pulse_glue.h>

static void lfrfid_cli(Cli* cli, FuriString* args, void* context);

#include <cli/cli_i.h>
CLI_PLUGIN_WRAPPER("lfrfid", lfrfid_cli)

// app cli function
void lfrfid_on_system_start(void) {
Cli* cli = furi_record_open(RECORD_CLI);
cli_add_command(cli, "rfid", CliCommandFlagDefault, lfrfid_cli_wrapper, NULL);
furi_record_close(RECORD_CLI);
}

static void lfrfid_cli_print_usage(void) {
printf("Usage:\r\n");
printf("rfid read <optional: normal | indala> - read in ASK/PSK mode\r\n");
Expand Down Expand Up @@ -568,16 +580,3 @@ static void lfrfid_cli(Cli* cli, FuriString* args, void* context) {

furi_string_free(cmd);
}

#include <flipper_application/flipper_application.h>
#include <cli/cli_i.h>

static const FlipperAppPluginDescriptor plugin_descriptor = {
.appid = CLI_PLUGIN_APP_ID,
.ep_api_version = CLI_PLUGIN_API_VERSION,
.entry_point = &lfrfid_cli,
};

const FlipperAppPluginDescriptor* lfrfid_cli_plugin_ep(void) {
return &plugin_descriptor;
}
11 changes: 0 additions & 11 deletions applications/main/lfrfid/lfrfid_start.c

This file was deleted.

2 changes: 1 addition & 1 deletion applications/main/nfc/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,6 @@ App(
targets=["f7"],
apptype=FlipperAppType.STARTUP,
entry_point="nfc_on_system_start",
sources=["nfc_start.c"],
sources=["nfc_cli.c"],
order=30,
)
18 changes: 9 additions & 9 deletions applications/main/nfc/nfc_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ static void nfc_cli(Cli* cli, FuriString* args, void* context) {
furi_string_free(cmd);
}

#include <flipper_application/flipper_application.h>
#include <cli/cli_i.h>
CLI_PLUGIN_WRAPPER("nfc", nfc_cli)

static const FlipperAppPluginDescriptor plugin_descriptor = {
.appid = CLI_PLUGIN_APP_ID,
.ep_api_version = CLI_PLUGIN_API_VERSION,
.entry_point = &nfc_cli,
};

const FlipperAppPluginDescriptor* nfc_cli_plugin_ep(void) {
return &plugin_descriptor;
void nfc_on_system_start(void) {
#ifdef SRV_CLI
Cli* cli = furi_record_open(RECORD_CLI);
cli_add_command(cli, "nfc", CliCommandFlagDefault, nfc_cli_wrapper, NULL);
furi_record_close(RECORD_CLI);
#else
UNUSED(nfc_cli);
#endif
}
11 changes: 0 additions & 11 deletions applications/main/nfc/nfc_start.c

This file was deleted.

2 changes: 1 addition & 1 deletion applications/main/onewire/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ App(
appid="onewire_start",
apptype=FlipperAppType.STARTUP,
entry_point="onewire_on_system_start",
sources=["onewire_start.c"],
sources=["onewire_cli.c"],
order=60,
)
28 changes: 15 additions & 13 deletions applications/main/onewire/onewire_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@

#include <one_wire/one_wire_host.h>

static void onewire_cli(Cli* cli, FuriString* args, void* context);

#include <cli/cli_i.h>
CLI_PLUGIN_WRAPPER("onewire", onewire_cli)

void onewire_on_system_start(void) {
#ifdef SRV_CLI
Cli* cli = furi_record_open(RECORD_CLI);
cli_add_command(cli, "onewire", CliCommandFlagDefault, onewire_cli_wrapper, cli);
furi_record_close(RECORD_CLI);
#else
UNUSED(onewire_cli);
#endif
}

static void onewire_cli_print_usage(void) {
printf("Usage:\r\n");
printf("onewire search\r\n");
Expand Down Expand Up @@ -58,16 +73,3 @@ void onewire_cli(Cli* cli, FuriString* args, void* context) {

furi_string_free(cmd);
}

#include <flipper_application/flipper_application.h>
#include <cli/cli_i.h>

static const FlipperAppPluginDescriptor plugin_descriptor = {
.appid = CLI_PLUGIN_APP_ID,
.ep_api_version = CLI_PLUGIN_API_VERSION,
.entry_point = &onewire_cli,
};

const FlipperAppPluginDescriptor* onewire_cli_plugin_ep(void) {
return &plugin_descriptor;
}
11 changes: 0 additions & 11 deletions applications/main/onewire/onewire_start.c

This file was deleted.

4 changes: 2 additions & 2 deletions applications/main/subghz/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ App(
appid="subghz_cli",
targets=["f7"],
apptype=FlipperAppType.PLUGIN,
entry_point="subghz_cli_plugin_ep",
entry_point="subghz_cli_command_plugin_ep",
requires=["cli"],
sources=["subghz_cli.c", "helpers/subghz_chat.c"],
)
Expand All @@ -59,7 +59,7 @@ App(
targets=["f7"],
apptype=FlipperAppType.STARTUP,
entry_point="subghz_on_system_start",
# sources=["subghz_start.c"],
# sources=["subghz_cli.c"],
order=40,
)

Expand Down
25 changes: 17 additions & 8 deletions applications/main/subghz/subghz_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -1185,15 +1185,24 @@ static void subghz_cli_command(Cli* cli, FuriString* args, void* context) {
furi_string_free(cmd);
}

#include <flipper_application/flipper_application.h>
#include <cli/cli_i.h>
CLI_PLUGIN_WRAPPER("subghz", subghz_cli_command)

static const FlipperAppPluginDescriptor plugin_descriptor = {
.appid = CLI_PLUGIN_APP_ID,
.ep_api_version = CLI_PLUGIN_API_VERSION,
.entry_point = &subghz_cli_command,
};
static void subghz_cli_command_chat_wrapper(Cli* cli, FuriString* args, void* context) {
furi_string_replace_at(args, 0, 0, "chat ");
subghz_cli_command_wrapper(cli, args, context);
}

void subghz_on_system_start(void) {
#ifdef SRV_CLI
Cli* cli = furi_record_open(RECORD_CLI);

cli_add_command(cli, "subghz", CliCommandFlagDefault, subghz_cli_command_wrapper, NULL);
cli_add_command(cli, "chat", CliCommandFlagDefault, subghz_cli_command_chat_wrapper, NULL);

const FlipperAppPluginDescriptor* subghz_cli_plugin_ep(void) {
return &plugin_descriptor;
furi_record_close(RECORD_CLI);
#else
UNUSED(subghz_cli_command);
UNUSED(subghz_cli_command_chat_wrapper);
#endif
}
Loading

0 comments on commit 2e7eedf

Please sign in to comment.