@geastack/host 0.1.8
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/LICENSE +202 -0
- package/README.md +25 -0
- package/audio_runtime.cpp +807 -0
- package/bluetooth.cpp +125 -0
- package/geolocation.cpp +43 -0
- package/host/apps.cpp +20 -0
- package/host/audio.cpp +240 -0
- package/host/ble.cpp +239 -0
- package/host/camera.cpp +193 -0
- package/host/display.cpp +230 -0
- package/host/fetch.cpp +1060 -0
- package/host/geolocation.cpp +31 -0
- package/host/gpio.cpp +55 -0
- package/host/http.cpp +349 -0
- package/host/image.cpp +335 -0
- package/host/imu.cpp +51 -0
- package/host/input.cpp +12 -0
- package/host/media.cpp +579 -0
- package/host/memory.cpp +91 -0
- package/host/rtc.cpp +212 -0
- package/host/rtc_esp.cpp +291 -0
- package/host/tile_loader.cpp +478 -0
- package/host/timers.cpp +327 -0
- package/host/touch.cpp +25 -0
- package/host/websocket.cpp +279 -0
- package/host/wifi.cpp +99 -0
- package/include/gea/embedded-host.h +38 -0
- package/include/host/apps.h +15 -0
- package/include/host/audio.h +158 -0
- package/include/host/backends.h +455 -0
- package/include/host/battery.h +25 -0
- package/include/host/camera.h +236 -0
- package/include/host/clock.h +45 -0
- package/include/host/device_control.h +23 -0
- package/include/host/display.h +266 -0
- package/include/host/display_orientation.h +291 -0
- package/include/host/fetch.h +310 -0
- package/include/host/gpio.h +36 -0
- package/include/host/http.h +161 -0
- package/include/host/image.h +144 -0
- package/include/host/input.h +14 -0
- package/include/host/media.h +165 -0
- package/include/host/memory.h +44 -0
- package/include/host/navigator.h +283 -0
- package/include/host/notify.h +41 -0
- package/include/host/profiler.h +49 -0
- package/include/host/rtc.h +174 -0
- package/include/host/storage.h +141 -0
- package/include/host/tile_loader.h +59 -0
- package/include/host/timers.h +41 -0
- package/include/host/touch.h +20 -0
- package/include/host/websocket.h +179 -0
- package/include/host/window.h +31 -0
- package/input.cpp +68 -0
- package/package.json +27 -0
- package/services/app_state.cpp +19 -0
- package/services/battery_service.cpp +19 -0
- package/services/bluetooth_service.cpp +37 -0
- package/services/diagnostics.cpp +233 -0
- package/services/diagnostics_connection.cpp +231 -0
- package/services/diagnostics_internal.h +15 -0
- package/services/diagnostics_server.cpp +135 -0
- package/services/mirror.cpp +364 -0
- package/services/network_services.cpp +62 -0
- package/services/runtime_log.cpp +23 -0
- package/services/settings_surface.h +221 -0
- package/wifi.cpp +185 -0
package/host/wifi.cpp
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#include <string>
|
|
3
|
+
|
|
4
|
+
#ifdef ESP_PLATFORM
|
|
5
|
+
#include "freertos/FreeRTOS.h"
|
|
6
|
+
#include "freertos/task.h"
|
|
7
|
+
#else
|
|
8
|
+
#include <chrono>
|
|
9
|
+
#include <thread>
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#include "gea/embedded-host.h"
|
|
13
|
+
#include "wifi.h"
|
|
14
|
+
|
|
15
|
+
namespace gea::framework::network {
|
|
16
|
+
|
|
17
|
+
namespace {
|
|
18
|
+
|
|
19
|
+
void sleepForMs(int ms) {
|
|
20
|
+
#ifdef ESP_PLATFORM
|
|
21
|
+
vTaskDelay(pdMS_TO_TICKS(ms));
|
|
22
|
+
#else
|
|
23
|
+
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
|
24
|
+
#endif
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
} // namespace
|
|
28
|
+
|
|
29
|
+
bool WifiBackend::enabled() {
|
|
30
|
+
return wifi().enabled();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void WifiBackend::setEnabled(bool enabled) {
|
|
34
|
+
wifi().setEnabled(enabled);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
bool WifiBackend::connected() {
|
|
38
|
+
return wifi().connected();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
double WifiBackend::rssi() {
|
|
42
|
+
return static_cast<double>(wifi().rssi());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
std::string WifiBackend::ssid() {
|
|
46
|
+
return wifi().ssid();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
std::string WifiBackend::ip() {
|
|
50
|
+
return wifi().ip();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
std::string WifiBackend::mac() {
|
|
54
|
+
return wifi().mac();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void WifiBackend::configure(const std::string &ssid, const std::string &password) {
|
|
58
|
+
wifi().configure(ssid, password);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
bool WifiBackend::waitForConnection(double timeoutMs) {
|
|
62
|
+
if (wifi().connected()) return true;
|
|
63
|
+
wifi().setEnabled(true);
|
|
64
|
+
|
|
65
|
+
const int timeout = timeoutMs > 0 ? static_cast<int>(timeoutMs) : 0;
|
|
66
|
+
int elapsed = 0;
|
|
67
|
+
while (elapsed < timeout) {
|
|
68
|
+
if (wifi().connected()) return true;
|
|
69
|
+
sleepForMs(100);
|
|
70
|
+
elapsed += 100;
|
|
71
|
+
}
|
|
72
|
+
return wifi().connected();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
void WifiBackend::startScan() {
|
|
76
|
+
wifi().scan();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
bool WifiBackend::scanning() {
|
|
80
|
+
return wifi().scanning();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
double WifiBackend::scanCount() {
|
|
84
|
+
return static_cast<double>(wifi().scanCount());
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
std::string WifiBackend::scanSsidAt(double index) {
|
|
88
|
+
return wifi().networkAt(static_cast<int>(index)).ssid;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
double WifiBackend::scanRssiAt(double index) {
|
|
92
|
+
return static_cast<double>(wifi().networkAt(static_cast<int>(index)).rssi);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
bool WifiBackend::scanSecuredAt(double index) {
|
|
96
|
+
return wifi().networkAt(static_cast<int>(index)).secured;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
} // namespace gea::framework::network
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Gea host platform umbrella — device + host services ONLY.
|
|
3
|
+
//
|
|
4
|
+
// Deliberately excludes the UI engine (ui/document.h) and the reactive layer
|
|
5
|
+
// (ui/signal.h). Host package .cpp include THIS, so @geastack/host carries no
|
|
6
|
+
// transitive dependency on engine/reactive. The full framework umbrella
|
|
7
|
+
// (gea/embedded.h) is this + ui/document.h + ui/signal.h, for engine/app code.
|
|
8
|
+
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#include "display.h"
|
|
12
|
+
#include "host/backends.h"
|
|
13
|
+
#include "host/fetch.h"
|
|
14
|
+
#include "geolocation.h"
|
|
15
|
+
#include "host/websocket.h"
|
|
16
|
+
#include "host/http.h"
|
|
17
|
+
#include "host/media.h"
|
|
18
|
+
#include "host/rtc.h"
|
|
19
|
+
#include "host/touch.h"
|
|
20
|
+
#include "host/apps.h"
|
|
21
|
+
#include "host/image.h"
|
|
22
|
+
#include "host/tile_loader.h"
|
|
23
|
+
#include "host/memory.h"
|
|
24
|
+
#include "host/input.h"
|
|
25
|
+
#include "host/gpio.h"
|
|
26
|
+
#include "host/clock.h"
|
|
27
|
+
#include "host/profiler.h"
|
|
28
|
+
#include "host/storage.h"
|
|
29
|
+
#include "host/battery.h"
|
|
30
|
+
#include "host/notify.h"
|
|
31
|
+
#include "host/device_control.h"
|
|
32
|
+
#include "input.h"
|
|
33
|
+
#include "host/audio.h"
|
|
34
|
+
#include "host/display.h"
|
|
35
|
+
#include "host/navigator.h"
|
|
36
|
+
#include "host/camera.h"
|
|
37
|
+
#include "host/timers.h"
|
|
38
|
+
#include "host/window.h"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
namespace gea::host {
|
|
7
|
+
|
|
8
|
+
class Apps {
|
|
9
|
+
public:
|
|
10
|
+
double launch(const std::string &app_id) const;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
inline constexpr Apps apps{};
|
|
14
|
+
|
|
15
|
+
} // namespace gea::host
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
#include <audio.h>
|
|
5
|
+
#include "backends.h"
|
|
6
|
+
|
|
7
|
+
#include <cstdint>
|
|
8
|
+
#include <cstring>
|
|
9
|
+
#include <string>
|
|
10
|
+
#include <utility>
|
|
11
|
+
#include <vector>
|
|
12
|
+
|
|
13
|
+
namespace gea::embedded::ui {
|
|
14
|
+
class NodeHandle;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
namespace gea::host {
|
|
18
|
+
|
|
19
|
+
using NativeAudioHandle = gea::platform::audio::NativeAudioHandle;
|
|
20
|
+
|
|
21
|
+
namespace detail {
|
|
22
|
+
inline double oscillator_type_from_name(const char *type) {
|
|
23
|
+
if (type == nullptr) return 0.0;
|
|
24
|
+
if (std::strcmp(type, "square") == 0) return 1.0;
|
|
25
|
+
if (std::strcmp(type, "sawtooth") == 0) return 2.0;
|
|
26
|
+
if (std::strcmp(type, "triangle") == 0) return 3.0;
|
|
27
|
+
return 0.0;
|
|
28
|
+
}
|
|
29
|
+
} // namespace detail
|
|
30
|
+
|
|
31
|
+
struct AudioDestinationNode {
|
|
32
|
+
NativeAudioHandle nativeHandle = 0;
|
|
33
|
+
|
|
34
|
+
constexpr AudioDestinationNode() = default;
|
|
35
|
+
explicit constexpr AudioDestinationNode(NativeAudioHandle destination) : nativeHandle(destination) {}
|
|
36
|
+
explicit constexpr AudioDestinationNode(double destination) : nativeHandle(static_cast<NativeAudioHandle>(destination)) {}
|
|
37
|
+
|
|
38
|
+
constexpr operator double() const { return static_cast<double>(nativeHandle); }
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
struct AudioDestinationProperty {
|
|
42
|
+
operator AudioDestinationNode() const;
|
|
43
|
+
operator double() const;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
struct AudioContextCurrentTimeProperty {
|
|
47
|
+
operator double() const;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
struct AudioBuffer {
|
|
51
|
+
std::vector<std::int16_t> samples;
|
|
52
|
+
int sampleRate = 16000;
|
|
53
|
+
int channels = 1;
|
|
54
|
+
|
|
55
|
+
constexpr AudioBuffer() = default;
|
|
56
|
+
AudioBuffer(std::vector<std::int16_t> pcm, int rate, int channelCount)
|
|
57
|
+
: samples(std::move(pcm)), sampleRate(rate), channels(channelCount) {}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
struct AudioParamValueProperty {
|
|
61
|
+
NativeAudioHandle oscillatorHandle = 0;
|
|
62
|
+
|
|
63
|
+
constexpr AudioParamValueProperty() = default;
|
|
64
|
+
explicit constexpr AudioParamValueProperty(NativeAudioHandle handle) : oscillatorHandle(handle) {}
|
|
65
|
+
explicit constexpr AudioParamValueProperty(double handle) : oscillatorHandle(static_cast<NativeAudioHandle>(handle)) {}
|
|
66
|
+
|
|
67
|
+
const AudioParamValueProperty &operator=(double frequency_hz) const;
|
|
68
|
+
operator double() const;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
struct AudioParam {
|
|
72
|
+
NativeAudioHandle oscillatorHandle = 0;
|
|
73
|
+
mutable AudioParamValueProperty value;
|
|
74
|
+
|
|
75
|
+
constexpr AudioParam() = default;
|
|
76
|
+
explicit constexpr AudioParam(NativeAudioHandle handle) : oscillatorHandle(handle), value(handle) {}
|
|
77
|
+
explicit constexpr AudioParam(double handle) : oscillatorHandle(static_cast<NativeAudioHandle>(handle)), value(handle) {}
|
|
78
|
+
|
|
79
|
+
const AudioParam &operator=(double frequency_hz) const;
|
|
80
|
+
void setValueAtTime(double frequency_hz, double start_time) const;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
struct OscillatorTypeProperty {
|
|
84
|
+
NativeAudioHandle oscillatorHandle = 0;
|
|
85
|
+
|
|
86
|
+
constexpr OscillatorTypeProperty() = default;
|
|
87
|
+
explicit constexpr OscillatorTypeProperty(NativeAudioHandle handle) : oscillatorHandle(handle) {}
|
|
88
|
+
explicit constexpr OscillatorTypeProperty(double handle) : oscillatorHandle(static_cast<NativeAudioHandle>(handle)) {}
|
|
89
|
+
|
|
90
|
+
const OscillatorTypeProperty &operator=(double type) const;
|
|
91
|
+
const OscillatorTypeProperty &operator=(const char *type) const;
|
|
92
|
+
const OscillatorTypeProperty &operator=(const std::string &type) const;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
struct OscillatorNode {
|
|
96
|
+
NativeAudioHandle nativeHandle = 0;
|
|
97
|
+
mutable AudioParam frequency;
|
|
98
|
+
mutable OscillatorTypeProperty type;
|
|
99
|
+
|
|
100
|
+
constexpr OscillatorNode() = default;
|
|
101
|
+
explicit constexpr OscillatorNode(NativeAudioHandle oscillator) : nativeHandle(oscillator), frequency(oscillator), type(oscillator) {}
|
|
102
|
+
explicit constexpr OscillatorNode(double oscillator) : nativeHandle(static_cast<NativeAudioHandle>(oscillator)), frequency(oscillator), type(oscillator) {}
|
|
103
|
+
|
|
104
|
+
constexpr operator double() const { return static_cast<double>(nativeHandle); }
|
|
105
|
+
|
|
106
|
+
void connect(AudioDestinationNode destination) const;
|
|
107
|
+
void connect(AudioDestinationProperty destination) const;
|
|
108
|
+
void connect(double destinationHandle) const;
|
|
109
|
+
void start(double when = 0.0) const;
|
|
110
|
+
void stop(double when = 0.0) const;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
struct AudioBufferSourceNode {
|
|
114
|
+
mutable AudioBuffer buffer;
|
|
115
|
+
mutable bool connected = false;
|
|
116
|
+
|
|
117
|
+
AudioDestinationNode connect(AudioDestinationNode destination) const;
|
|
118
|
+
AudioDestinationNode connect(AudioDestinationProperty destination) const;
|
|
119
|
+
AudioDestinationNode connect(double destinationHandle) const;
|
|
120
|
+
void start(double when = 0.0) const;
|
|
121
|
+
void stop(double when = 0.0) const;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
struct AudioContext {
|
|
125
|
+
AudioDestinationProperty destination;
|
|
126
|
+
AudioContextCurrentTimeProperty currentTime;
|
|
127
|
+
|
|
128
|
+
OscillatorNode createOscillator() const;
|
|
129
|
+
AudioBufferSourceNode createBufferSource() const;
|
|
130
|
+
AudioBuffer decodeAudioData(const std::vector<std::uint8_t> &bytes) const;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
class HTMLAudioElement {
|
|
134
|
+
public:
|
|
135
|
+
HTMLAudioElement() = default;
|
|
136
|
+
explicit HTMLAudioElement(const char *src);
|
|
137
|
+
explicit HTMLAudioElement(const std::string &src);
|
|
138
|
+
explicit HTMLAudioElement(const gea::embedded::ui::NodeHandle &node);
|
|
139
|
+
|
|
140
|
+
std::string src() const;
|
|
141
|
+
void setSrc(const std::string &src);
|
|
142
|
+
bool play() const;
|
|
143
|
+
void pause() const;
|
|
144
|
+
|
|
145
|
+
private:
|
|
146
|
+
int nodeId_ = -1;
|
|
147
|
+
std::string src_;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
struct AudioFacade {
|
|
151
|
+
double getVolume() const { return gea::framework::audio::AudioBackend::volume(); }
|
|
152
|
+
void setVolume(double volume) const { gea::framework::audio::AudioBackend::setVolume(volume); }
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
inline constexpr AudioContext audioContext{};
|
|
156
|
+
inline constexpr AudioFacade Audio{};
|
|
157
|
+
|
|
158
|
+
} // namespace gea::host
|