Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kbembedded committed Jun 5, 2024
0 parents commit 34d6c6b
Show file tree
Hide file tree
Showing 23 changed files with 974 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "FAP: Build for multiple SDK sources"
# This will build your app for dev and release channels on GitHub.
# It will also build your app every day to make sure it's up to date with the latest SDK changes.
# See https://github.com/marketplace/actions/build-flipper-application-package-fap for more information

on:
pull_request:
schedule:
# do a build every day
- cron: "1 1 * * *"

jobs:
ufbt-build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: dev channel
sdk-channel: dev
- name: release channel
sdk-channel: release
# You can add unofficial channels here. See ufbt action docs for more info.
name: 'ufbt: Build for ${{ matrix.name }}'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build with ufbt
uses: flipperdevices/[email protected]
id: build-app
with:
sdk-channel: ${{ matrix.sdk-channel }}
- name: Upload app artifacts
uses: actions/upload-artifact@v4
with:
# See ufbt action docs for other output variables
name: ${{ github.event.repository.name }}-${{ steps.build-app.outputs.suffix }}
path: ${{ steps.build-app.outputs.fap-artifacts }}
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "FAP: Build/release for release SDK"
# This will build your app for dev and release channels on GitHub.
# It will also build your app every day to make sure it's up to date with the latest SDK changes.
# See https://github.com/marketplace/actions/build-flipper-application-package-fap for more information

on:
workflow_dispatch:
push:
tags:
- v[0-9]+.[0-9]+

jobs:
ufbt-build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: release channel
sdk-channel: release
# You can add unofficial channels here. See ufbt action docs for more info.
name: 'ufbt: Build for ${{ matrix.name }}'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build with ufbt
uses: flipperdevices/[email protected]
id: build-app
with:
sdk-channel: ${{ matrix.sdk-channel }}
- name: Upload app artifacts
uses: actions/upload-artifact@v4
with:
# See ufbt action docs for other output variables
name: ${{ github.event.repository.name }}-${{ steps.build-app.outputs.suffix }}
path: ${{ steps.build-app.outputs.fap-artifacts }}
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
${{ steps.build-app.outputs.fap-artifacts }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
.vscode/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "lib/nanopb"]
path = lib/nanopb
url = https://github.com/nanopb/nanopb
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BSD 2-Clause License

Copyright (c) 2024, Kris Bahnsen

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Frequency Liberation and Interchangeable Country Kit

## FAQ
**Q:** What is this?

**A:** You'll figure it out.

---

**Q:** Why not just use one of the many custom firmwares that exist?

**A:** I prefer the stability, support, and ease of use of the official firmware. Why make a whole fork that I gotta maintain when I can make a single app that will work with minimal update chasing needed?

---

**Q:** How do I use this app?

**A:** Run it, select `FLICK` to FLICK your Flipper (keeping a backup of the original data on the SD card). If its been FLICK'ed, an option to un-FLICK will appear; this will restore the data from SD card back to the flipper.

---

**Q:** What is the password to FLICK my Flipper?

**A:** Read the EULA, or the source code; you'll figure it out. Gotta make it just annoying/difficult enough for the skids to lose interest.

---

**Q:** Is it safe?

**A:** Probably! I made sure the max power is the same as the max power that the official firmware uses for any given region. More power than most, and it probably won't damage anything. But I can't promise anything, use this at your own risk.

---

**Q:** What is the app icon?

**A:** Coffee bean. If you can make a better looking one, open a PR please.

---

**Q:** I want XYZ feature!

**A:** Great! Open a PR.

---

## Testimonials
*"This tool has been fantastic in being able to use my Flipper with my garage door in a region that normally wouldn't let me do that. 10/10 stars!"*

-- Me, the creator of this app
19 changes: 19 additions & 0 deletions application.fam
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
App(
appid="flick", # Must be unique
name="FLICK", # Displayed in menus
apptype=FlipperAppType.EXTERNAL,
entry_point="flick_app",
stack_size=2 * 1024,
fap_category="Sub-Ghz",
# Optional values
fap_version="1.0",
fap_icon="flick.png", # 10x10 1-bit PNG
fap_description="Frequency Liberation and Interchangeable Country Kit",
fap_author="KBEmbedded",
fap_extbuild=(
ExtFile(
path=[ "${FAP_WORK_DIR}/flick.pb.c", "${FAP_WORK_DIR}/flick.pb.h" ],
command="${FAP_SRC_DIR}/lib/nanopb/generator/protoc --nanopb_out=${FAP_WORK_DIR} --nanopb_opt=-I${FAP_SRC_DIR} -I${FAP_SRC_DIR} flick.proto",
),
),
)
128 changes: 128 additions & 0 deletions flick.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#include <furi.h>

/* GUI handling */
#include <gui/view_dispatcher.h>
#include <gui/scene_manager.h>
#include <gui/modules/dialog_ex.h>
#include <gui/modules/popup.h>
#include <gui/modules/submenu.h>
#include <gui/modules/text_box.h>
#include <gui/modules/text_input.h>
#include <storage/storage.h>

/* Main application struct */
#include "flick_data.h"

