The CH32V003 microcontroller is utilized to implement a lightweight node for a bus-based system, focusing on minimal resource consumption. The project aims to provide RPC support, A/B firmware updates, JSON-based configuration, and basic LED control within a 7 KB application memory limit.
The communication protocol uses an 8-byte header followed by a JSON-RPC 2.0 payload. To optimize performance, the system employs static reflection at compile-time, eliminating the need for RTTI or virtual tables. The JSMN library serves as a lightweight tokenizer for parsing JSON data.
The RPC server is implemented as a template specialization, where methods are defined and registered during compilation. This approach allows for the detection of duplicate handlers and ensures that adding new commands or settings requires minimal code changes, as the reflection mechanism automatically handles the structure updates.
Predefined presets for system functions, settings, and OTA updates are provided as parameterized templates. These presets utilize C++ concepts to enforce interface requirements, ensuring that the firmware remains modular and extensible while maintaining a small memory footprint suitable for the CH32V003.





