-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial migration to espidf. Some libraries depend on Arduino types, thus we build as an espidf project with Arduino as a component. Enable ESP32 dynamic frequency control. Enable FreeRTOS tickless idle. Enable ESP32 power management. Minimally tested on M5Core2 and M5StickC Plus2. * Various tweaks. Use array length for Fujifilm token write. Adjust battery smoothing, reduce weight on newer values. Convert UI loop delay to proper 5ms. Format clean-up. * Fix mis-formatted CMakeLists.txt. * Restore missing NimBLE configuration. * Refactor Furble.cpp into Scan.cpp. * Update battery life time from test results. * Remove app0 binary.
- Loading branch information
Showing
21 changed files
with
6,609 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.pio | ||
.vscode | ||
src/furble.ino.cpp | ||
sdkconfig.*.old |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cmake_minimum_required(VERSION 3.16.0) | ||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(furble) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include <NimBLEAdvertisedDevice.h> | ||
#include <NimBLEScan.h> | ||
|
||
#include "Device.h" | ||
#include "Scan.h" | ||
|
||
// log tag | ||
const char *LOG_TAG = FURBLE_STR; | ||
|
||
namespace Furble { | ||
|
||
Scan &Scan::getInstance(void) { | ||
static Scan instance; | ||
|
||
if (instance.m_Scan == nullptr) { | ||
// NimBLE requires configuring server before scan | ||
instance.m_HIDServer = HIDServer::getInstance(); | ||
|
||
instance.m_Scan = NimBLEDevice::getScan(); | ||
instance.m_Scan->setScanCallbacks(&instance); | ||
instance.m_Scan->setActiveScan(true); | ||
instance.m_Scan->setInterval(6553); | ||
instance.m_Scan->setWindow(6553); | ||
} | ||
|
||
return instance; | ||
} | ||
|
||
/** | ||
* BLE Advertisement callback. | ||
*/ | ||
void Scan::onResult(const NimBLEAdvertisedDevice *pDevice) { | ||
if (CameraList::match(pDevice)) { | ||
ESP_LOGI(LOG_TAG, "RSSI(%s) = %d", pDevice->getName().c_str(), pDevice->getRSSI()); | ||
if (m_ScanResultCallback != nullptr) { | ||
(m_ScanResultCallback)(m_ScanResultPrivateData); | ||
} | ||
} | ||
}; | ||
|
||
/** | ||
* HID server callback. | ||
*/ | ||
void Scan::onComplete(const NimBLEAddress &address, const std::string &name) { | ||
CameraList::add(address, name); | ||
if (m_ScanResultCallback != nullptr) { | ||
(m_ScanResultCallback)(m_ScanResultPrivateData); | ||
} | ||
}; | ||
|
||
void Scan::start(std::function<void(void *)> scanCallback, void *scanPrivateData) { | ||
m_HIDServer->start(nullptr, this); | ||
|
||
m_ScanResultCallback = scanCallback; | ||
m_ScanResultPrivateData = scanPrivateData; | ||
m_Scan->start(0, false); | ||
} | ||
|
||
void Scan::stop(void) { | ||
m_HIDServer->stop(); | ||
|
||
m_Scan->stop(); | ||
m_ScanResultPrivateData = nullptr; | ||
m_ScanResultCallback = nullptr; | ||
} | ||
|
||
void Scan::clear(void) { | ||
m_Scan->clearResults(); | ||
} | ||
} // namespace Furble |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#ifndef SCAN_H | ||
#define SCAN_H | ||
|
||
#include <vector> | ||
|
||
#include <NimBLEScan.h> | ||
|
||
#include "CameraList.h" | ||
#include "FurbleTypes.h" | ||
#include "HIDServer.h" | ||
|
||
#ifndef FURBLE_VERSION | ||
#define FURBLE_VERSION "unknown" | ||
#endif | ||
|
||
namespace Furble { | ||
/** | ||
* BLE advertisement scanning class. | ||
* | ||
* Works in conjunction with Furble::Device class. | ||
*/ | ||
class Scan: public HIDServerCallbacks, public NimBLEScanCallbacks { | ||
public: | ||
static Scan &getInstance(void); | ||
|
||
Scan(Scan const &) = delete; | ||
Scan(Scan &&) = delete; | ||
Scan &operator=(Scan const &) = delete; | ||
Scan &operator=(Scan &&) = delete; | ||
|
||
/** | ||
* Start the scan for BLE advertisements with a callback function when a | ||
* matching reseult is encountered. | ||
*/ | ||
void start(std::function<void(void *)> scanCallback, void *scanResultPrivateData); | ||
|
||
/** | ||
* Stop the scan. | ||
*/ | ||
void stop(void); | ||
|
||
/** | ||
* Clear the scan list. | ||
*/ | ||
void clear(void); | ||
|
||
void onResult(const NimBLEAdvertisedDevice *pDevice) override; | ||
|
||
void onComplete(const NimBLEAddress &address, const std::string &name) override; | ||
|
||
private: | ||
Scan() {}; | ||
|
||
NimBLEScan *m_Scan = nullptr; | ||
std::function<void(void *)> m_ScanResultCallback; | ||
void *m_ScanResultPrivateData = nullptr; | ||
HIDServer *m_HIDServer = nullptr; | ||
}; | ||
|
||
} // namespace Furble | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ build_flags = -Wall -Wextra | |
platform = espressif32 | ||
board_build.f_cpu = 80000000L | ||
upload_protocol = esptool | ||
framework = arduino | ||
framework = arduino, espidf | ||
lib_deps = | ||
[email protected] | ||
[email protected] | ||
|
Oops, something went wrong.