Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Findmyflipper - Merge fixes to dev #18

Merged
merged 20 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 60 additions & 45 deletions applications/services/gui/modules/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,47 +348,68 @@ static void menu_draw_callback(Canvas* canvas, void* _model) {

break;
}
case MenuStyleTerminal: {
// Draw a border around the screen
canvas_draw_frame(canvas, 0, 0, 128, 64);

// current dir on the title bar
canvas_set_font(canvas, FontSecondary);
case MenuStyleMNTM: {
// Reset canvas and set background
canvas_reset(canvas);
canvas_set_color(canvas, ColorBlack);
canvas_clear(canvas);
canvas_set_bitmap_mode(canvas, true);
canvas_set_font(canvas, FontPrimary);
canvas_draw_str(canvas, 5, 13, "Momentum");
canvas_draw_icon(canvas, 62, 4, &I_Release_arrow_18x15);
canvas_draw_line(canvas, 5, 15, 59, 15);
canvas_draw_line(canvas, 7, 17, 61, 17);
canvas_draw_line(canvas, 10, 19, 63, 19);
char title[20];
snprintf(title, sizeof(title), "%s@fz: ~/Home", furi_hal_version_get_name_ptr());
canvas_draw_str(canvas, 20, 10, title);

canvas_draw_str(canvas, 118, 9, "x"); // "X" button on the top-right corner
canvas_draw_frame(canvas, 116, 2, 8, 9);
canvas_draw_frame(canvas, 0, 0, 128, 13);

// Display the user's name line at the bottom
canvas_set_font(canvas, FontBatteryPercent);
char prefix[15];
snprintf(prefix, sizeof(prefix), "%s@fz:~$", furi_hal_version_get_name_ptr());
canvas_draw_str(canvas, 2, 56, prefix);

size_t name_start_x = 2 + (strlen(prefix) - 1) * 6;
snprintf(title, sizeof(title), "%s", furi_hal_version_get_name_ptr());
canvas_draw_str(canvas, 5, 34, title);
DateTime curr_dt;
furi_hal_rtc_get_datetime(&curr_dt);
int hour = curr_dt.hour;
int min = curr_dt.minute;
if(hour > 12) {
hour -= 12;
}
if(hour == 0) {
hour = 12;
}
canvas_set_font(canvas, FontSecondary);
char clk[20];
snprintf(clk, sizeof(clk), "%02u:%02u", hour, min);
canvas_draw_str(canvas, 5, 46, clk);

// Draw the selected menu item
MenuItem* item = MenuItemArray_get(model->items, position);
FuriString* name = furi_string_alloc();
menu_short_name(item, name);
canvas_set_font(canvas, FontSecondary);
canvas_set_color(canvas, ColorBlack);
elements_bold_rounded_frame(canvas, 42, 23, 35, 33);
menu_centered_icon(canvas, item, 43, 24, 35, 32);
canvas_draw_frame(canvas, 0, 0, 128, 64);

for(size_t i = 0; i < 4 && (position + i) < items_count; i++) {
item = MenuItemArray_get(model->items, position + i);
int startY = 15;
int itemHeight = 10;
int itemMaxVisible = 5;
size_t startItem = model->vertical_offset;
size_t endItem = startItem + itemMaxVisible;
endItem = (endItem > MenuItemArray_size(model->items)) ?
MenuItemArray_size(model->items) :
endItem;
size_t scroll_counter = menu_scroll_counter(model, item);

for(size_t i = startItem; i < endItem; i++) {
MenuItem* item = MenuItemArray_get(model->items, i);
FuriString* name = furi_string_alloc();
menu_short_name(item, name);

size_t scroll_counter = menu_scroll_counter(model, item);
if(i == 0) {
// Display selected item to the right of the $ symbol
// May want to reduce spacing
elements_scrollable_text_line(
canvas, name_start_x, 56, 60, name, scroll_counter, false);
} else {
// Display the previous items above the user's name line
canvas_draw_str(canvas, 2, 56 - i * 12, item->label);
}
int yPos = startY + ((i - startItem) * itemHeight);
elements_scrollable_text_line(canvas, 83, yPos, 62, name, scroll_counter, false);
furi_string_free(name);
}

furi_string_free(name);
canvas_commit(canvas);
break;
}

default:
break;
}
Expand Down Expand Up @@ -614,16 +635,13 @@ static void menu_process_up(Menu* menu) {

switch(momentum_settings.menu_style) {
case MenuStyleList:
case MenuStyleTerminal:
case MenuStyleMNTM:
if(position > 0) {
position--;
if(vertical_offset && vertical_offset == position) {
vertical_offset--;
}
} else {
position = count - 1;
vertical_offset = count - 8;
}
vertical_offset = position;
break;
case MenuStyleWii:
if(position % 2 || (position == count - 1 && count % 2)) {
Expand Down Expand Up @@ -665,16 +683,13 @@ static void menu_process_down(Menu* menu) {

switch(momentum_settings.menu_style) {
case MenuStyleList:
case MenuStyleTerminal:
case MenuStyleMNTM:
if(position < count - 1) {
position++;
if(vertical_offset < count - 8 && vertical_offset == position - 7) {
vertical_offset++;
}
} else {
position = 0;
vertical_offset = 0;
}
vertical_offset = position;
break;
case MenuStyleWii:
if(position % 2 || (position == count - 1 && count % 2)) {
Expand Down
74 changes: 74 additions & 0 deletions applications/system/findmy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# FindMy Flipper - FindMy SmartTag Emulator

This app extends the functionality of the FlipperZero's bluetooth capabilities, enabling it to act as an Apple AirTag or Samsung SmartTag, or even both simultaneously. It utilizes the FlipperZero's BLE beacon to broadcast a SmartTag signal to be picked up by the FindMy Network. I made this to serve as a versatile tool for tracking purposes, offering the ability to clone existing tags, generate OpenHaystack key pairs for integration with Apple's FindMy network, and tune the device's beacon broadcast settings.

## Features

1. Tag Emulation: Clone your existing Apple AirTag or Samsung SmartTag to the FlipperZero, or generate a key pair for use with the FindMy network without owning an actual AirTag.
2. Customization: Users can adjust the interval between beacon broadcasts and modify the transmit power to suit their needs, optimizing for both visibility and battery life.
3. Efficient Background Operation: The app is optimized to run in the background, ensuring that your FlipperZero can still be tracked with minimal battery usage and without stopping normal use.

## Usage Guide

### Step 1: Installation
- **Option A:** Use the released/precompiled firmware appropriate (FAP) for your device.
- **Option B:** Build the firmware yourself using `fbt/ufbt`.
- Both Installation options require you to be running a dev build of firmware. When release gets access to the extra BLE beacon this will change, thank you!
### Step 2: Obtaining SmartTag Data

#### Option A: Open Haystack Method
1. **Generate a Tag:** Download the `generate_keys.py` file and execute it in your terminal. (You will need cryptography ```python3 -m pip install cryptography```)
2. **Follow Prompts:** During execution, you'll be prompted for inputs. By the end, you'll obtain a **Private Key**, **Public Key**, **Payload**, and **MAC Address**.
- **Private Key** is necessary to receive location reports from Apple.
- **MAC Address** should be registered in the FlipperZero app:
1. Open the app and navigate to the config menu.
2. Choose "register tag" and enter the MAC Address when prompted.
3. A payload dialog will appear next. Enter your **Payload** here.
4. Click save.
3. **Configuration Completion:** With this setup, your device is ready for Open Haystack. Proceed with the specific steps for Open Haystack or MaclessHaystack based on your setup.
- Don't Own a Mac: https://github.com/dchristl/macless-haystack
- Own a Mac: https://github.com/seemoo-lab/openhaystack

#### Option B: Cloning Existing Tag
1. **Pair a Tag:** First, pair an AirTag or Samsung SmartTag with your device.
2. **Enter 'Lost' Mode:** Keep the tag away from the device it's registered to for approximately 15 minutes.
3. **Download nrfConnect:** Install nrfConnect from the Apple App Store or Google Play Store.
4. **Filter and Scan:**
- Open the app, click on filters, and exclude all except for the brand of your tag (Apple/Samsung).
- Adjust the RSSI to the lowest setting (-40 dBm).
- Initiate a scan. Wait for your SmartTag to appear as a "FindMy" device.
5. **Capture Data:** Click **Raw** or **View Raw** to capture your **payload** and note your tag's **MAC Address**. Immediately remove the tag's battery to prevent key/MAC rotation.
6. **Enter Data in FlipperZero App:** Input the captured **payload** and **MAC Address** into the FlipperZero app.

### Step 3: Configuration
- Upon launching the app, choose whether to clone an AirTag or SmartTag, generate a new Open Haystack key pair, or adjust broadcast settings.

### Step 4: Tracking
- Once the app is configured, your FlipperZero can be tracked using the relevant platform's tracking service (FindMy app for Apple devices, SmartThings for Samsung devices, and respective web browsers).


Customization

- Beacon Interval: Adjust how frequently your FlipperZero broadcasts its presence.
- Transmit Power: Increase or decrease the signal strength to balance between tracking range and battery life.

Background Use

The app is designed to have a negligible impact on battery life, even when running in the background. This allows for continuous tracking without the need for frequent recharging.

Compatibility

- Apple devices for AirTag tracking via the FindMy network.
- Any device that supports Samsung SmartTag tracking, including web browsers (previously FindMyMobile).

Thanks

- Huge thanks to all the people that contributed to the OpenHaystack project, supporting projects, and guides on the subject. This wouldn't be a thing without any of you!

Legal and Privacy

This app is intended for personal and educational use. Users are responsible for complying with local privacy laws and regulations regarding tracking devices. The cloning and emulation of tracking tags should be done responsibly and with respect to the ownership of the original devices.

Disclaimer

This project is not affiliated with Apple Inc. or Samsung. All product names, logos, and brands are property of their respective owners. Use this app responsibly and ethically.
5 changes: 3 additions & 2 deletions applications/system/findmy/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ App(
apptype=FlipperAppType.EXTERNAL,
entry_point="findmy_main",
requires=["gui"],
stack_size=1 * 1024,
order=35,
stack_size=2 * 1024,
fap_icon="location_icon.png",
fap_icon_assets="icons",
fap_category="Bluetooth",
fap_author="@MatthewKuKanich",
fap_weburl="https://github.com/MatthewKuKanich/FindMyFlipper",
fap_version="1.0",
fap_description="BLE FindMy Location Beacon",
)
Loading
Loading