Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion firmware/ESP32/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build/**
venv/**
.vscode/**
**/*.code-workspace
**/*.code-workspace
sdkconfig.esp32-s3-devkitc-1
4 changes: 2 additions & 2 deletions firmware/ESP32/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)

set(SUPPORTED_TARGETS esp32)
set(SUPPORTED_TARGETS esp32 esp32s3)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(openhaystack)
project(openhaystack)
7 changes: 6 additions & 1 deletion firmware/ESP32/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Macless Haystack Firmware for ESP32

This project contains a battery-optimzed PoC firmware for Espressif ESP32 chips (like ESP32-WROOM or ESP32-WROVER, but _not_ ESP32-S2).
This project contains a battery-optimzed PoC firmware for Espressif ESP32 chips with BLE support (like ESP32-WROOM, ESP32-WROVER, or ESP32-S3, but _not_ ESP32-S2).
After flashing our firmware, the device sends out Bluetooth Low Energy advertisements such that it can be found by [Apple's Find My network](https://developer.apple.com/find-my/).
This firmware consumes slightly more power when more than 1 key is used. The controller wakes up every 30 minutes and switches the key.

Expand All @@ -13,6 +13,11 @@ This firmware consumes slightly more power when more than 1 key is used. The con

- Download and unpack the firmware
- Copy your previously generated PREFIX_keyfile in the same folder
- For ESP32-S3 builds with PlatformIO, use the `esp32-s3-devkitc-1` environment:

```bash
pio run -e esp32-s3-devkitc-1
```

```bash
esptool.py write_flash 0x1000 bootloader.bin \
Expand Down
8 changes: 7 additions & 1 deletion firmware/ESP32/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ framework = espidf
monitor_speed = 115200
board_build.partitions = with_key.csv


[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = espidf
monitor_speed = 115200
board_build.partitions = with_key.csv
board_upload.flash_size = 4MB
9 changes: 9 additions & 0 deletions firmware/ESP32/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CONFIG_BT_ENABLED=y
CONFIG_BT_BLUEDROID_ENABLED=y
# CONFIG_BT_NIMBLE_ENABLED is not set
# CONFIG_BT_CLASSIC_ENABLED is not set
CONFIG_BT_BLE_ENABLED=y
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
CONFIG_BT_BLE_42_ADV_EN=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
4 changes: 4 additions & 0 deletions firmware/ESP32/src/openhaystack_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
#include "esp_log.h"
#include "esp_sleep.h"
#include "esp_random.h"
#include "soc/soc_caps.h"

/* Delay between advertisement. Advertisment will only be transmitted for a short period of time (20ms) and the device will go to sleep.
Higher delay = less power consumption, but more inaccurate tracking
*/
#define DELAY_IN_S 60

/* Define how often (long) a key will be reused after switching to the next one
This is for using less keys after all. The interval for one key is (DELAY_IN_S * REUSE_CYCLES => 60s * 30 cycles = changes key every 30 min)
Smaller number of cycles = key changes more often, but more keys needed.
Expand Down Expand Up @@ -167,7 +169,9 @@ void app_main(void)
// vTaskDelay(pdMS_TO_TICKS(2000));

ESP_ERROR_CHECK(nvs_flash_init());
#if SOC_BT_CLASSIC_SUPPORTED
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
#endif
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
esp_bt_controller_init(&bt_cfg);
esp_bt_controller_enable(ESP_BT_MODE_BLE);
Expand Down