Commit Graph
54 Commits
Author SHA1 Message Date
jpirnay a67799b04c Extend error messages 2026-04-07 10:56:56 +02:00
jpirnay b9cf57f7f4 Koreader Sync: Fix XPath index comparison 2026-04-04 15:54:55 +02:00
jpirnay 19aa643079 yaclf 2026-04-01 13:57:06 +02:00
jpirnay fea600dd7e Fix parent-element “exact” preemption 2026-04-01 13:32:55 +02:00
jpirnay e1fd631ced Review implied changes 2026-04-01 11:14:53 +02:00
jpirnay 55fbe1817e Merge branch 'feat-koysnc-xpath' of https://github.com/jpirnay/crosspoint-reader into mybuild 2026-04-01 10:46:04 +02:00
jpirnay ed02f20c36 yaclf 2026-04-01 10:41:56 +02:00
jpirnay fb4d0c6572 Refactor and extend docs 2026-04-01 10:38:02 +02:00
jpirnay 560a108921 KOReaderSync: add text-node offset mapping and trim debug noise 2026-04-01 10:15:05 +02:00
jpirnay 9cbe3bfc4d KOReaderSync: add text-node offset mapping and trim debug noise 2026-04-01 10:10:31 +02:00
jpirnay c4186abb61 Merge branch 'feat-koysnc-xpath' of https://github.com/jpirnay/crosspoint-reader into mybuild 2026-03-31 12:58:22 +02:00
jpirnay 12ad974dc7 Address /text()[N].M cases 2026-03-31 12:58:00 +02:00
jpirnay d7c4471864 yaclf 2026-03-30 10:07:10 +02:00
jpirnay 08f05b7a5b Fix br.0 indexing issue 2026-03-28 11:04:01 +01:00
jpirnay 420110b733 Fix index issue 2026-03-28 11:01:22 +01:00
jpirnay 5745e598e3 fix: migrate KOSync registerUser to esp_http_client 2026-03-25 20:22:01 +01:00
trilwu 08739746f8 style: fix clang-format alignment and log allocation failure
Address CI clang-format check and CodeRabbit review feedback:
- Fix parameter alignment (one extra space)
- Log warning when response buffer allocation fails

(cherry picked from commit 3900ea1feb017c07bd5e38da0b471fe623ec506e)
2026-03-25 20:19:46 +01:00
trilwu 10ea651e26 fix: use esp_http_client for KOSync to prevent TLS OOM on ESP32-C3
The Arduino WiFiClientSecure allocates 16KB TLS buffers by default,
which exhausts the ESP32-C3's limited heap (~46KB free after WiFi)
during the TLS handshake. This causes KOReader sync to fail silently
or crash on HTTPS servers (including the default sync.koreader.rocks).

Replace WiFiClientSecure/HTTPClient with esp_http_client (ESP-IDF),
which supports configurable buffer sizes. Use 2KB TLS buffers — more
than sufficient for KOSync's tiny JSON payloads (<1KB).

Also:
- Use esp_crt_bundle for proper TLS certificate verification instead
  of setInsecure()
- Strip trailing slashes from server URL to prevent double-slash in
  API paths
- Add lastHttpCode for diagnostics
- Add heap logging to help debug memory issues

Fixes #581

(cherry picked from commit 835abc19ff14fcbea8571ccb0dfd8d21e882b84c)
2026-03-25 20:19:46 +01:00
jpirnay e0ee59cbdf Merge branch 'feat-kosync-onlongpress' of https://github.com/jpirnay/crosspoint-reader into mybuild 2026-03-23 12:42:23 +01:00
jpirnay 75350b0a3e Incorporate koreader registration 2026-03-23 12:35:01 +01:00
jpirnayandClaude Opus 4.6 fd70b3a231 Add paragraph index LUT for accurate KOReader position sync
Store per-page paragraph indices in section cache to enable precise
XPath-to-page and page-to-XPath mapping without reparsing XHTML.

Forward path (upload): generates XPath directly from paragraph LUT
instead of byte-offset estimation, eliminating drift in chapters
with non-uniform content density.

Reverse path (download): resolves incoming KOReader XPath p[N] to
the exact page via paragraph LUT lookup.

