@typecad/framework-zephyr 1.0.0-alpha.12 → 1.0.0-alpha.14
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 +13 -1
- package/dist/chips/controllers.d.ts +28 -8
- package/dist/chips/controllers.js +49 -12
- package/dist/chips/resolve.js +32 -6
- package/dist/chips/types.d.ts +63 -12
- package/dist/chips/xiao-ble.js +12 -0
- package/dist/display/index.d.ts +1 -1
- package/dist/display/index.js +1 -1
- package/dist/display/profiles.d.ts +8 -0
- package/dist/display/profiles.js +19 -0
- package/dist/display/ui-adapter.d.ts +4 -0
- package/dist/display/ui-adapter.js +46 -0
- package/dist/dt-config/kconfig.d.ts +11 -0
- package/dist/dt-config/kconfig.js +1 -1
- package/dist/dt-config/overlay.d.ts +8 -1
- package/dist/dt-config/overlay.js +104 -1
- package/dist/framework.manifest.d.ts +20 -30
- package/dist/framework.manifest.js +12 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/lowering/adc.d.ts +7 -4
- package/dist/lowering/adc.js +25 -11
- package/dist/lowering/gpio.js +15 -8
- package/dist/lowering/mqtt.js +9 -1
- package/dist/lowering/pulse.js +7 -7
- package/dist/lowering/pwm.d.ts +21 -3
- package/dist/lowering/pwm.js +28 -4
- package/dist/lowering/spi.js +2 -2
- package/dist/lowering/tone.js +3 -2
- package/dist/lowering/wifi.js +28 -5
- package/dist/strategy.d.ts +20 -0
- package/dist/strategy.js +295 -119
- package/dist/toolchain/debug-config.d.ts +43 -2
- package/dist/toolchain/debug-config.js +129 -17
- package/dist/toolchain/index.d.ts +14 -1
- package/dist/toolchain/index.js +146 -20
- package/dist/toolchain/scaffold.d.ts +9 -0
- package/dist/toolchain/scaffold.js +84 -19
- package/dist/toolchain/west-discover.d.ts +4 -1
- package/dist/toolchain/west-discover.js +2 -0
- package/dist/toolchain/west-spawn.js +17 -5
- package/package.json +5 -5
- package/src/chips/controllers.ts +61 -12
- package/src/chips/resolve.ts +32 -5
- package/src/chips/types.ts +63 -12
- package/src/chips/xiao-ble.ts +82 -70
- package/src/display/index.ts +1 -1
- package/src/display/profiles.ts +23 -0
- package/src/display/ui-adapter.ts +51 -0
- package/src/dt-config/kconfig.ts +12 -1
- package/src/dt-config/overlay.ts +123 -0
- package/src/framework.manifest.ts +12 -3
- package/src/index.ts +6 -0
- package/src/lowering/adc.ts +28 -12
- package/src/lowering/gpio.ts +15 -8
- package/src/lowering/mqtt.ts +9 -1
- package/src/lowering/pulse.ts +7 -7
- package/src/lowering/pwm.ts +29 -4
- package/src/lowering/spi.ts +2 -2
- package/src/lowering/tone.ts +3 -3
- package/src/lowering/wifi.ts +29 -5
- package/src/strategy.ts +320 -123
- package/src/toolchain/debug-config.ts +137 -14
- package/src/toolchain/index.ts +645 -513
- package/src/toolchain/scaffold.ts +81 -17
- package/src/toolchain/west-discover.ts +321 -316
- package/src/toolchain/west-spawn.ts +17 -5
package/src/lowering/gpio.ts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import type { HALOpIR } from '@typecad/cuttlefish/api/shared';
|
|
19
19
|
import type { ZephyrChipDescriptor } from '../chips/types.js';
|
|
20
|
-
import { controllerNodelabelForPin } from '../chips/controllers.js';
|
|
20
|
+
import { controllerNodelabelForPin, controllerRawPinForPin } from '../chips/controllers.js';
|
|
21
21
|
|
|
22
22
|
/** The C identifier emitted for a pin's gpio_dt_spec variable. */
|
|
23
23
|
export function dtSpecVarName(dtSpec: string): string {
|
|
@@ -121,24 +121,31 @@ function lowerGpioRaw(
|
|
|
121
121
|
const o = op as any;
|
|
122
122
|
const pin: number = o.pin;
|
|
123
123
|
// Resolve the owning controller by pin range (ESP32-S3 splits GPIO across
|
|
124
|
-
// gpio0/gpio1). For single-controller SoCs
|
|
124
|
+
// gpio0/gpio1; STM32 across gpioa/gpiob/gpioc). For single-controller SoCs
|
|
125
|
+
// this is just chip.gpioController. The raw API takes the PORT-RELATIVE
|
|
126
|
+
// index (STM32 gpiob is 0-15), not the global HAL pin number.
|
|
125
127
|
const controller = `DEVICE_DT_GET(DT_NODELABEL(${controllerNodelabelForPin(chip, pin)}))`;
|
|
128
|
+
const rawPin = controllerRawPinForPin(chip, pin);
|
|
126
129
|
|
|
127
130
|
switch (op.operation) {
|
|
128
131
|
case 'gpio.set_mode': {
|
|
129
|
-
return { code: `gpio_pin_configure(${controller}, ${
|
|
132
|
+
return { code: `gpio_pin_configure(${controller}, ${rawPin}, ${flagsForMode(o.mode)});` };
|
|
130
133
|
}
|
|
131
134
|
case 'gpio.write': {
|
|
132
135
|
const v = o.value;
|
|
133
136
|
const rhs = typeof v === 'string' ? `((${v}) ? 1 : 0)` : v ? 1 : 0;
|
|
134
|
-
return { code: `gpio_pin_set_raw(${controller}, ${
|
|
137
|
+
return { code: `gpio_pin_set_raw(${controller}, ${rawPin}, ${rhs});` };
|
|
135
138
|
}
|
|
136
139
|
case 'gpio.read':
|
|
137
|
-
return { expression: `gpio_pin_get_raw(${controller}, ${
|
|
140
|
+
return { expression: `gpio_pin_get_raw(${controller}, ${rawPin})` };
|
|
138
141
|
case 'gpio.toggle':
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
// Native atomic toggle — never read-modify-write. gpio_pin_get_raw on
|
|
143
|
+
// a direction-only output reads the input latch, which is undefined on
|
|
144
|
+
// SoCs that don't latch it. Zephyr's toggle API has no _raw variant —
|
|
145
|
+
// gpio_pin_toggle is the driver-level atomic toggle, and for pins
|
|
146
|
+
// configured without GPIO_ACTIVE_LOW the logical level equals the
|
|
147
|
+
// physical one, so it matches the get_raw/set_raw used elsewhere.
|
|
148
|
+
return { code: `gpio_pin_toggle(${controller}, ${rawPin});` };
|
|
142
149
|
default:
|
|
143
150
|
throw new Error(
|
|
144
151
|
`framework-zephyr does not yet support HAL op \`${op.operation}\`. ` +
|
package/src/lowering/mqtt.ts
CHANGED
|
@@ -294,7 +294,15 @@ export function mqttInitLines(): string[] {
|
|
|
294
294
|
` (void)k_thread_create(&__tc_mqtt.poll_thread, __tc_mqtt_stack,`,
|
|
295
295
|
` K_THREAD_STACK_SIZEOF(__tc_mqtt_stack),`,
|
|
296
296
|
` __tc_mqtt_poll_thread, nullptr, nullptr, nullptr,`,
|
|
297
|
-
` 5, 0,
|
|
297
|
+
` 5, 0, K_FOREVER);`,
|
|
298
|
+
`#ifdef CONFIG_SMP`,
|
|
299
|
+
` // On SMP targets park the poll thread on the app core so the network`,
|
|
300
|
+
` // stack never competes with the main/UI thread for core 0. k_thread_cpu_pin`,
|
|
301
|
+
` // is SMP-only; the pin happens before k_thread_start (which is why the`,
|
|
302
|
+
` // thread is created K_FOREVER). Compiles away on !SMP builds.`,
|
|
303
|
+
` (void)k_thread_cpu_pin(&__tc_mqtt.poll_thread, 1);`,
|
|
304
|
+
`#endif`,
|
|
305
|
+
` k_thread_start(&__tc_mqtt.poll_thread);`,
|
|
298
306
|
`}`,
|
|
299
307
|
``,
|
|
300
308
|
`static inline void __tc_mqtt_set_on_message(__tc_mqtt_msg_cb_t fn) {`,
|
package/src/lowering/pulse.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import type { HALOpIR } from '@typecad/cuttlefish/api/shared';
|
|
12
12
|
import type { ZephyrChipDescriptor } from '../chips/types.js';
|
|
13
|
-
import { controllerNodelabelForPin } from '../chips/controllers.js';
|
|
13
|
+
import { controllerNodelabelForPin, controllerRawPinForPin } from '../chips/controllers.js';
|
|
14
14
|
|
|
15
15
|
/** `DEVICE_DT_GET(DT_NODELABEL(<owning-controller>))` for a HAL pin. */
|
|
16
16
|
function devForPin(chip: ZephyrChipDescriptor, pin: number): string {
|
|
@@ -32,9 +32,9 @@ export function lowerPulseOrShift(
|
|
|
32
32
|
// for the start edge is bounded by the timeout; the measurement of the
|
|
33
33
|
// pulse itself is intentionally unbounded (that IS the pulse length).
|
|
34
34
|
// Returns -1 (0) if the start edge never arrives within the timeout.
|
|
35
|
-
const pin = o.pin;
|
|
35
|
+
const pin = controllerRawPinForPin(chip, o.pin);
|
|
36
36
|
const want = o.value;
|
|
37
|
-
const dev = devForPin(chip, pin);
|
|
37
|
+
const dev = devForPin(chip, o.pin);
|
|
38
38
|
const timeout = o.timeout ?? 1_000_000; // default 1s in us
|
|
39
39
|
return {
|
|
40
40
|
expression: `({ int64_t __max = static_cast<int64_t>(${timeout} / 1000); int64_t __t0 = k_uptime_get(); bool __ok = true; while (gpio_pin_get_raw(${dev}, ${pin}) != ${want}) { if ((k_uptime_get() - __t0) > __max) { __ok = false; break; } } int32_t __ret = 0; if (__ok) { int64_t __start = k_uptime_get(); while (gpio_pin_get_raw(${dev}, ${pin}) == ${want}) { } __ret = static_cast<int32_t>((k_uptime_get() - __start) * 1000); } __ret; })`,
|
|
@@ -45,9 +45,9 @@ export function lowerPulseOrShift(
|
|
|
45
45
|
// with NO timeout (the comment claimed "no overflow concern" but the
|
|
46
46
|
// real risk was hanging the thread on a stuck pin). Apply the same
|
|
47
47
|
// timeout-bounded start-edge wait as pulse.in (bug Q5).
|
|
48
|
-
const pin = o.pin;
|
|
48
|
+
const pin = controllerRawPinForPin(chip, o.pin);
|
|
49
49
|
const want = o.value;
|
|
50
|
-
const dev = devForPin(chip, pin);
|
|
50
|
+
const dev = devForPin(chip, o.pin);
|
|
51
51
|
const timeout = o.timeout ?? 3_000_000; // default 3s in us (long pulses)
|
|
52
52
|
return {
|
|
53
53
|
expression: `({ int64_t __max = static_cast<int64_t>(${timeout} / 1000); int64_t __t0 = k_uptime_get(); bool __ok = true; while (gpio_pin_get_raw(${dev}, ${pin}) != ${want}) { if ((k_uptime_get() - __t0) > __max) { __ok = false; break; } } int32_t __ret = 0; if (__ok) { int64_t __start = k_uptime_get(); while (gpio_pin_get_raw(${dev}, ${pin}) == ${want}) { } __ret = static_cast<int32_t>((k_uptime_get() - __start) * 1000); } __ret; })`,
|
|
@@ -66,7 +66,7 @@ export function lowerPulseOrShift(
|
|
|
66
66
|
const test = msbFirst ? '(__i >= 0)' : '(__i < 8)';
|
|
67
67
|
const step = msbFirst ? '__i--' : '__i++';
|
|
68
68
|
return {
|
|
69
|
-
code: `for (int __i = ${init}; ${test}; ${step}) { gpio_pin_set_raw(${dataDev}, ${dataPin}, (${o.value} >> __i) & 1); gpio_pin_set_raw(${clockDev}, ${clockPin}, 1); k_busy_wait(1); gpio_pin_set_raw(${clockDev}, ${clockPin}, 0); }`,
|
|
69
|
+
code: `for (int __i = ${init}; ${test}; ${step}) { gpio_pin_set_raw(${dataDev}, ${controllerRawPinForPin(chip, dataPin)}, (${o.value} >> __i) & 1); gpio_pin_set_raw(${clockDev}, ${controllerRawPinForPin(chip, clockPin)}, 1); k_busy_wait(1); gpio_pin_set_raw(${clockDev}, ${controllerRawPinForPin(chip, clockPin)}, 0); }`,
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
72
|
case 'shift.in': {
|
|
@@ -81,7 +81,7 @@ export function lowerPulseOrShift(
|
|
|
81
81
|
const step = msbFirst ? '__i--' : '__i++';
|
|
82
82
|
const accum = msbFirst ? '__v = (__v << 1)' : '__v |= (bit << __i)';
|
|
83
83
|
return {
|
|
84
|
-
expression: `({ uint8_t __v = 0; for (int __i = ${init}; ${test}; ${step}) { gpio_pin_set_raw(${clockDev}, ${clockPin}, 1); k_busy_wait(1); int bit = gpio_pin_get_raw(${dataDev}, ${dataPin}); gpio_pin_set_raw(${clockDev}, ${clockPin}, 0); ${accum}; } __v; })`,
|
|
84
|
+
expression: `({ uint8_t __v = 0; for (int __i = ${init}; ${test}; ${step}) { gpio_pin_set_raw(${clockDev}, ${controllerRawPinForPin(chip, clockPin)}, 1); k_busy_wait(1); int bit = gpio_pin_get_raw(${dataDev}, ${controllerRawPinForPin(chip, dataPin)}); gpio_pin_set_raw(${clockDev}, ${controllerRawPinForPin(chip, clockPin)}, 0); ${accum}; } __v; })`,
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
default:
|
package/src/lowering/pwm.ts
CHANGED
|
@@ -10,6 +10,26 @@
|
|
|
10
10
|
import type { HALOpIR } from '@typecad/cuttlefish/api/shared';
|
|
11
11
|
import type { ZephyrChipDescriptor, ZephyrPwmSpec } from '../chips/types.js';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* The DT alias a PWM spec is addressed by. Board-shipped specs carry their
|
|
15
|
+
* alias in `dtSpec`; synthesized specs (controller + channel) get a
|
|
16
|
+
* `tc-pwm<pin>` alias that the overlay generator creates in
|
|
17
|
+
* <board>.overlay — both sides derive the name from the pin so they agree.
|
|
18
|
+
*/
|
|
19
|
+
export function pwmDtAlias(spec: ZephyrPwmSpec): string {
|
|
20
|
+
return spec.dtSpec ?? `tc-pwm${spec.pin}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The C macro token for a spec's alias. Zephyr's devicetree macros replace
|
|
25
|
+
* dashes in alias names with underscores (`pwm-led0` in DTS is
|
|
26
|
+
* DT_ALIAS(pwm_led0) in C) — the dashed spelling is a subtraction
|
|
27
|
+
* expression and fails to compile (caught by the blackpill E2E west build).
|
|
28
|
+
*/
|
|
29
|
+
export function pwmDtAliasToken(spec: ZephyrPwmSpec): string {
|
|
30
|
+
return pwmDtAlias(spec).replace(/-/g, '_');
|
|
31
|
+
}
|
|
32
|
+
|
|
13
33
|
/** Look up a PWM spec by HAL pin number. */
|
|
14
34
|
function findPwmSpec(chip: ZephyrChipDescriptor, pin: number): ZephyrPwmSpec | undefined {
|
|
15
35
|
return chip.pwm?.specs.find((s) => s.pin === pin);
|
|
@@ -17,18 +37,23 @@ function findPwmSpec(chip: ZephyrChipDescriptor, pin: number): ZephyrPwmSpec | u
|
|
|
17
37
|
|
|
18
38
|
/** The C variable name emitted for a PWM channel's spec. */
|
|
19
39
|
function pwmVarName(spec: ZephyrPwmSpec): string {
|
|
20
|
-
return `__tc_pwm_${spec
|
|
40
|
+
return `__tc_pwm_${pwmDtAliasToken(spec)}`;
|
|
21
41
|
}
|
|
22
42
|
|
|
23
43
|
/**
|
|
24
44
|
* Emit the per-channel PWM spec declarations. One per spec in the chip
|
|
25
|
-
* descriptor
|
|
45
|
+
* descriptor that the PROGRAM ACTUALLY DRIVES (`usedPins`) — a spec for an
|
|
46
|
+
* untouched pin is unused code in the emitted TU (and would need a dead DT
|
|
47
|
+
* alias in the overlay). When `usedPins` is omitted (probe paths with no
|
|
48
|
+
* program), every spec is emitted. Called from shimLines when the program
|
|
49
|
+
* uses PWM.
|
|
26
50
|
*/
|
|
27
|
-
export function pwmInitLines(chip: ZephyrChipDescriptor): string[] {
|
|
51
|
+
export function pwmInitLines(chip: ZephyrChipDescriptor, usedPins?: ReadonlySet<number>): string[] {
|
|
28
52
|
const lines: string[] = ['// CUTTLEFISH_PWM_BEGIN'];
|
|
29
53
|
for (const spec of chip.pwm?.specs ?? []) {
|
|
54
|
+
if (usedPins && !usedPins.has(spec.pin)) continue;
|
|
30
55
|
lines.push(
|
|
31
|
-
`static const struct pwm_dt_spec ${pwmVarName(spec)} = PWM_DT_SPEC_GET(DT_ALIAS(${spec
|
|
56
|
+
`static const struct pwm_dt_spec ${pwmVarName(spec)} = PWM_DT_SPEC_GET(DT_ALIAS(${pwmDtAliasToken(spec)}));`,
|
|
32
57
|
);
|
|
33
58
|
}
|
|
34
59
|
lines.push('// CUTTLEFISH_PWM_END');
|
package/src/lowering/spi.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import type { HALOpIR } from '@typecad/cuttlefish/api/shared';
|
|
16
16
|
import type { ZephyrChipDescriptor } from '../chips/types.js';
|
|
17
17
|
import { parseControllerIndex } from './util.js';
|
|
18
|
-
import { controllerNodelabelForPin } from '../chips/controllers.js';
|
|
18
|
+
import { controllerNodelabelForPin, controllerRawPinForPin } from '../chips/controllers.js';
|
|
19
19
|
|
|
20
20
|
/** The C variable prefix for a controller's state. */
|
|
21
21
|
function prefix(idx: number): string {
|
|
@@ -112,7 +112,7 @@ export function lowerSpi(
|
|
|
112
112
|
const val = op.operation === 'spi.cs_low' ? 0 : 1;
|
|
113
113
|
const gpioController = controllerNodelabelForPin(chip, o.pin);
|
|
114
114
|
return {
|
|
115
|
-
code: `gpio_pin_set_raw(DEVICE_DT_GET(DT_NODELABEL(${gpioController})), ${o.pin}, ${val});`,
|
|
115
|
+
code: `gpio_pin_set_raw(DEVICE_DT_GET(DT_NODELABEL(${gpioController})), ${controllerRawPinForPin(chip, o.pin)}, ${val});`,
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
default:
|
package/src/lowering/tone.ts
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import type { HALOpIR } from '@typecad/cuttlefish/api/shared';
|
|
16
16
|
import type { ZephyrChipDescriptor } from '../chips/types.js';
|
|
17
|
-
import { lowerPwm } from './pwm.js';
|
|
17
|
+
import { lowerPwm, pwmDtAliasToken } from './pwm.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Resolve a HAL tone.* op to Zephyr C++ via PWM.
|
|
@@ -35,7 +35,7 @@ export function lowerTone(
|
|
|
35
35
|
if (!spec) {
|
|
36
36
|
return { code: `/* tone.play(${o.frequency}): no PWM spec in chip descriptor */` };
|
|
37
37
|
}
|
|
38
|
-
const v = `__tc_pwm_${spec
|
|
38
|
+
const v = `__tc_pwm_${pwmDtAliasToken(spec)}`;
|
|
39
39
|
const freq = o.frequency;
|
|
40
40
|
const duration = o.duration;
|
|
41
41
|
const setTone = `uint32_t __period = (${freq} > 0) ? (1000000000ULL / static_cast<uint64_t>(${freq})) : 0; pwm_set_dt(&${v}, __period, __period / 2);`;
|
|
@@ -48,7 +48,7 @@ export function lowerTone(
|
|
|
48
48
|
case 'tone.stop': {
|
|
49
49
|
const spec = chip.pwm?.specs[0];
|
|
50
50
|
if (!spec) return { code: `/* tone.stop: no PWM spec */` };
|
|
51
|
-
const v = `__tc_pwm_${spec
|
|
51
|
+
const v = `__tc_pwm_${pwmDtAliasToken(spec)}`;
|
|
52
52
|
return { code: `pwm_set_pulse_dt(&${v}, 0);` };
|
|
53
53
|
}
|
|
54
54
|
default:
|
package/src/lowering/wifi.ts
CHANGED
|
@@ -126,6 +126,29 @@ export function wifiInitLines(): string[] {
|
|
|
126
126
|
` }`,
|
|
127
127
|
` __tc_wifi.inited = true;`,
|
|
128
128
|
`}`,
|
|
129
|
+
``,
|
|
130
|
+
`// ── blocking-wait pump ───────────────────────────────────────────────────`,
|
|
131
|
+
`// Blocking wifi waits hold the main thread, which suspends the loop()-driven`,
|
|
132
|
+
`// ui_tick — a 15s association would freeze the display for its whole`,
|
|
133
|
+
`// duration. Each wait slice sleeps 20ms and, in the entry TU of a UI build`,
|
|
134
|
+
`// (the only TU carrying the ui_tick definition), pumps one frame so`,
|
|
135
|
+
`// animations and touch stay live during the wait. Constraint: do NOT call`,
|
|
136
|
+
`// blocking wifi waits from inside UI event handlers — that re-enters`,
|
|
137
|
+
`// ui_tick mid-tick; use wifi.connect_start + wifi.is_connected there.`,
|
|
138
|
+
`#ifdef CUTTLEFISH_ENTRY_UI_TU`,
|
|
139
|
+
`static void ui_tick(uint16_t deltaMs); // defined by the UI runtime header`,
|
|
140
|
+
`#endif`,
|
|
141
|
+
`static void __tc_wifi_wait_slice(uint32_t slice_ms) {`,
|
|
142
|
+
` k_msleep(slice_ms);`,
|
|
143
|
+
`#ifdef CUTTLEFISH_ENTRY_UI_TU`,
|
|
144
|
+
` static uint32_t last_ms = 0U;`,
|
|
145
|
+
` uint32_t now_ms = k_uptime_get_32();`,
|
|
146
|
+
` uint32_t delta = (last_ms != 0U) ? (now_ms - last_ms) : 0U;`,
|
|
147
|
+
` if (delta > 250U) delta = 250U; // same clamp as the loop() tick injection`,
|
|
148
|
+
` last_ms = now_ms;`,
|
|
149
|
+
` ui_tick(static_cast<uint16_t>(delta));`,
|
|
150
|
+
`#endif`,
|
|
151
|
+
`}`,
|
|
129
152
|
`// CUTTLEFISH_WIFI_CORE_END`,
|
|
130
153
|
``,
|
|
131
154
|
`// ── connect / disconnect (net_mgmt — conn_mgr monitor supplies L4 events) ─`,
|
|
@@ -180,8 +203,9 @@ export function wifiInitLines(): string[] {
|
|
|
180
203
|
`static void __tc_wifi_connect(const char* ssid, const char* password, int32_t timeout_ms) {`,
|
|
181
204
|
` __tc_wifi_connect_start(ssid, password);`,
|
|
182
205
|
` // Block until the L4 handler signals connectivity or the deadline passes.`,
|
|
206
|
+
` // 20ms slices let __tc_wifi_wait_slice pump the UI between polls.`,
|
|
183
207
|
` int32_t waited = 0;`,
|
|
184
|
-
` while (!__tc_wifi.connected && waited < timeout_ms) {
|
|
208
|
+
` while (!__tc_wifi.connected && waited < timeout_ms) { __tc_wifi_wait_slice(20); waited += 20; }`,
|
|
185
209
|
` printk("tc-wifi: connect %s after %dms\\n", __tc_wifi.connected ? "ok" : "timeout", waited);`,
|
|
186
210
|
`}`,
|
|
187
211
|
`// CUTTLEFISH_WIFI_CONNECT_BLOCKING_END`,
|
|
@@ -245,7 +269,7 @@ export function wifiInitLines(): string[] {
|
|
|
245
269
|
``,
|
|
246
270
|
`static void __tc_wifi_scan_blocking(void) {`,
|
|
247
271
|
` __tc_wifi_scan_start();`,
|
|
248
|
-
` while (__tc_wifi.scanning) {
|
|
272
|
+
` while (__tc_wifi.scanning) { __tc_wifi_wait_slice(20); }`,
|
|
249
273
|
`}`,
|
|
250
274
|
``,
|
|
251
275
|
`static const char* __tc_wifi_scan_ssid(int32_t i) {`,
|
|
@@ -313,13 +337,13 @@ export function wifiInitLines(): string[] {
|
|
|
313
337
|
`static void __tc_wifi_wait_connected(int32_t timeout_ms) {`,
|
|
314
338
|
` __tc_wifi_ensure_init();`,
|
|
315
339
|
` int32_t waited = 0;`,
|
|
316
|
-
` while (!__tc_wifi.connected && waited < timeout_ms) {
|
|
340
|
+
` while (!__tc_wifi.connected && waited < timeout_ms) { __tc_wifi_wait_slice(20); waited += 20; }`,
|
|
317
341
|
`}`,
|
|
318
|
-
|
|
342
|
+
|
|
319
343
|
`static void __tc_wifi_wait_disconnected(void) {`,
|
|
320
344
|
` __tc_wifi_ensure_init();`,
|
|
321
345
|
` // No timeout in the HAL surface — block until the L4 handler clears the flag.`,
|
|
322
|
-
` while (__tc_wifi.connected) {
|
|
346
|
+
` while (__tc_wifi.connected) { __tc_wifi_wait_slice(20); }`,
|
|
323
347
|
`}`,
|
|
324
348
|
``,
|
|
325
349
|
`// ── AP mode (NET_REQUEST_WIFI_AP_ENABLE / DISABLE) ──────────────────────`,
|