Skip to content

feat: Add libcbv2g_json_wrapper core + AppHandshake converter#57

Open
biubiuzhang wants to merge 3 commits intoEVerest:everestfrom
biubiuzhang:feature/cbv2g-json-wrapper-core
Open

feat: Add libcbv2g_json_wrapper core + AppHandshake converter#57
biubiuzhang wants to merge 3 commits intoEVerest:everestfrom
biubiuzhang:feature/cbv2g-json-wrapper-core

Conversation

@biubiuzhang
Copy link
Copy Markdown

@biubiuzhang biubiuzhang commented Feb 12, 2026

Summary

This PR adds a native C shared library (libcbv2g_json_wrapper) that wraps libcbv2g with a JSON-based API for EXI encoding/decoding, designed to replace the Java-based EXIficient codec in Josev's EV simulation stack.

This is the first of 5 PRs to upstream the native EXI codec — it establishes the architecture with the smallest protocol (AppHandshake) for early review and feedback.

Developed by the Enteligent Team.

Problem

The current EV-side simulation (PyEvJosev) depends on a closed-source Java JAR (ExiCodec.jar) for EXI encoding/decoding, which:

What's included (PR 1 of 5)

  • `cbv2g_json_wrapper.h` — Public API, error codes, namespace constants
  • `cbv2g_json_wrapper.c` — Protocol dispatch, version/error functions
  • `json_utils.c/.h` — Shared JSON helpers (base64, hex, accessors)
  • `apphand_converter.c` — AppHandshake (SAP) protocol converter
  • `converters.h` — Internal converter declarations
  • `CMakeLists.txt` — Build system supporting both system-installed libcbv2g (Yocto) and source-tree builds
  • Bundled cJSON 1.7.19 (MIT) in `third_party/`

Upcoming PRs

PR Content ~Lines
1 (this) Core + AppHandshake ~750
2 DIN 70121 converter ~1,274
3 ISO 15118-2 converter ~1,476
4 ISO 15118-20 converter ~1,851
5 Python bindings + integration ~250

Build & Test

```bash

With system-installed libcbv2g (e.g., Yocto)

cmake -S iso15118/shared/cbv2g_wrapper -B build
cmake --build build

With libcbv2g source tree

cmake -S iso15118/shared/cbv2g_wrapper -B build -DLIBCBV2G_ROOT=/path/to/libcbv2g
cmake --build build
```

Test plan

  • Verify CMake configuration succeeds with system libcbv2g
  • Verify CMake configuration succeeds with source-tree libcbv2g
  • Verify library builds and links correctly
  • Verify AppHandshake encode/decode round-trip
  • Review API surface for suitability before adding more converters

🤖 Generated with Claude Code

@biubiuzhang
Copy link
Copy Markdown
Author

This PR is part of the approach described in the RFC: #58. Feedback on the architecture and API design is welcome before we submit the remaining protocol converters.

@biubiuzhang biubiuzhang force-pushed the feature/cbv2g-json-wrapper-core branch from df6e945 to 3506a01 Compare February 18, 2026 07:17
Nancy Zhang and others added 3 commits February 18, 2026 22:14
Add a native C shared library (libcbv2g_json_wrapper) that provides a
JSON-based API for EXI encoding/decoding via libcbv2g. This replaces
the Java-based EXIficient codec dependency for EV simulation, eliminating
the JRE requirement for embedded/Yocto deployments.

This initial PR establishes the architecture and includes:
- cbv2g_json_wrapper.h: Public API with error codes and namespace constants
- cbv2g_json_wrapper.c: Dispatch logic, version/error functions
- json_utils.c/.h: Shared JSON helper utilities (base64, hex, accessors)
- apphand_converter.c: AppHandshake (SAP) protocol converter
- converters.h: Internal converter declarations
- CMakeLists.txt: Build system supporting both system-installed libcbv2g
  (Yocto) and source-tree builds
- Bundled cJSON 1.7.19 (MIT license) in third_party/

The AppHandshake converter is included as the smallest protocol to
validate the approach. DIN 70121, ISO 15118-2, and ISO 15118-20
converters will follow in subsequent PRs.

Refs: EVerest/EVerest#118, EcoG-io#157, everest-demo#129

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Nancy Zhang <nancy.zhang@enteligent.com>
…rminated strings (CWE-126)

Replace strlen/strcmp with strnlen/strncmp across cbv2g_wrapper to
address Codacy static analysis findings. No behavioral change for
valid null-terminated input.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Nancy Zhang <nancy.zhang@enteligent.com>
…dacy findings (CWE-120, CWE-126)

Use snprintf with %s and %.*s for all string copies in apphand_converter
to eliminate Codacy warnings about unbounded copies, MS-banned functions,
and non-null-terminated string handling. No behavioral change.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Nancy Zhang <nancy.zhang@enteligent.com>
@biubiuzhang biubiuzhang force-pushed the feature/cbv2g-json-wrapper-core branch from 0ee4fcc to 85dd0d5 Compare February 18, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants