@geastack/host 0.1.23 → 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/host/device.cpp +2 -1
- package/host/image.cpp +11 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,11 +20,11 @@ headers it cannot satisfy with the portable sources.
|
|
|
20
20
|
|
|
21
21
|
There is no JavaScript entry point; the package exists to be compiled.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
the ESP-IDF WebSocket client and its owned
|
|
26
|
-
works on the actual HTTP upgrade request.
|
|
27
|
-
|
|
23
|
+
On ESP32 the native WebSocket client applies the connection headers passed to
|
|
24
|
+
the `@geastack/core` WebSocket constructor (since host 0.1.16 and core 0.1.41).
|
|
25
|
+
Headers are applied to both the ESP-IDF WebSocket client and its owned
|
|
26
|
+
transport, so bearer authentication works on the actual HTTP upgrade request.
|
|
27
|
+
Connections opened with only a URL and subprotocol keep their defaults.
|
|
28
28
|
|
|
29
29
|
## License
|
|
30
30
|
|
package/host/device.cpp
CHANGED
|
@@ -24,7 +24,8 @@ GEA_WEAK_DEVICE bool setEpochMs(double timestamp) {
|
|
|
24
24
|
if (!std::isfinite(timestamp) || timestamp < 0) {
|
|
25
25
|
return false;
|
|
26
26
|
}
|
|
27
|
-
#if defined(_WIN32)
|
|
27
|
+
#if defined(_WIN32) || defined(__EMSCRIPTEN__)
|
|
28
|
+
// Neither host lets a program set the wall clock (Emscripten has no settimeofday).
|
|
28
29
|
return false;
|
|
29
30
|
#else
|
|
30
31
|
const auto seconds = static_cast<time_t>(timestamp / 1000);
|
package/host/image.cpp
CHANGED
|
@@ -55,11 +55,20 @@ namespace gea::platform::storage {
|
|
|
55
55
|
namespace {
|
|
56
56
|
bool (*g_mount_provider)() = nullptr;
|
|
57
57
|
bool (*g_fallback_mount_provider)() = nullptr;
|
|
58
|
+
std::string (*g_read_path_provider)(const std::string &) = nullptr;
|
|
58
59
|
} // namespace
|
|
59
60
|
void setMountProvider(bool (*provider)()) { g_mount_provider = provider; }
|
|
60
61
|
void setFallbackMountProvider(bool (*provider)()) {
|
|
61
62
|
g_fallback_mount_provider = provider;
|
|
62
63
|
}
|
|
64
|
+
void setReadPathProvider(std::string (*provider)(const std::string &)) {
|
|
65
|
+
g_read_path_provider = provider;
|
|
66
|
+
}
|
|
67
|
+
static std::FILE *openRead(const std::string &path) {
|
|
68
|
+
if (g_read_path_provider)
|
|
69
|
+
return std::fopen(g_read_path_provider(path).c_str(), "rb");
|
|
70
|
+
return std::fopen(path.c_str(), "rb");
|
|
71
|
+
}
|
|
63
72
|
bool ensureMounted() {
|
|
64
73
|
auto provider =
|
|
65
74
|
g_mount_provider ? g_mount_provider : g_fallback_mount_provider;
|
|
@@ -164,7 +173,7 @@ void mapReadTask(void *arg) {
|
|
|
164
173
|
|
|
165
174
|
std::vector<std::uint8_t> readWholeFile(const std::string &path) {
|
|
166
175
|
std::vector<std::uint8_t> out;
|
|
167
|
-
std::FILE *f =
|
|
176
|
+
std::FILE *f = gea::platform::storage::openRead(path);
|
|
168
177
|
if (!f)
|
|
169
178
|
return out;
|
|
170
179
|
std::fseek(f, 0, SEEK_END);
|
|
@@ -298,7 +307,7 @@ std::vector<std::uint8_t> ImageService::readFileRange(const std::string &path,
|
|
|
298
307
|
if (path.empty() || offset < 0 || length <= 0 ||
|
|
299
308
|
!gea::platform::storage::ensureMounted())
|
|
300
309
|
return;
|
|
301
|
-
std::FILE *f =
|
|
310
|
+
std::FILE *f = gea::platform::storage::openRead(path);
|
|
302
311
|
if (!f)
|
|
303
312
|
return;
|
|
304
313
|
if (std::fseek(f, static_cast<long>(offset), SEEK_SET) == 0) {
|