@geastack/host 0.1.14 → 0.1.15
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/audio_runtime.cpp +183 -98
- package/host/audio.cpp +47 -24
- package/host/audio_buffer_runtime.cpp +117 -0
- package/host/audio_worklet.cpp +29 -17
- package/host/camera.cpp +34 -1
- package/host/device.cpp +36 -0
- package/host/http.cpp +155 -56
- package/host/image.cpp +188 -97
- package/host/media.cpp +18 -6
- package/host/mjpeg.cpp +1 -1
- package/host/rtc.cpp +1 -1
- package/host/rtc_esp.cpp +2 -2
- package/host/timers.cpp +2 -2
- package/host/wifi.cpp +30 -32
- package/include/gea/audio-worklet-runtime.h +4 -3
- package/include/gea/http-native-runtime.h +127 -0
- package/include/host/audio.h +84 -13
- package/include/host/backends.h +88 -51
- package/include/host/battery.h +10 -0
- package/include/host/camera.h +1 -0
- package/include/host/camera_frame.h +69 -0
- package/include/host/clock.h +6 -0
- package/include/host/http.h +80 -20
- package/include/host/image.h +1 -0
- package/include/host/navigator.h +238 -89
- package/include/host/storage.h +9 -6
- package/include/host/timers.h +2 -5
- package/include/platform/internal_stack.h +89 -0
- package/input.cpp +57 -33
- package/package.json +1 -1
- package/wifi.cpp +140 -121
package/include/host/navigator.h
CHANGED
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
namespace gea::host {
|
|
9
9
|
|
|
10
|
-
using GeolocationCoordinates =
|
|
10
|
+
using GeolocationCoordinates =
|
|
11
|
+
gea::framework::geolocation::GeolocationCoordinates;
|
|
11
12
|
using GeolocationPosition = gea::framework::geolocation::GeolocationPosition;
|
|
12
|
-
using GeolocationPositionError =
|
|
13
|
+
using GeolocationPositionError =
|
|
14
|
+
gea::framework::geolocation::GeolocationPositionError;
|
|
13
15
|
using GeolocationOptions = gea::framework::geolocation::GeolocationOptions;
|
|
14
16
|
|
|
15
17
|
class AccelerometerValueProperty {
|
|
@@ -17,15 +19,12 @@ public:
|
|
|
17
19
|
using Getter = double (*)();
|
|
18
20
|
|
|
19
21
|
constexpr AccelerometerValueProperty() = default;
|
|
20
|
-
explicit constexpr AccelerometerValueProperty(Getter getter)
|
|
22
|
+
explicit constexpr AccelerometerValueProperty(Getter getter)
|
|
23
|
+
: getter_(getter) {}
|
|
21
24
|
|
|
22
|
-
double operator()() const {
|
|
23
|
-
return getter_ ? getter_() : 0.0;
|
|
24
|
-
}
|
|
25
|
+
double operator()() const { return getter_ ? getter_() : 0.0; }
|
|
25
26
|
|
|
26
|
-
operator double() const {
|
|
27
|
-
return (*this)();
|
|
28
|
-
}
|
|
27
|
+
operator double() const { return (*this)(); }
|
|
29
28
|
|
|
30
29
|
private:
|
|
31
30
|
Getter getter_ = nullptr;
|
|
@@ -39,9 +38,12 @@ public:
|
|
|
39
38
|
x(gea::framework::sensors::AccelerometerBackend::accelerationX),
|
|
40
39
|
y(gea::framework::sensors::AccelerometerBackend::accelerationY),
|
|
41
40
|
z(gea::framework::sensors::AccelerometerBackend::accelerationZ),
|
|
42
|
-
accelerationX(
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
accelerationX(
|
|
42
|
+
gea::framework::sensors::AccelerometerBackend::accelerationX),
|
|
43
|
+
accelerationY(
|
|
44
|
+
gea::framework::sensors::AccelerometerBackend::accelerationY),
|
|
45
|
+
accelerationZ(
|
|
46
|
+
gea::framework::sensors::AccelerometerBackend::accelerationZ),
|
|
45
47
|
gyroscopeX(gea::framework::sensors::AccelerometerBackend::gyroscopeX),
|
|
46
48
|
gyroscopeY(gea::framework::sensors::AccelerometerBackend::gyroscopeY),
|
|
47
49
|
gyroscopeZ(gea::framework::sensors::AccelerometerBackend::gyroscopeZ) {}
|
|
@@ -49,7 +51,9 @@ public:
|
|
|
49
51
|
void start() const { gea::framework::sensors::AccelerometerBackend::init(); }
|
|
50
52
|
void init() const { gea::framework::sensors::AccelerometerBackend::init(); }
|
|
51
53
|
void close() const { gea::framework::sensors::AccelerometerBackend::close(); }
|
|
52
|
-
void calibrateBias() const {
|
|
54
|
+
void calibrateBias() const {
|
|
55
|
+
gea::framework::sensors::AccelerometerBackend::calibrateBias();
|
|
56
|
+
}
|
|
53
57
|
|
|
54
58
|
AccelerometerValueProperty tiltX;
|
|
55
59
|
AccelerometerValueProperty tiltY;
|
|
@@ -72,9 +76,15 @@ inline constexpr const AccelerometerFacade &imu = Accelerometer;
|
|
|
72
76
|
class WiFiNetwork {
|
|
73
77
|
public:
|
|
74
78
|
explicit WiFiNetwork(double index) : index_(index) {}
|
|
75
|
-
std::string ssid() const {
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
std::string ssid() const {
|
|
80
|
+
return gea::framework::network::WifiBackend::scanSsidAt(index_);
|
|
81
|
+
}
|
|
82
|
+
double rssi() const {
|
|
83
|
+
return gea::framework::network::WifiBackend::scanRssiAt(index_);
|
|
84
|
+
}
|
|
85
|
+
bool secured() const {
|
|
86
|
+
return gea::framework::network::WifiBackend::scanSecuredAt(index_);
|
|
87
|
+
}
|
|
78
88
|
|
|
79
89
|
private:
|
|
80
90
|
double index_ = 0.0;
|
|
@@ -83,18 +93,53 @@ private:
|
|
|
83
93
|
class WiFi {
|
|
84
94
|
public:
|
|
85
95
|
const WiFi &operator()() const { return *this; }
|
|
86
|
-
bool enabled() const {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
96
|
+
bool enabled() const {
|
|
97
|
+
return gea::framework::network::WifiBackend::enabled();
|
|
98
|
+
}
|
|
99
|
+
void setEnabled(bool enabled) const {
|
|
100
|
+
gea::framework::network::WifiBackend::setEnabled(enabled);
|
|
101
|
+
}
|
|
102
|
+
bool connected() const {
|
|
103
|
+
return gea::framework::network::WifiBackend::connected();
|
|
104
|
+
}
|
|
105
|
+
std::string ssid() const {
|
|
106
|
+
return gea::framework::network::WifiBackend::ssid();
|
|
107
|
+
}
|
|
90
108
|
std::string ip() const { return gea::framework::network::WifiBackend::ip(); }
|
|
91
|
-
std::string mac() const {
|
|
109
|
+
std::string mac() const {
|
|
110
|
+
return gea::framework::network::WifiBackend::mac();
|
|
111
|
+
}
|
|
92
112
|
double rssi() const { return gea::framework::network::WifiBackend::rssi(); }
|
|
93
|
-
void configure(const std::string &ssid, const std::string &password) const {
|
|
94
|
-
|
|
113
|
+
void configure(const std::string &ssid, const std::string &password) const {
|
|
114
|
+
gea::framework::network::WifiBackend::configure(ssid, password);
|
|
115
|
+
}
|
|
116
|
+
bool startAccessPoint(const std::string &ssid,
|
|
117
|
+
const std::string &password = {}) const {
|
|
118
|
+
return gea::framework::network::WifiBackend::startAccessPoint(ssid,
|
|
119
|
+
password);
|
|
120
|
+
}
|
|
121
|
+
void stopAccessPoint() const {
|
|
122
|
+
gea::framework::network::WifiBackend::stopAccessPoint();
|
|
123
|
+
}
|
|
124
|
+
std::string accessPointMac() const {
|
|
125
|
+
return gea::framework::network::WifiBackend::accessPointMac();
|
|
126
|
+
}
|
|
127
|
+
bool startCaptivePortal() const {
|
|
128
|
+
return gea::framework::network::WifiBackend::startCaptivePortal();
|
|
129
|
+
}
|
|
130
|
+
void stopCaptivePortal() const {
|
|
131
|
+
gea::framework::network::WifiBackend::stopCaptivePortal();
|
|
132
|
+
}
|
|
133
|
+
bool waitForConnection(double timeoutMs) const {
|
|
134
|
+
return gea::framework::network::WifiBackend::waitForConnection(timeoutMs);
|
|
135
|
+
}
|
|
95
136
|
void startScan() const { gea::framework::network::WifiBackend::startScan(); }
|
|
96
|
-
bool scanning() const {
|
|
97
|
-
|
|
137
|
+
bool scanning() const {
|
|
138
|
+
return gea::framework::network::WifiBackend::scanning();
|
|
139
|
+
}
|
|
140
|
+
double scanCount() const {
|
|
141
|
+
return gea::framework::network::WifiBackend::scanCount();
|
|
142
|
+
}
|
|
98
143
|
WiFiNetwork network(double index) const { return WiFiNetwork(index); }
|
|
99
144
|
std::string scanSsidAt(double index) const { return network(index).ssid(); }
|
|
100
145
|
double scanRssiAt(double index) const { return network(index).rssi(); }
|
|
@@ -103,17 +148,24 @@ public:
|
|
|
103
148
|
|
|
104
149
|
class BluetoothKeyboard {
|
|
105
150
|
public:
|
|
106
|
-
void tap(double hid_code) const {
|
|
107
|
-
|
|
151
|
+
void tap(double hid_code) const {
|
|
152
|
+
gea::framework::bluetooth::HidBackend::keyTap(hid_code);
|
|
153
|
+
}
|
|
154
|
+
void down(double modifier, double hid_code) const {
|
|
155
|
+
gea::framework::bluetooth::HidBackend::keyDown(modifier, hid_code);
|
|
156
|
+
}
|
|
108
157
|
void up() const { gea::framework::bluetooth::HidBackend::keyUp(); }
|
|
109
158
|
};
|
|
110
159
|
|
|
111
160
|
class BluetoothMouse {
|
|
112
161
|
public:
|
|
113
|
-
void move(double dx, double dy, double buttons = 0.0,
|
|
162
|
+
void move(double dx, double dy, double buttons = 0.0,
|
|
163
|
+
double wheel = 0.0) const {
|
|
114
164
|
gea::framework::bluetooth::HidBackend::mouseMove(dx, dy, buttons, wheel);
|
|
115
165
|
}
|
|
116
|
-
void click(double button) const {
|
|
166
|
+
void click(double button) const {
|
|
167
|
+
gea::framework::bluetooth::HidBackend::mouseClick(button);
|
|
168
|
+
}
|
|
117
169
|
};
|
|
118
170
|
|
|
119
171
|
class BluetoothMidi {
|
|
@@ -123,17 +175,35 @@ public:
|
|
|
123
175
|
// advertised). send() transmits one already-framed BLE-MIDI packet — the
|
|
124
176
|
// TS side owns the header/timestamp framing.
|
|
125
177
|
void enable() const { gea::framework::bluetooth::HidBackend::midiEnable(); }
|
|
126
|
-
bool bound() const {
|
|
127
|
-
|
|
178
|
+
bool bound() const {
|
|
179
|
+
return gea::framework::bluetooth::HidBackend::midiBound();
|
|
180
|
+
}
|
|
181
|
+
void send(const std::vector<double> &bytes) const {
|
|
182
|
+
gea::framework::bluetooth::HidBackend::midiSend(bytes);
|
|
183
|
+
}
|
|
128
184
|
// Central role: scan for BLE-MIDI peripherals and connect as a GATT client.
|
|
129
185
|
// Scan results use the WiFi-scan polling idiom (startScan / scanCount / *At).
|
|
130
|
-
void startScan() const {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
186
|
+
void startScan() const {
|
|
187
|
+
gea::framework::bluetooth::HidBackend::midiStartScan();
|
|
188
|
+
}
|
|
189
|
+
void stopScan() const {
|
|
190
|
+
gea::framework::bluetooth::HidBackend::midiStopScan();
|
|
191
|
+
}
|
|
192
|
+
bool scanning() const {
|
|
193
|
+
return gea::framework::bluetooth::HidBackend::midiScanning();
|
|
194
|
+
}
|
|
195
|
+
double scanCount() const {
|
|
196
|
+
return gea::framework::bluetooth::HidBackend::midiScanCount();
|
|
197
|
+
}
|
|
198
|
+
std::string scanNameAt(double index) const {
|
|
199
|
+
return gea::framework::bluetooth::HidBackend::midiScanNameAt(index);
|
|
200
|
+
}
|
|
201
|
+
void connect(double index) const {
|
|
202
|
+
gea::framework::bluetooth::HidBackend::midiConnect(index);
|
|
203
|
+
}
|
|
204
|
+
void disconnect() const {
|
|
205
|
+
gea::framework::bluetooth::HidBackend::midiDisconnect();
|
|
206
|
+
}
|
|
137
207
|
};
|
|
138
208
|
|
|
139
209
|
class BluetoothHidHost {
|
|
@@ -143,21 +213,46 @@ public:
|
|
|
143
213
|
// polling idiom as MIDI; raw input reports queue driver-side until the
|
|
144
214
|
// app drains them (reportCount / reportIdAt / reportLenAt / reportByteAt
|
|
145
215
|
// / clearReports) and decodes the peripheral's report format itself.
|
|
146
|
-
void startScan() const {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
double
|
|
156
|
-
|
|
216
|
+
void startScan() const {
|
|
217
|
+
gea::framework::bluetooth::HidBackend::hidHostStartScan();
|
|
218
|
+
}
|
|
219
|
+
void stopScan() const {
|
|
220
|
+
gea::framework::bluetooth::HidBackend::hidHostStopScan();
|
|
221
|
+
}
|
|
222
|
+
bool scanning() const {
|
|
223
|
+
return gea::framework::bluetooth::HidBackend::hidHostScanning();
|
|
224
|
+
}
|
|
225
|
+
double scanCount() const {
|
|
226
|
+
return gea::framework::bluetooth::HidBackend::hidHostScanCount();
|
|
227
|
+
}
|
|
228
|
+
std::string scanNameAt(double index) const {
|
|
229
|
+
return gea::framework::bluetooth::HidBackend::hidHostScanNameAt(index);
|
|
230
|
+
}
|
|
231
|
+
void connect(double index) const {
|
|
232
|
+
gea::framework::bluetooth::HidBackend::hidHostConnect(index);
|
|
233
|
+
}
|
|
234
|
+
void disconnect() const {
|
|
235
|
+
gea::framework::bluetooth::HidBackend::hidHostDisconnect();
|
|
236
|
+
}
|
|
237
|
+
bool bound() const {
|
|
238
|
+
return gea::framework::bluetooth::HidBackend::hidHostBound();
|
|
239
|
+
}
|
|
240
|
+
double reportCount() const {
|
|
241
|
+
return gea::framework::bluetooth::HidBackend::hidHostReportCount();
|
|
242
|
+
}
|
|
243
|
+
double reportIdAt(double index) const {
|
|
244
|
+
return gea::framework::bluetooth::HidBackend::hidHostReportIdAt(index);
|
|
245
|
+
}
|
|
246
|
+
double reportLenAt(double index) const {
|
|
247
|
+
return gea::framework::bluetooth::HidBackend::hidHostReportLenAt(index);
|
|
248
|
+
}
|
|
157
249
|
double reportByteAt(double index, double byteIndex) const {
|
|
158
|
-
return gea::framework::bluetooth::HidBackend::hidHostReportByteAt(
|
|
250
|
+
return gea::framework::bluetooth::HidBackend::hidHostReportByteAt(
|
|
251
|
+
index, byteIndex);
|
|
252
|
+
}
|
|
253
|
+
void clearReports() const {
|
|
254
|
+
gea::framework::bluetooth::HidBackend::hidHostClearReports();
|
|
159
255
|
}
|
|
160
|
-
void clearReports() const { gea::framework::bluetooth::HidBackend::hidHostClearReports(); }
|
|
161
256
|
};
|
|
162
257
|
|
|
163
258
|
class BluetoothConnections {
|
|
@@ -166,9 +261,15 @@ public:
|
|
|
166
261
|
// central peer (desktop using us as keyboard/mouse), 1 = MIDI central
|
|
167
262
|
// peer (DAW), 2 = HID peripheral we host (macro pad), 3 = BLE-MIDI
|
|
168
263
|
// peripheral we drive (pedal/WIDI adapter).
|
|
169
|
-
double count() const {
|
|
170
|
-
|
|
171
|
-
|
|
264
|
+
double count() const {
|
|
265
|
+
return gea::framework::bluetooth::HidBackend::connectionCount();
|
|
266
|
+
}
|
|
267
|
+
double kindAt(double index) const {
|
|
268
|
+
return gea::framework::bluetooth::HidBackend::connectionKindAt(index);
|
|
269
|
+
}
|
|
270
|
+
std::string nameAt(double index) const {
|
|
271
|
+
return gea::framework::bluetooth::HidBackend::connectionNameAt(index);
|
|
272
|
+
}
|
|
172
273
|
};
|
|
173
274
|
|
|
174
275
|
class BluetoothConfig {
|
|
@@ -180,15 +281,32 @@ public:
|
|
|
180
281
|
// polls pendingLength() each frame; on a committed inbound blob it drains
|
|
181
282
|
// pendingByteAt()/consumePending() and re-serializes via setDocument().
|
|
182
283
|
// The pairing trio drives the on-device pairing overlay.
|
|
183
|
-
void setDocument(const std::vector<double> &bytes) const {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
284
|
+
void setDocument(const std::vector<double> &bytes) const {
|
|
285
|
+
gea::framework::bluetooth::HidBackend::configSetDocument(bytes);
|
|
286
|
+
}
|
|
287
|
+
double pendingLength() const {
|
|
288
|
+
return gea::framework::bluetooth::HidBackend::configPendingLength();
|
|
289
|
+
}
|
|
290
|
+
double pendingByteAt(double index) const {
|
|
291
|
+
return gea::framework::bluetooth::HidBackend::configPendingByteAt(index);
|
|
292
|
+
}
|
|
293
|
+
void consumePending() const {
|
|
294
|
+
gea::framework::bluetooth::HidBackend::configConsumePending();
|
|
295
|
+
}
|
|
296
|
+
bool pairing() const {
|
|
297
|
+
return gea::framework::bluetooth::HidBackend::configPairing();
|
|
298
|
+
}
|
|
299
|
+
std::string pairCode() const {
|
|
300
|
+
return gea::framework::bluetooth::HidBackend::configPairCode();
|
|
301
|
+
}
|
|
302
|
+
void dismissPairing() const {
|
|
303
|
+
gea::framework::bluetooth::HidBackend::configDismissPairing();
|
|
304
|
+
}
|
|
305
|
+
// Device -> portal activity push (see BluetoothConfig::pushActivity in the TS
|
|
306
|
+
// API).
|
|
307
|
+
void pushActivity(double index) const {
|
|
308
|
+
gea::framework::bluetooth::HidBackend::configPushActivity(index);
|
|
309
|
+
}
|
|
192
310
|
};
|
|
193
311
|
|
|
194
312
|
class Bluetooth {
|
|
@@ -201,52 +319,82 @@ public:
|
|
|
201
319
|
BluetoothConfig config;
|
|
202
320
|
|
|
203
321
|
const Bluetooth &operator()() const { return *this; }
|
|
204
|
-
bool enabled() const {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
void
|
|
211
|
-
|
|
322
|
+
bool enabled() const {
|
|
323
|
+
return gea::framework::bluetooth::HidBackend::enabled();
|
|
324
|
+
}
|
|
325
|
+
void setEnabled(bool enabled) const {
|
|
326
|
+
gea::framework::bluetooth::HidBackend::setEnabled(enabled);
|
|
327
|
+
}
|
|
328
|
+
void init(const std::string &device_name, double appearance = 0.0,
|
|
329
|
+
const std::string &mac_address = std::string()) const {
|
|
330
|
+
gea::framework::bluetooth::HidBackend::init(device_name, appearance,
|
|
331
|
+
mac_address);
|
|
332
|
+
}
|
|
333
|
+
void startAdvertising() const {
|
|
334
|
+
gea::framework::bluetooth::HidBackend::startAdvertising();
|
|
335
|
+
}
|
|
336
|
+
void stopAdvertising() const {
|
|
337
|
+
gea::framework::bluetooth::HidBackend::stopAdvertising();
|
|
338
|
+
}
|
|
339
|
+
bool connected() const {
|
|
340
|
+
return gea::framework::bluetooth::HidBackend::connected();
|
|
341
|
+
}
|
|
212
342
|
bool bound() const { return gea::framework::bluetooth::HidBackend::bound(); }
|
|
213
|
-
double batteryLevel() const {
|
|
214
|
-
|
|
215
|
-
|
|
343
|
+
double batteryLevel() const {
|
|
344
|
+
return gea::framework::bluetooth::HidBackend::batteryLevel();
|
|
345
|
+
}
|
|
346
|
+
std::string mac() const {
|
|
347
|
+
return gea::framework::bluetooth::HidBackend::mac();
|
|
348
|
+
}
|
|
349
|
+
std::string deviceName() const {
|
|
350
|
+
return gea::framework::bluetooth::HidBackend::deviceName();
|
|
351
|
+
}
|
|
216
352
|
};
|
|
217
353
|
|
|
218
354
|
class Geolocation {
|
|
219
355
|
public:
|
|
220
356
|
const Geolocation &operator()() const { return *this; }
|
|
221
357
|
|
|
222
|
-
bool hasFix() const {
|
|
223
|
-
|
|
358
|
+
bool hasFix() const {
|
|
359
|
+
return gea::framework::geolocation::GeolocationBackend::hasFix();
|
|
360
|
+
}
|
|
361
|
+
GeolocationPosition currentPosition() const {
|
|
362
|
+
return gea::framework::geolocation::GeolocationBackend::currentPosition();
|
|
363
|
+
}
|
|
224
364
|
GeolocationCoordinates coords() const { return currentPosition().coords; }
|
|
225
|
-
double latitude() const {
|
|
226
|
-
|
|
227
|
-
|
|
365
|
+
double latitude() const {
|
|
366
|
+
return gea::framework::geolocation::GeolocationBackend::latitude();
|
|
367
|
+
}
|
|
368
|
+
double longitude() const {
|
|
369
|
+
return gea::framework::geolocation::GeolocationBackend::longitude();
|
|
370
|
+
}
|
|
371
|
+
double accuracy() const {
|
|
372
|
+
return gea::framework::geolocation::GeolocationBackend::accuracy();
|
|
373
|
+
}
|
|
228
374
|
|
|
229
|
-
template <typename Success>
|
|
230
|
-
void getCurrentPosition(Success success) const {
|
|
375
|
+
template <typename Success> void getCurrentPosition(Success success) const {
|
|
231
376
|
auto position = currentPosition();
|
|
232
|
-
if (position.hasFix)
|
|
377
|
+
if (position.hasFix)
|
|
378
|
+
success(position);
|
|
233
379
|
}
|
|
234
380
|
|
|
235
381
|
template <typename Success, typename Error>
|
|
236
382
|
void getCurrentPosition(Success success, Error error) const {
|
|
237
383
|
auto position = currentPosition();
|
|
238
|
-
if (position.hasFix)
|
|
239
|
-
|
|
384
|
+
if (position.hasFix)
|
|
385
|
+
success(position);
|
|
386
|
+
else
|
|
387
|
+
error(GeolocationPositionError{2.0, "Position unavailable"});
|
|
240
388
|
}
|
|
241
389
|
|
|
242
390
|
template <typename Success, typename Error, typename Options>
|
|
243
|
-
void getCurrentPosition(Success success, Error error,
|
|
391
|
+
void getCurrentPosition(Success success, Error error,
|
|
392
|
+
const Options &options) const {
|
|
244
393
|
(void)options;
|
|
245
394
|
getCurrentPosition(success, error);
|
|
246
395
|
}
|
|
247
396
|
|
|
248
|
-
template <typename Success>
|
|
249
|
-
double watchPosition(Success success) const {
|
|
397
|
+
template <typename Success> double watchPosition(Success success) const {
|
|
250
398
|
getCurrentPosition(success);
|
|
251
399
|
return 1.0;
|
|
252
400
|
}
|
|
@@ -258,7 +406,8 @@ public:
|
|
|
258
406
|
}
|
|
259
407
|
|
|
260
408
|
template <typename Success, typename Error, typename Options>
|
|
261
|
-
double watchPosition(Success success, Error error,
|
|
409
|
+
double watchPosition(Success success, Error error,
|
|
410
|
+
const Options &options) const {
|
|
262
411
|
(void)options;
|
|
263
412
|
getCurrentPosition(success, error);
|
|
264
413
|
return 1.0;
|
|
@@ -280,4 +429,4 @@ public:
|
|
|
280
429
|
|
|
281
430
|
inline constexpr Navigator navigator{};
|
|
282
431
|
|
|
283
|
-
}
|
|
432
|
+
} // namespace gea::host
|
package/include/host/storage.h
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#pragma once
|
|
3
3
|
|
|
4
4
|
#include "services/storage_service.h"
|
|
5
|
+
#include "platform/internal_stack.h"
|
|
5
6
|
|
|
6
7
|
#include <cstdint>
|
|
7
8
|
#include <cstring>
|
|
@@ -21,11 +22,10 @@ namespace gea::host {
|
|
|
21
22
|
// setItem / removeItem / clear / key / length is a pure in-memory operation —
|
|
22
23
|
// safe from ANY task, at any time (a store constructor, init(), tick(), or an
|
|
23
24
|
// event handler). A mutation only flips a dirty flag; the actual flash write is
|
|
24
|
-
// deferred to flushPending(), which the runtime calls once per frame
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
// once at boot from the frame task.
|
|
25
|
+
// deferred to flushPending(), which the runtime calls once per frame. Flash
|
|
26
|
+
// writes run on the shared internal-stack worker when the runtime stack is in
|
|
27
|
+
// PSRAM, so a cache-disabled flash operation cannot invalidate its own stack.
|
|
28
|
+
// load() runs during boot on the internal bring-up stack.
|
|
29
29
|
//
|
|
30
30
|
// Persistence is delegated to gea::framework::services::StorageService, which
|
|
31
31
|
// stores the whole set as one opaque blob (an NVS blob on esp32, RAM elsewhere),
|
|
@@ -86,7 +86,10 @@ struct StorageFacade {
|
|
|
86
86
|
// from the main frame task — the only context that is allowed to touch flash.
|
|
87
87
|
void flushPending() {
|
|
88
88
|
if (!dirty_) return;
|
|
89
|
-
|
|
89
|
+
const auto blob = serialize();
|
|
90
|
+
gea::platform::onInternalStack([&] {
|
|
91
|
+
gea::framework::services::StorageService::saveKv(blob);
|
|
92
|
+
});
|
|
90
93
|
dirty_ = false;
|
|
91
94
|
}
|
|
92
95
|
|
package/include/host/timers.h
CHANGED
|
@@ -6,11 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
namespace gea::host {
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
using AnimationFrameTimestamp =
|
|
11
|
-
#else
|
|
12
|
-
using AnimationFrameTimestamp = double;
|
|
13
|
-
#endif
|
|
9
|
+
// Application::frame supplies integer milliseconds on every native target.
|
|
10
|
+
using AnimationFrameTimestamp = int;
|
|
14
11
|
|
|
15
12
|
using AnimationFrameCallback = std::function<void(AnimationFrameTimestamp)>;
|
|
16
13
|
using TimerCallback = std::function<void()>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
#include <exception>
|
|
5
|
+
#include <functional>
|
|
6
|
+
#include <mutex>
|
|
7
|
+
#include <stdexcept>
|
|
8
|
+
|
|
9
|
+
#ifdef ESP_PLATFORM
|
|
10
|
+
#include "esp_memory_utils.h"
|
|
11
|
+
#include "freertos/FreeRTOS.h"
|
|
12
|
+
#include "freertos/idf_additions.h"
|
|
13
|
+
#include "freertos/semphr.h"
|
|
14
|
+
#include "freertos/task.h"
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
namespace gea::platform {
|
|
18
|
+
|
|
19
|
+
// Flash-backed VFS and radio configuration can disable caches. Run these
|
|
20
|
+
// operations on an internal stack when a compiled application uses PSRAM.
|
|
21
|
+
inline void onInternalStack(const std::function<void()> &action, unsigned stackBytes = 6144) {
|
|
22
|
+
#ifdef ESP_PLATFORM
|
|
23
|
+
int marker;
|
|
24
|
+
if (esp_ptr_external_ram(&marker)) {
|
|
25
|
+
static std::mutex mutex;
|
|
26
|
+
std::lock_guard<std::mutex> lock(mutex);
|
|
27
|
+
|
|
28
|
+
struct Worker {
|
|
29
|
+
SemaphoreHandle_t ready = nullptr;
|
|
30
|
+
SemaphoreHandle_t done = nullptr;
|
|
31
|
+
const std::function<void()> *action = nullptr;
|
|
32
|
+
std::exception_ptr error;
|
|
33
|
+
TaskHandle_t task = nullptr;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
static Worker worker;
|
|
37
|
+
if (stackBytes > 10240) {
|
|
38
|
+
throw std::runtime_error("Internal-stack action exceeds worker capacity");
|
|
39
|
+
}
|
|
40
|
+
if (!worker.task) {
|
|
41
|
+
worker.ready = xSemaphoreCreateBinary();
|
|
42
|
+
worker.done = xSemaphoreCreateBinary();
|
|
43
|
+
if (!worker.ready || !worker.done) {
|
|
44
|
+
if (worker.ready) {
|
|
45
|
+
vSemaphoreDelete(worker.ready);
|
|
46
|
+
}
|
|
47
|
+
if (worker.done) {
|
|
48
|
+
vSemaphoreDelete(worker.done);
|
|
49
|
+
}
|
|
50
|
+
worker.ready = worker.done = nullptr;
|
|
51
|
+
throw std::runtime_error("Internal-stack semaphore allocation failed");
|
|
52
|
+
}
|
|
53
|
+
const auto run = [](void *argument) {
|
|
54
|
+
auto &worker = *static_cast<Worker *>(argument);
|
|
55
|
+
for (;;) {
|
|
56
|
+
xSemaphoreTake(worker.ready, portMAX_DELAY);
|
|
57
|
+
try {
|
|
58
|
+
(*worker.action)();
|
|
59
|
+
} catch (...) {
|
|
60
|
+
worker.error = std::current_exception();
|
|
61
|
+
}
|
|
62
|
+
worker.action = nullptr;
|
|
63
|
+
xSemaphoreGive(worker.done);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
if (xTaskCreateWithCaps(run, "gea_internal", 10240, &worker, 5, &worker.task,
|
|
67
|
+
MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) != pdPASS) {
|
|
68
|
+
vSemaphoreDelete(worker.ready);
|
|
69
|
+
vSemaphoreDelete(worker.done);
|
|
70
|
+
worker.ready = worker.done = nullptr;
|
|
71
|
+
throw std::runtime_error("Internal-stack worker allocation failed");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
worker.error = {};
|
|
75
|
+
worker.action = &action;
|
|
76
|
+
xSemaphoreGive(worker.ready);
|
|
77
|
+
xSemaphoreTake(worker.done, portMAX_DELAY);
|
|
78
|
+
if (worker.error) {
|
|
79
|
+
std::rethrow_exception(worker.error);
|
|
80
|
+
}
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
#else
|
|
84
|
+
(void)stackBytes;
|
|
85
|
+
#endif
|
|
86
|
+
action();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
} // namespace gea::platform
|