-
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- state handled reparately, decoupled from app - better apple/samsung/unknown parsing and handling - improve error handling - add url to manifest + up stack size just in case
- Loading branch information
Showing
12 changed files
with
176 additions
and
106 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#pragma once | ||
|
||
typedef struct FindMy FindMy; | ||
|
||
typedef enum FindMyType FindMyType; |
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "findmy_state.h" | ||
|
||
#include <string.h> | ||
#include <stddef.h> | ||
#include <furi_hal_bt.h> | ||
|
||
bool findmy_state_load(FindMyState* out_state) { | ||
FindMyState state; | ||
|
||
// Set default values | ||
state.beacon_active = false; | ||
state.broadcast_interval = 5; | ||
state.transmit_power = 6; | ||
state.config.min_adv_interval_ms = state.broadcast_interval * 1000; // Converting s to ms | ||
state.config.max_adv_interval_ms = (state.broadcast_interval * 1000) + 150; | ||
state.config.adv_channel_map = GapAdvChannelMapAll; | ||
state.config.adv_power_level = GapAdvPowerLevel_0dBm + state.transmit_power; | ||
state.config.address_type = GapAddressTypePublic; | ||
|
||
// Set default mac | ||
uint8_t default_mac[EXTRA_BEACON_MAC_ADDR_SIZE] = {0x66, 0x55, 0x44, 0x33, 0x22, 0x11}; | ||
memcpy(state.mac, default_mac, sizeof(state.mac)); | ||
memcpy(state.config.address, default_mac, sizeof(state.config.address)); | ||
|
||
// Set default empty AirTag data | ||
uint8_t* data = state.data; | ||
*data++ = 0x1E; // Length | ||
*data++ = 0xFF; // Manufacturer Specific Data | ||
*data++ = 0x4C; // Company ID (Apple, Inc.) | ||
*data++ = 0x00; // ... | ||
*data++ = 0x12; // Type (FindMy) | ||
*data++ = 0x19; // Length | ||
*data++ = 0x00; // Status | ||
// Placeholder Empty Public Key without the MAC address | ||
for(size_t i = 0; i < 22; ++i) { | ||
*data++ = 0x00; | ||
} | ||
*data++ = 0x00; // First 2 bits are the version, the rest is the battery level | ||
*data++ = 0x00; // Hint (0x00) | ||
|
||
// Copy to caller state before popping stack | ||
memcpy(out_state, &state, sizeof(state)); | ||
|
||
// Return if active, can be used to start after loading in an if statement | ||
return state.beacon_active; | ||
} | ||
|
||
void findmy_state_apply(FindMyState* state) { | ||
// Stop any running beacon | ||
if(furi_hal_bt_extra_beacon_is_active()) { | ||
furi_check(furi_hal_bt_extra_beacon_stop()); | ||
} | ||
|
||
furi_check(furi_hal_bt_extra_beacon_set_config(&state->config)); | ||
|
||
furi_check(furi_hal_bt_extra_beacon_set_data(state->data, sizeof(state->data))); | ||
|
||
if(state->beacon_active) { | ||
furi_check(furi_hal_bt_extra_beacon_start()); | ||
} | ||
} |
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,17 @@ | ||
#pragma once | ||
|
||
#include <extra_beacon.h> | ||
|
||
typedef struct { | ||
uint8_t mac[EXTRA_BEACON_MAC_ADDR_SIZE]; | ||
uint8_t data[EXTRA_BEACON_MAX_DATA_SIZE]; | ||
GapExtraBeaconConfig config; | ||
|
||
bool beacon_active; | ||
uint8_t broadcast_interval; | ||
uint8_t transmit_power; | ||
} FindMyState; | ||
|
||
bool findmy_state_load(FindMyState* out_state); | ||
|
||
void findmy_state_apply(FindMyState* state); |
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
Oops, something went wrong.