- Batch-fetch asset IDs in deep sleep mode with NVS caching to reduce network calls and improve battery life (configurable batch size 1-50) - Add wake_log module: persistent CSV log of each photo cycle surviving reboots and deep sleep, with download/clear via web UI - Add browser-based log viewer and log comparison tools (tools/) - Update .gitignore to exclude .cursor/, chat-summaries/, wake_*.csv, and .DS_Store Co-authored-by: Cursor <cursoragent@cursor.com>
62 lines
1.8 KiB
C++
62 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
#include <vector>
|
|
#include "settings.h"
|
|
|
|
struct AlbumInfo {
|
|
String id;
|
|
String title;
|
|
int assetCount;
|
|
};
|
|
|
|
struct AssetInfo {
|
|
String id;
|
|
String originalFileName;
|
|
String dateTime;
|
|
String city;
|
|
String camera;
|
|
bool isFavorite;
|
|
bool isPortrait;
|
|
std::vector<String> people;
|
|
};
|
|
|
|
struct RandomAsset {
|
|
String id;
|
|
String dateTime;
|
|
};
|
|
|
|
struct RandomFetchFilter {
|
|
std::vector<String> albumIds;
|
|
bool favoriteOnly = false;
|
|
String takenAfter; // ISO datetime, empty = no filter
|
|
String takenBefore; // ISO datetime, empty = no filter
|
|
};
|
|
|
|
class ImmichClient {
|
|
public:
|
|
void begin(const String& baseUrl, const String& apiKey);
|
|
std::vector<AlbumInfo> fetchAlbums();
|
|
std::vector<String> fetchAlbumAssetIds(const String& albumId);
|
|
std::vector<String> fetchRandomAssetIds(int count = 50,
|
|
const std::vector<String>& albumIds = {});
|
|
std::vector<RandomAsset> fetchRandomAssets(int count = 50,
|
|
const std::vector<String>& albumIds = {});
|
|
std::vector<String> fetchFavoriteAssetIds();
|
|
String fetchOneRandomAssetId(const RandomFetchFilter& filter);
|
|
std::vector<String> fetchFilteredBatch(const RandomFetchFilter& filter, int count);
|
|
AssetInfo fetchAssetInfo(const String& assetId);
|
|
bool downloadAsset(const String& assetId, ImageQuality quality,
|
|
uint8_t** outBuffer, size_t* outSize);
|
|
|
|
private:
|
|
String _baseUrl;
|
|
String _apiKey;
|
|
|
|
String buildUrl(const String& path);
|
|
String httpGet(const String& url);
|
|
String httpPost(const String& url, const String& body);
|
|
char* httpGetPsram(const String& url, size_t* outLen);
|
|
bool httpGetBinary(const String& url, uint8_t** outBuffer, size_t* outSize);
|
|
};
|