Просмотр исходного кода

BleSpam: Restore previous extra beacon config on exit

Willy-JL 1 год назад
Родитель
Сommit
5d0aec99cd
2 измененных файлов с 19 добавлено и 2 удалено
  1. 1 1
      ble_spam/application.fam
  2. 18 1
      ble_spam/ble_spam.c

+ 1 - 1
ble_spam/application.fam

@@ -8,7 +8,7 @@ App(
     fap_category="Bluetooth",
     fap_author="@Willy-JL @ECTO-1A @Spooks4576",
     fap_weburl="https://github.com/Flipper-XFW/Xtreme-Apps/tree/dev/ble_spam",
-    fap_version="5.0",
+    fap_version="5.1",
     fap_description="Flood BLE advertisements to cause spammy and annoying popups/notifications",
     fap_icon_assets="icons",
     fap_icon_assets_symbol="ble_spam",

+ 18 - 1
ble_spam/ble_spam.c

@@ -390,7 +390,7 @@ static void draw_callback(Canvas* canvas, void* _ctx) {
             "App+Spam: \e#WillyJL\e# XFW\n"
             "Apple+Crash: \e#ECTO-1A\e#\n"
             "Android+Win: \e#Spooks4576\e#\n"
-            "                                   Version \e#5.0\e#",
+            "                                   Version \e#5.1\e#",
             false);
         break;
     default: {
@@ -620,6 +620,15 @@ static bool back_event_callback(void* _ctx) {
 
 int32_t ble_spam(void* p) {
     UNUSED(p);
+    GapExtraBeaconConfig prev_cfg;
+    const GapExtraBeaconConfig* prev_cfg_ptr = furi_hal_bt_extra_beacon_get_config();
+    if(prev_cfg_ptr) {
+        memcpy(&prev_cfg, prev_cfg_ptr, sizeof(prev_cfg));
+    }
+    uint8_t prev_data[EXTRA_BEACON_MAX_DATA_SIZE];
+    uint8_t prev_data_len = furi_hal_bt_extra_beacon_get_data(&prev_data);
+    bool prev_active = furi_hal_bt_extra_beacon_is_active();
+
     State* state = malloc(sizeof(State));
     state->config.adv_channel_map = GapAdvChannelMapAll;
     state->config.adv_power_level = GapAdvPowerLevel_6dBm;
@@ -694,5 +703,13 @@ int32_t ble_spam(void* p) {
     furi_timer_free(state->lock_timer);
     furi_thread_free(state->thread);
     free(state);
+
+    if(prev_cfg_ptr) {
+        furi_check(furi_hal_bt_extra_beacon_set_config(&prev_cfg));
+    }
+    furi_check(furi_hal_bt_extra_beacon_set_data(&prev_data, prev_data_len));
+    if(prev_active) {
+        furi_check(furi_hal_bt_extra_beacon_start());
+    }
     return 0;
 }