/* Scene list produced by overly-complex-but-still-probably-the-best-way-to-
* maintain macro hell.
*/
#include "scenes/flick_scene.h"

struct flick_app *flick_alloc(void)
{
struct flick_app *flick = malloc(sizeof(struct flick_app));
Storage *storage;

/* View dispatcher setup
* This probably isn't needed since we're using scenes mostly, but, I
* already know this paradigm and its easy to spit out.
*/
flick->view_dispatcher = view_dispatcher_alloc();
view_dispatcher_enable_queue(flick->view_dispatcher);
view_dispatcher_set_event_callback_context(flick->view_dispatcher, flick);
view_dispatcher_attach_to_gui(flick->view_dispatcher,
(Gui *)furi_record_open(RECORD_GUI),
ViewDispatcherTypeFullscreen);

/* Submenu */
flick->submenu = submenu_alloc();
view_dispatcher_add_view(flick->view_dispatcher,
FlickViewMenu,
submenu_get_view(flick->submenu));

/* Popup */
flick->popup = popup_alloc();
view_dispatcher_add_view(flick->view_dispatcher,
FlickViewPopup,
popup_get_view(flick->popup));

/* DialogEx */
flick->dialog_ex = dialog_ex_alloc();
view_dispatcher_add_view(flick->view_dispatcher,
FlickViewDialogEx,
dialog_ex_get_view(flick->dialog_ex));

/* TextBox */
flick->text_box = text_box_alloc();
view_dispatcher_add_view(flick->view_dispatcher,
FlickViewTextBox,
text_box_get_view(flick->text_box));

/* TextInput */
flick->text_input = text_input_alloc();
view_dispatcher_add_view(flick->view_dispatcher,
FlickViewTextInput,
text_input_get_view(flick->text_input));

/* Path for data folder */
storage = furi_record_open(RECORD_STORAGE);
flick->data_path = furi_string_alloc_set(APP_DATA_PATH());
storage_common_resolve_path_and_ensure_app_directory(storage, flick->data_path);
furi_record_close(RECORD_STORAGE);

/* Scene management */
flick->scene_manager = scene_manager_alloc(&flick_scene_handlers, flick);
scene_manager_next_scene(flick->scene_manager, FlickSceneMainMenu);

return flick;
}

void flick_free(struct flick_app *flick)
{
/* Asset folder path */
furi_string_free(flick->data_path);

/* TextInput */
view_dispatcher_remove_view(flick->view_dispatcher, FlickViewTextInput);
text_input_free(flick->text_input);

/* TextBox */
view_dispatcher_remove_view(flick->view_dispatcher, FlickViewTextBox);
text_box_free(flick->text_box);

/* DiaglogEx */
view_dispatcher_remove_view(flick->view_dispatcher, FlickViewDialogEx);
dialog_ex_free(flick->dialog_ex);

/* Popup */
view_dispatcher_remove_view(flick->view_dispatcher, FlickViewPopup);
popup_free(flick->popup);

/* SubMenu */
view_dispatcher_remove_view(flick->view_dispatcher, FlickViewMenu);
submenu_free(flick->submenu);

/* ViewDispatcher */
view_dispatcher_free(flick->view_dispatcher);

/* Path for data folder */
furi_string_free(flick->data_path);

/* Scene Manager */
scene_manager_free(flick->scene_manager);

free(flick);
}

int32_t flick_app(void* p) {
UNUSED(p);

struct flick_app *flick;
flick = flick_alloc();

view_dispatcher_run(flick->view_dispatcher);

flick_free(flick);

return 0;
}
4 changes: 4 additions & 0 deletions flick.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
PB.Region.country_code type:FT_POINTER
PB.Region.country_code max_size:2
PB.Region.Band.power_limit int_size:IS_8
PB.Region.Band.duty_cycle int_size:IS_8
Binary file added flick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions flick.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";

package PB;

message Region {
message Band {
uint32 start = 1;
uint32 end = 2;
int32 power_limit = 3;
uint32 duty_cycle = 4;
}

bytes country_code = 1;
repeated Band bands = 2;
}
33 changes: 33 additions & 0 deletions flick_data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef __FLICK_DATA_H__
#define __FLICK_DATA_H__

#include <gui/view_dispatcher.h>
#include <gui/scene_manager.h>
#include <gui/modules/dialog_ex.h>
#include <gui/modules/popup.h>
#include <gui/modules/submenu.h>
#include <gui/modules/text_box.h>
#include <gui/modules/text_input.h>

struct flick_app {
ViewDispatcher *view_dispatcher;
SceneManager *scene_manager;
DialogEx *dialog_ex;
Popup *popup;
Submenu *submenu;
TextBox *text_box;
TextInput *text_input;
FuriString *data_path;
};

/* Views */
enum {
FlickViewMenu,
FlickViewDialogEx,
FlickViewPopup,
FlickViewTextBox,
FlickViewTextInput,
FlickViewNum
};

#endif // __FLICK_DATA_H__
1 change: 1 addition & 0 deletions lib/nanopb
Submodule nanopb added at afc499
Loading

0 comments on commit 34d6c6b

Please sign in to comment.