Use this page when you cannot open the full reference SOIFGO_AI_CONTEXT.md (complete, much longer). Everything a beginner needs to go from an idea to a running page is here.
window.soifgo: Bluetooth (two module families, both tested: Classic SPP such as HC-05, HC-06, JDY-31, and BLE such as JDY-23, DX-BT05, CC2541; boards such as Arduino, ESP32, ESP8266), MQTT, HTTP API, phone sensors, the microphone and the camera (permission through the camera_permission Sub).html_bluetooth_rx and html_bluetooth_tx are used for both families.Browser or HTML File.window.soifgo does not exist in a normal browser.A new project is empty. The order is fixed: folder, then page, then button. The top-left icon is the main menu; its first item switches between Play (run) and Edit (design). SoifGo always opens in Play.
| Step | Action | What the user sees |
|---|---|---|
| 1 | In Play, tap the top-left icon, then Edit. | The icon becomes a Pause symbol. This is Edit. |
| 2 | Top-left icon, then Select Design. | The list shows only folder. This is normal. |
| 3 | Tap folder and create a folder. | A folder exists. |
| 4 | Tap Page and create a New Page. Tapping Page alone is not enough. | A page exists. |
| 5 | Now Background, Button (max 40), SeekBar (max 10) and btnstartup appear. | The list is complete. |
| 6 | Tap Button. | A button is placed on the page and is in move mode. |
| 7 | Fix it in place: tap it, or tap the close icon at the top, or press the phone Back button. | The button stays where it is. |
If the user cannot see Button, the folder or the page does not exist yet. Go back to steps 3 and 4.
Behavior, then Browser or HTML File.Select Behavior dialog shows two choices: Open URL in Browser (a website, not needed here) and Open or Edit Local HTML File in WebView.Html. Choose the second.Create (+) (a default "Hello SoifGo" page), File Explorer (an HTML file from the phone), Sample (built-in examples) and Saved (pages saved earlier in the project). For a first start, recommend Create (+), confirm the name, and finish.If the user's screen shows slightly different wording, follow what the screen shows; it is the same feature.
Play. Tap the WebView button. The WebView opens.Edit. No extra dialog appears. The code editor opens.Select All and Paste. The clipboard replaces the whole file.This is visible in the app under Edit, Select Design, Page. Give the Classic Context to the AI assistant, describe the page, and take the design code back from it.
Page menu has: Cancel, New Page, Open Page, Save Page, Save As, Rename, Copy AI Context, New Page Past Ai (spelled like this on screen).Copy AI Context copies the Classic Context: a second, separate AI context for pages of native buttons and sliders. It is not the WebView manual on this page.Edit → Select Design → Page → Copy AI Context; paste it into the AI chat with the idea; copy the design code the AI returns; then Edit → Select Design → Page → New Page Past Ai. If the app shows an error, paste the error to the AI so it returns a corrected full block.Copy AI Context copies.ON\n and OFF\n), so both sides agree. For Classic modules (HC-05, HC-06, JDY-31), pair the module in Android Settings first.window.soifgo.CallSub('subName', true, arg1, arg2, arg3)
true. Never omit it, never pass false.true, pass exactly the number of arguments listed for that Sub (0 to 3). If a required value is empty, pass ''. Never add extra arguments and never drop a required one: a wrong count can raise an error or close the app.if (window.soifgo) { ... }.window, for example window.html_bluetooth_tx = function(data) { ... };.| Sub | Arguments after true | Purpose |
|---|---|---|
html_bluetooth_rx | 1: text | SEND text to Bluetooth (the name looks swapped, it is correct). By default SoifGo adds CR+LF. |
bluetooth_eol | 1: mode | Line ending added by html_bluetooth_rx: 'CRLF' (default), 'CR', 'LF', 'STXETX', 'NULL', 'NON'. Call once in window.onload before sending; it resets to CRLF when the WebView closes. |
sensor_light | 0 | Activate light sensor |
sensor_move | 0 | Activate accelerometer (X, Y and Z) |
sensor_magno | 0 | Activate magnetometer (X, Y, Z) |
sensor_barometer | 0 | Activate barometer (air pressure) |
camera_permission | 0 | Ask for camera permission. The answer arrives in html_camera_status. Call getUserMedia only after 'true'. |
connecte_mqtt_ai | 2: address, id | MQTT connect, step 1 |
connecte_mqtt_up | 2: username, password (both non-empty) | MQTT connect, step 2 (optional) |
mqtt_retained | 1: 1 or 0 | Retained option for the next publish. Call before mqtt_publish. |
mqtt_publish | 3: topic, message, qos | Publish (also auto-subscribes to the topic) |
mqtt_Disconnect | 0 | Disconnect MQTT |
mqtt_status | 0 | Check MQTT status |
api_send | 3: address, key, value | API POST |
api_recive | 2: address, key | API GET (the spelling "recive" is correct) |
window)| Function | Arguments | Purpose |
|---|---|---|
html_bluetooth_tx | data | RECEIVE Bluetooth text (the name looks swapped, it is correct) |
html_sensor_light | data | Light value (integer, as string) |
html_sensor_movex | data | Movement X (3 decimals, as string) |
html_sensor_movey | data | Movement Y (3 decimals, as string) |
html_sensor_movez | data | Movement Z (3 decimals, as string). Axis perpendicular to the screen; not for tilt |
html_sensor_magnox | data | Magnetic X (3 decimals, as string) |
html_sensor_magnoy | data | Magnetic Y (3 decimals, as string) |
html_sensor_magnoz | data | Magnetic Z (3 decimals, as string) |
html_sensor_barometer | data | Barometer / air pressure (hPa, 3 decimals, as string) |
html_camera_status | data | The string 'true' or 'false': result of the camera permission; compare with === 'true' |
mqtt_rx | topic, message | MQTT message |
html_mqtt_status | connected | The string 'true' or 'false'; compare with === 'true' |
api_rx | number | API response (a plain value or a Map string like {usd=86750}; handle both) |
<button onclick="send('ON')">ON</button>
<button onclick="send('OFF')">OFF</button>
<pre id="log"></pre>
<script>
function send(t) {
if (window.soifgo) { window.soifgo.CallSub('html_bluetooth_rx', true, t); }
}
window.html_bluetooth_tx = function (data) {
document.getElementById('log').textContent += data + '\n';
};
</script>
localStorage persists across reloads; wrap it in try/catch. alert, confirm and prompt work natively.