diff options
| author | Your Name <you@example.com> | 2026-05-19 02:31:19 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-19 02:32:41 +0530 |
| commit | 81f2dc52dc42d01c89dff45a5407ec40b8863052 (patch) | |
| tree | 15018c2438639ca89dc6d33a5144c10d0b1c2af0 /components/qrcode/include | |
| parent | 75688d55b3c8d13c8c9a50da9668ec408f684cb3 (diff) | |
feat: local Nostr relay with relay selection, sync, and integration tests
Local Nostr relay (NIP-01) on port 4869 with LittleFS 4MB storage.
All events published locally first, then synced to public relays via REQ-diff.
Relay selection via NIP-11 HTTP probing with NIP-77 scoring and auto-failover.
Components:
- wisp_relay: 16-file local relay (ws_server, storage_engine, sub_manager,
broadcaster, relay_validator, router, handlers, rate_limiter, nip11,
deletion, flash_monitor, relay_types)
- esp_littlefs: LittleFS VFS integration (git submodule)
- negentropy: for future NIP-77 binary sync (git submodule)
New source files:
- local_relay.c/h: thin wrapper for relay init/start/publish
- relay_selector.c/h: NIP-11 probe + scoring + auto-failover
- sync_manager.c/h: REQ-diff sync (primary 30min, fallback 6h)
Bug fixes:
- config.c: use-after-free (cJSON_Delete before seed_relays/sync parsing)
- local_relay: moved init to app_main for boot-time start (not gated on STA IP)
Flash layout: 4MB LittleFS partition at 0x500000 for relay_store
Test results (Board B, live hardware):
- Smoke: ping + HTTP 4869 + NIP-11: PASS
- NIP-11 info document: 10/11 PASS
- WS pub/sub (connect, REQ/EOSE, EVENT/OK, CLOSE, concurrent): 6/6 PASS
- Unit tests (relay_validator + relay_selector): 13/13 PASS
Hardware test make targets in physical-router-test-automation/:
- make relay-build, relay-flash-b, relay-test-smoke/nip11/pubsub/sync/full
Diffstat (limited to 'components/qrcode/include')
| -rwxr-xr-x | components/qrcode/include/qrcoded.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/components/qrcode/include/qrcoded.h b/components/qrcode/include/qrcoded.h new file mode 100755 index 0000000..602f9c0 --- /dev/null +++ b/components/qrcode/include/qrcoded.h | |||
| @@ -0,0 +1,85 @@ | |||
| 1 | /** | ||
| 2 | * The MIT License (MIT) | ||
| 3 | * | ||
| 4 | * This library is written and maintained by Richard Moore. | ||
| 5 | * Major parts were derived from Project Nayuki's library. | ||
| 6 | * | ||
| 7 | * Copyright (c) 2017 Richard Moore (https://github.com/ricmoo/QRCode) | ||
| 8 | * Copyright (c) 2017 Project Nayuki (https://www.nayuki.io/page/qr-code-generator-library) | ||
| 9 | * | ||
| 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 11 | * of this software and associated documentation files (the "Software"), to deal | ||
| 12 | * in the Software without restriction, including without limitation the rights | ||
| 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 14 | * copies of the Software, and to permit persons to whom the Software is | ||
| 15 | * furnished to do so, subject to the following conditions: | ||
| 16 | * | ||
| 17 | * The above copyright notice and this permission notice shall be included in | ||
| 18 | * all copies or substantial portions of the Software. | ||
| 19 | * | ||
| 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 26 | * THE SOFTWARE. | ||
| 27 | */ | ||
| 28 | |||
| 29 | /** | ||
| 30 | * Special thanks to Nayuki (https://www.nayuki.io/) from which this library was | ||
| 31 | * heavily inspired and compared against. | ||
| 32 | * | ||
| 33 | * See: https://github.com/nayuki/QR-Code-generator/tree/master/cpp | ||
| 34 | */ | ||
| 35 | |||
| 36 | #ifndef __QRCODE_H_ | ||
| 37 | #define __QRCODE_H_ | ||
| 38 | |||
| 39 | #include <stdbool.h> | ||
| 40 | #include <stdint.h> | ||
| 41 | |||
| 42 | // QR Code Format Encoding | ||
| 43 | #define MODE_NUMERIC 0 | ||
| 44 | #define MODE_ALPHANUMERIC 1 | ||
| 45 | #define MODE_BYTE 2 | ||
| 46 | |||
| 47 | // Error Correction Code Levels | ||
| 48 | #define ECC_LOW 0 | ||
| 49 | #define ECC_MEDIUM 1 | ||
| 50 | #define ECC_QUARTILE 2 | ||
| 51 | #define ECC_HIGH 3 | ||
| 52 | |||
| 53 | // If set to non-zero, this library can ONLY produce QR codes at that version | ||
| 54 | // This saves a lot of dynamic memory, as the codeword tables are skipped | ||
| 55 | #ifndef LOCK_VERSION | ||
| 56 | #define LOCK_VERSION 0 | ||
| 57 | #endif | ||
| 58 | |||
| 59 | typedef struct QRCode | ||
| 60 | { | ||
| 61 | uint8_t version; | ||
| 62 | uint8_t size; | ||
| 63 | uint8_t ecc; | ||
| 64 | uint8_t mode; | ||
| 65 | uint8_t mask; | ||
| 66 | uint8_t *modules; | ||
| 67 | } QRCode; | ||
| 68 | |||
| 69 | #ifdef __cplusplus | ||
| 70 | extern "C" | ||
| 71 | { | ||
| 72 | #endif /* __cplusplus */ | ||
| 73 | |||
| 74 | uint16_t qrcode_getBufferSize(uint8_t version); | ||
| 75 | |||
| 76 | int8_t qrcode_initText(QRCode *qrcoded, uint8_t *modules, uint8_t version, uint8_t ecc, const char *data); | ||
| 77 | int8_t qrcode_initBytes(QRCode *qrcoded, uint8_t *modules, uint8_t version, uint8_t ecc, uint8_t *data, uint16_t length); | ||
| 78 | |||
| 79 | bool qrcode_getModule(QRCode *qrcoded, uint8_t x, uint8_t y); | ||
| 80 | |||
| 81 | #ifdef __cplusplus | ||
| 82 | } | ||
| 83 | #endif /* __cplusplus */ | ||
| 84 | |||
| 85 | #endif /* __QRCODE_H_ */ | ||