mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-16 04:24:45 -07:00
Refactor packet types and sizes --nobuild
This commit is contained in:
@@ -21,14 +21,6 @@ typedef struct {
|
|||||||
static Payload
|
static Payload
|
||||||
payloads[] =
|
payloads[] =
|
||||||
{
|
{
|
||||||
{.title = "Random Action",
|
|
||||||
.text = "Spam shuffle Nearby Actions",
|
|
||||||
.random = true,
|
|
||||||
.msg =
|
|
||||||
{
|
|
||||||
.type = ContinuityTypeNearbyAction,
|
|
||||||
.data = {.nearby_action = {.type = 0x00}},
|
|
||||||
}},
|
|
||||||
{.title = "Random Pair",
|
{.title = "Random Pair",
|
||||||
.text = "Spam shuffle Proximity Pairs",
|
.text = "Spam shuffle Proximity Pairs",
|
||||||
.random = true,
|
.random = true,
|
||||||
@@ -37,6 +29,14 @@ static Payload
|
|||||||
.type = ContinuityTypeProximityPair,
|
.type = ContinuityTypeProximityPair,
|
||||||
.data = {.proximity_pair = {.prefix = 0x00, .model = 0x0000}},
|
.data = {.proximity_pair = {.prefix = 0x00, .model = 0x0000}},
|
||||||
}},
|
}},
|
||||||
|
{.title = "Random Action",
|
||||||
|
.text = "Spam shuffle Nearby Actions",
|
||||||
|
.random = true,
|
||||||
|
.msg =
|
||||||
|
{
|
||||||
|
.type = ContinuityTypeNearbyAction,
|
||||||
|
.data = {.nearby_action = {.type = 0x00}},
|
||||||
|
}},
|
||||||
{.title = "AirPods Pro",
|
{.title = "AirPods Pro",
|
||||||
.text = "Modal, spammy (auto close)",
|
.text = "Modal, spammy (auto close)",
|
||||||
.random = false,
|
.random = false,
|
||||||
@@ -385,6 +385,7 @@ int32_t apple_ble_spam(void* p) {
|
|||||||
randoms[payloads[payload_i].msg.type].count++;
|
randoms[payloads[payload_i].msg.type].count++;
|
||||||
}
|
}
|
||||||
for(ContinuityType type = 0; type < ContinuityTypeCount; type++) {
|
for(ContinuityType type = 0; type < ContinuityTypeCount; type++) {
|
||||||
|
if(!randoms[type].count) continue;
|
||||||
randoms[type].datas = malloc(sizeof(ContinuityData*) * randoms[type].count);
|
randoms[type].datas = malloc(sizeof(ContinuityData*) * randoms[type].count);
|
||||||
size_t random_i = 0;
|
size_t random_i = 0;
|
||||||
for(size_t payload_i = 0; payload_i < COUNT_OF(payloads); payload_i++) {
|
for(size_t payload_i = 0; payload_i < COUNT_OF(payloads); payload_i++) {
|
||||||
|
|||||||
@@ -7,40 +7,36 @@
|
|||||||
// Custom adv logic and Airtag ID from https://techryptic.github.io/2023/09/01/Annoying-Apple-Fans/
|
// Custom adv logic and Airtag ID from https://techryptic.github.io/2023/09/01/Annoying-Apple-Fans/
|
||||||
|
|
||||||
static const char* continuity_type_names[ContinuityTypeCount] = {
|
static const char* continuity_type_names[ContinuityTypeCount] = {
|
||||||
[ContinuityTypeNearbyAction] = "Nearby Action",
|
|
||||||
[ContinuityTypeProximityPair] = "Proximity Pair",
|
[ContinuityTypeProximityPair] = "Proximity Pair",
|
||||||
|
[ContinuityTypeNearbyAction] = "Nearby Action",
|
||||||
};
|
};
|
||||||
const char* continuity_get_type_name(ContinuityType type) {
|
const char* continuity_get_type_name(ContinuityType type) {
|
||||||
return continuity_type_names[type];
|
return continuity_type_names[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t continuity_packet_sizes[ContinuityTypeCount] = {
|
static size_t continuity_packet_sizes[ContinuityTypeCount] = {
|
||||||
[ContinuityTypeNearbyAction] = 11,
|
|
||||||
[ContinuityTypeProximityPair] = 31,
|
[ContinuityTypeProximityPair] = 31,
|
||||||
|
[ContinuityTypeNearbyAction] = 11,
|
||||||
};
|
};
|
||||||
size_t continuity_get_packet_size(ContinuityType type) {
|
size_t continuity_get_packet_size(ContinuityType type) {
|
||||||
return continuity_packet_sizes[type];
|
return continuity_packet_sizes[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
void continuity_generate_packet(const ContinuityMsg* msg, uint8_t* packet) {
|
void continuity_generate_packet(const ContinuityMsg* msg, uint8_t* packet) {
|
||||||
|
size_t size = continuity_get_packet_size(msg->type);
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
packet[i++] = continuity_get_packet_size(msg->type) - 1;
|
|
||||||
packet[i++] = 0xff;
|
packet[i] = size - i - 1; // Packet Length
|
||||||
packet[i++] = 0x4c;
|
i++;
|
||||||
packet[i++] = 0x00;
|
packet[i++] = 0xff; // Packet Header
|
||||||
|
packet[i++] = 0x4c; // ...
|
||||||
|
packet[i++] = 0x00; // ...
|
||||||
|
packet[i++] = msg->type; // Type
|
||||||
|
packet[i] = size - i - 1; // Message Length
|
||||||
|
i++;
|
||||||
|
|
||||||
switch(msg->type) {
|
switch(msg->type) {
|
||||||
case ContinuityTypeNearbyAction:
|
|
||||||
packet[i++] = 0x0f; // Type (Nearby Action)
|
|
||||||
packet[i++] = 0x05; // Length
|
|
||||||
packet[i++] = 0xc1; // Action Flags
|
|
||||||
packet[i++] = msg->data.nearby_action.type;
|
|
||||||
packet[i++] = (rand() % 256); // Authentication Tag
|
|
||||||
packet[i++] = (rand() % 256); // ...
|
|
||||||
packet[i++] = (rand() % 256); // ...
|
|
||||||
break;
|
|
||||||
case ContinuityTypeProximityPair:
|
case ContinuityTypeProximityPair:
|
||||||
packet[i++] = 0x07; // Type (Proximity Pair)
|
|
||||||
packet[i++] = 0x19; // Length
|
|
||||||
packet[i++] = msg->data.proximity_pair.prefix; // Prefix (paired 0x01 new0x07 airtag 0x05)
|
packet[i++] = msg->data.proximity_pair.prefix; // Prefix (paired 0x01 new0x07 airtag 0x05)
|
||||||
packet[i++] = msg->data.proximity_pair.model >> 8;
|
packet[i++] = msg->data.proximity_pair.model >> 8;
|
||||||
packet[i++] = msg->data.proximity_pair.model & 0xFF;
|
packet[i++] = msg->data.proximity_pair.model & 0xFF;
|
||||||
@@ -67,6 +63,15 @@ void continuity_generate_packet(const ContinuityMsg* msg, uint8_t* packet) {
|
|||||||
packet[i++] = (rand() % 256); // ...
|
packet[i++] = (rand() % 256); // ...
|
||||||
packet[i++] = (rand() % 256); // ...
|
packet[i++] = (rand() % 256); // ...
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ContinuityTypeNearbyAction:
|
||||||
|
packet[i++] = 0xc1; // Action Flags
|
||||||
|
packet[i++] = msg->data.nearby_action.type;
|
||||||
|
packet[i++] = (rand() % 256); // Authentication Tag
|
||||||
|
packet[i++] = (rand() % 256); // ...
|
||||||
|
packet[i++] = (rand() % 256); // ...
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,19 +9,19 @@
|
|||||||
// Custom adv logic and Airtag ID from https://techryptic.github.io/2023/09/01/Annoying-Apple-Fans/
|
// Custom adv logic and Airtag ID from https://techryptic.github.io/2023/09/01/Annoying-Apple-Fans/
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ContinuityTypeNearbyAction,
|
ContinuityTypeProximityPair = 0x07,
|
||||||
ContinuityTypeProximityPair,
|
ContinuityTypeNearbyAction = 0x0F,
|
||||||
ContinuityTypeCount
|
ContinuityTypeCount
|
||||||
} ContinuityType;
|
} ContinuityType;
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
struct {
|
|
||||||
uint8_t type;
|
|
||||||
} nearby_action;
|
|
||||||
struct {
|
struct {
|
||||||
uint8_t prefix;
|
uint8_t prefix;
|
||||||
uint16_t model;
|
uint16_t model;
|
||||||
} proximity_pair;
|
} proximity_pair;
|
||||||
|
struct {
|
||||||
|
uint8_t type;
|
||||||
|
} nearby_action;
|
||||||
} ContinuityData;
|
} ContinuityData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user