Skip to content

Commit

Permalink
Merge pull request #41 from ckcr4lyf/patch/fix-multiple-version
Browse files Browse the repository at this point in the history
Conditional Compilation for ESP32-Arduino v2/v3 breaking changes
  • Loading branch information
ckcr4lyf authored Jul 8, 2024
2 parents deaabbd + e477b41 commit 6ef1aa1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
18 changes: 15 additions & 3 deletions src/EvilAppleJuice-ESP32-INO/EvilAppleJuice-ESP32-INO.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#include <esp_arduino_version.h>

// Bluetooth maximum transmit power
#if defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C2) || defined(CONFIG_IDF_TARGET_ESP32S3)
Expand Down Expand Up @@ -132,13 +133,24 @@ void loop() {
// First decide short or long
// 0 = long (headphones), 1 = short (misc stuff like Apple TV)
int device_choice = random(2);
//int device_choice = 1;
if (device_choice == 0){
int index = random(17);
oAdvertisementData.addData(std::string((char*)DEVICES[index], 31).c_str());
#ifdef ESP_ARDUINO_VERSION_MAJOR
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
oAdvertisementData.addData(String((char*)DEVICES[index], 31));
#else
oAdvertisementData.addData(std::string((char*)DEVICES[index], 31));
#endif
#endif
} else {
int index = random(13);
oAdvertisementData.addData(std::string((char*)SHORT_DEVICES[index], 23).c_str());
#ifdef ESP_ARDUINO_VERSION_MAJOR
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
oAdvertisementData.addData(String((char*)SHORT_DEVICES[index], 23));
#else
oAdvertisementData.addData(std::string((char*)SHORT_DEVICES[index], 23));
#endif
#endif
}

/* Page 191 of Apple's "Accessory Design Guidelines for Apple Devices (Release R20)" recommends to use only one of
Expand Down
17 changes: 15 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#include <esp_arduino_version.h>

#include "devices.hpp"

Expand Down Expand Up @@ -71,10 +72,22 @@ void loop() {
int device_choice = random(2);
if (device_choice == 0){
int index = random(17);
oAdvertisementData.addData(std::string((char*)DEVICES[index], 31));
#ifdef ESP_ARDUINO_VERSION_MAJOR
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
oAdvertisementData.addData(String((char*)DEVICES[index], 31));
#else
oAdvertisementData.addData(std::string((char*)DEVICES[index], 31));
#endif
#endif
} else {
int index = random(13);
oAdvertisementData.addData(std::string((char*)SHORT_DEVICES[index], 23));
#ifdef ESP_ARDUINO_VERSION_MAJOR
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
oAdvertisementData.addData(String((char*)SHORT_DEVICES[index], 23));
#else
oAdvertisementData.addData(std::string((char*)SHORT_DEVICES[index], 23));
#endif
#endif
}

/* Page 191 of Apple's "Accessory Design Guidelines for Apple Devices (Release R20)" recommends to use only one of
Expand Down

0 comments on commit 6ef1aa1

Please sign in to comment.