Paragraph counter counts all <p> elements including display:none
to match ChapterXPathIndexer and crengine's standard XPath counting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 12:29:30 +01:00
jpirnayandClaude Opus 4.6 b625b8bd26 Add paragraph index LUT for accurate KOReader position sync
Store per-page paragraph indices in section cache to enable precise
XPath-to-page and page-to-XPath mapping without reparsing XHTML.

Forward path (upload): generates XPath directly from paragraph LUT
instead of byte-offset estimation, eliminating drift in chapters
with non-uniform content density.

Reverse path (download): resolves incoming KOReader XPath p[N] to
the exact page via paragraph LUT lookup.

Paragraph counter counts all <p> elements including display:none
to match ChapterXPathIndexer and crengine's standard XPath counting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 12:29:26 +01:00
jpirnay dccb82642d Merge branch 'feat-koysnc-xpath' of https://github.com/jpirnay/crosspoint-reader into mybuild 2026-03-21 20:10:23 +01:00
jpirnay 5b710e960f Fix OOM 2026-03-21 20:04:03 +01:00
jpirnay b08b576ddf Merge branch 'feat-koysnc-xpath' of https://github.com/jpirnay/crosspoint-reader into mybuild 2026-03-21 09:04:41 +01:00
jpirnay beeea38721 Remove cache - caused OOM in certain scenarios 2026-03-21 09:04:03 +01:00
jpirnay b7cb9517ea Fix xpath case issue 2026-03-20 11:13:36 +01:00
jpirnay 14d1c14137 Fix xpath case issue 2026-03-20 11:12:19 +01:00
jpirnay b545912734 Merge branch 'feat-koysnc-xpath' of https://github.com/jpirnay/crosspoint-reader into mybuild 2026-03-20 09:44:21 +01:00
jpirnay 5dec3d7f95 Reuse spine 2026-03-20 09:43:26 +01:00
jpirnay 913c24407b case fix 2026-03-19 16:43:34 +01:00
jpirnay 6e53ab3551 Merge branch 'feat-koysnc-xpath' of https://github.com/jpirnay/crosspoint-reader into mybuild 2026-03-19 16:29:05 +01:00
jpirnay 6deca2b78f Use temp file approach 2026-03-19 16:28:29 +01:00
jpirnay ec2458de41 Merge branch 'feat-koysnc-xpath' of https://github.com/jpirnay/crosspoint-reader into mybuild 2026-03-19 13:43:57 +01:00
jpirnay 3aa5c1b0de Reduce memory usage for parseSpineItem 2026-03-19 13:43:21 +01:00
jpirnay ed0302571e Merge branch 'feat-koysnc-xpath' of https://github.com/jpirnay/crosspoint-reader into mybuild 2026-03-08 09:58:54 +01:00
jpirnay f859169dde Function combination 2026-02-28 05:46:46 +01:00
jpirnay 8c08c19ca6 Review comments 2026-02-28 05:31:12 +01:00
jpirnay 5764e22b82 Review comments 2026-02-27 11:53:19 +01:00
jpirnay 5e62dd79cd Fix comparison 2026-02-27 11:09:42 +01:00
jpirnay 9a4c9baf85 Additional debug information 2026-02-27 10:20:32 +01:00
jpirnay 34586d0010 Fix faulty 0 based docfragment 2026-02-27 09:51:53 +01:00
jpirnay c335e027b4 Update docs 2026-02-25 22:44:08 +01:00
jpirnay 7e8bd70f3c First attempt for proper koreader xpath generation / resolution 2026-02-25 22:34:11 +01:00
jpirnay 39eb75f1c9 Nitpick comment 2026-02-25 21:29:39 +01:00
jpirnay 3ca525ef3a Add fingerprint 2026-02-25 21:06:51 +01:00
jpirnay b3aae93f41 Cache KOReader document hash 2026-02-25 20:14:21 +01:00
jpirnayandDave Allie cd748a01a9 feat: Migrate binary settings to json (#920)
## Summary

* This PR introduces a migration from binary file storage to JSON-based
storage for application settings, state, and various credential stores.
This improves readability, maintainability, and allows for easier manual
configuration editing.
* Benefits:
  - Settings files are now JSON and can be easily read/edited manually
  - Easier to inspect application state and settings during development
  - JSON structure is more flexible for future changes
* Drawback: around 15k of additional flash usage
* Compatibility: Seamless migration preserves existing user data

## Additional Context
1. New JSON I/O Infrastructure files:
- JsonSettingsIO: Core JSON serialization/deserialization logic using
ArduinoJson library
- ObfuscationUtils: XOR-based password obfuscation for sensitive data
2. Migrated Components (now use JSON storage with automatic binary
migration):
     - CrossPointSettings (settings.json): Main application settings
- CrossPointState (state.json): Application state (open book, sleep
mode, etc.)
- WifiCredentialStore (wifi.json): WiFi network credentials (Password
Obfuscation: Sensitive data like WiFi passwords, uses XOR encryption
with fixed keys. Note: This is obfuscation, not cryptographic security -
passwords can be recovered with the key)
- KOReaderCredentialStore (koreader.json): KOReader sync credentials
     - RecentBooksStore (recent.json): Recently opened books list
3. Migration Logic
     - Forward Compatibility: New installations use JSON format
- Backward Compatibility: Existing binary files are automatically
migrated to JSON on first load
- Backup Safety: Original binary files are renamed with .bak extension
after successful migration
- Fallback Handling: If JSON parsing fails, system falls back to binary
loading
4. Infrastructure Updates
     - HalStorage: Added rename() method for backup operations

---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _** YES**_

---------

Co-authored-by: Dave Allie <dave@daveallie.com>
2026-02-22 17:18:25 +11:00
jpirnay 6bcca5a127 fix: Fix kosync repositioning issue (#783)
## Summary

* Original implementation had inconsistent positioning logic:
- When XPath parsing succeeded: incorrectly set pageNumber = 0 (always
beginning of chapter)
- When XPath parsing failed: used percentage for positioning (worked
correctly)
- Result: Positions restored to wrong locations depending on XPath
parsing success
  - Mentioned in Issue #581 
* Solution
- Unified ProgressMapper::toCrossPoint() to use percentage-based
positioning exclusively for both spine identification and intra-chapter
page calculation, eliminating unreliable XPath parsing entirely.

## Additional Context

* ProgressMapper.cpp: Simplified toCrossPoint() to always use percentage
for positioning, removed parseDocFragmentIndex() function
* ProgressMapper.h: Updated comments and removed unused function
declaration
* Tests confirmed appropriate positioning
* __Notabene: the syncing to another device will (most probably) end up
at the current chapter of crosspoints reading position. There is not
much we can do about it, as KOReader needs to have the correct XPath
information - we can only provide an apporximate position (plus
percentage) - the percentage information is not used in KOReaders
current implementation__
---

### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? YES
2026-02-19 21:38:46 +11:00
jpirnayandXuan Son Nguyen 5029f5fda5 feat: Add central logging pragma (#843)
## Summary

* Definition and use of a central LOG function, that can later be
extended or completely be removed (for public use where debugging
information may not be required) to save flash by suppressing the
-DENABLE_SERIAL_LOG like in the slim branch

* **What changes are included?**

## Additional Context
* By using the central logger the usual:
```
#include <HardwareSerial.h>
...
  Serial.printf("[%lu] [WCS] Obfuscating/deobfuscating %zu bytes\n", millis(), data.size());
```
would then become
```
#include <Logging.h>
...
  LOG_DBG("WCS", "Obfuscating/deobfuscating %zu bytes", data.size());
```
You do have ``LOG_DBG`` for debug messages, ``LOG_ERR`` for error
messages and ``LOG_INF`` for informational messages. Depending on the
verbosity level defined (see below) soe of these message types will be
suppressed/not-compiled.

* The normal compilation (default) will create a firmware.elf file of
42.194.356 bytes, the same code via slim will create 42.024.048 bytes -
170.308 bytes less
* Firmware.bin : 6.469.984 bytes for default, 6.418.672 bytes for slim -
51.312 bytes less


### AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing,
please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? _NO_

---------

Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
2026-02-13 12:16:39 +01:00