Update README and environment configuration; enhance code1 functionality and add assembly code

This commit is contained in:
2026-10-13 20:17:34 -05:00
parent 1ff23a3004
commit 8775601f49
7 changed files with 140 additions and 19 deletions
+13 -7
View File
@@ -49,6 +49,10 @@ Copy-Item dev.env .env
You can also provide `DEV_SECRET_KEY` through the process environment. Do not
commit secrets or expose them in client-side code.
Set `PROD=true` to make the server start in the live state. Truthy values are
`1`, `true`, `yes`, and `on` (case-insensitive); an absent or other value starts
the server offline.
Code 1 sends an SMS through TextBee when the server is live. Set
`TEXTBEE_API_KEY`, `RECIPIENT_SELF`, `RECIPIENT_1`, and `RECIPIENT_2` (each a
single E.164 number) in `.env`; `TEXTBEE_DEVICE_ID` is optional and selects a
@@ -65,16 +69,18 @@ the notification instead while offline). The result page displays
step when ready.
The robot submits code 1 with `POST /event/buzz` and a JSON body containing
`delta_ms` (a signed integer) and `secret` (the value of `CODE1_SECRET`).
`delay_ms` (a non-negative integer) and `secret` (the value of `CODE1_SECRET`).
The server subtracts the target delay of 6430 ms from `delay_ms` to calculate
the signed buzz delta.
Set `CODE1_SECRET` to a unique random secret of at least 32 bytes in
`.env`. For example, with the server running locally:
```sh
curl.exe -X POST http://127.0.0.1:3000/event/buzz -H "Content-Type: application/json" -d '{"delta_ms":-42,"secret":"<your CODE1_SECRET value>"}'
curl.exe -X POST http://127.0.0.1:3000/event/buzz -H "Content-Type: application/json" -d '{"delay_ms":6388,"secret":"<your CODE1_SECRET value>"}'
```
The integer `delta_ms` value is passed through to the congratulations message;
a valid request returns HTTP `202`.
The server calculates `6388 - 6430 = -42` ms for the congratulations message.
A valid request returns HTTP `202`.
### Test code1 with Postman
@@ -82,7 +88,7 @@ Create a `POST` request to `http://127.0.0.1:3000/event/buzz`, select **Body >
raw > JSON**, and send:
```json
{
"delta_ms": -42,
"delay_ms": 6388,
"secret": "<your CODE1_SECRET value>"
}
```
@@ -94,14 +100,14 @@ single test event:
```javascript
async function main() {
const deltaMs = -42;
const delayMs = 6388;
const secret = process.env.CODE1_SECRET;
if (!secret) throw new Error("CODE1_SECRET is not set");
const response = await fetch("http://127.0.0.1:3000/event/buzz", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ delta_ms: deltaMs, secret }),
body: JSON.stringify({ delay_ms: delayMs, secret }),
});
console.log(response.status, await response.text());