提交图
20 次代码提交
作者 SHA1 备注 提交日期
Guoguo ec5b8584ec refactor: remove 17-byte FFE4 and 33-byte FFE1 legacy compat code
- Remove parseVendorStatus 17-byte branch (FFE4 is now 19 bytes)
- Remove parseVendorStatus 33-byte branch (FFE1 is now 34 bytes)
- Remove buildVendorCommand33 deprecated alias
- Remove fitting/run_state !== -1 guards in connection.js
- Update commands.js to use buildVendorCommand directly
2026-06-24 05:13:36 -07:00
Guoguo c6d958d2ea debug: log FFE4 frame length and type on receive 2026-06-24 02:31:23 -07:00
Guoguo 69621fd2b6 feat: support FFE4 19-byte format with fitting and run_state fields
Per 协议简述(3): FFE4 now 19 bytes — adds Byte17 fitting status
(0=not fitted, 1=fitted) and Byte18 run state (0=IDLE, 1=scanning,
2=treating, FF=fault). Maintains backward compat with 17-byte format.
2026-06-12 08:52:44 -07:00
Guoguo 5bce7060ac fix: BLE scan match use indexOf instead of exact equals
Fixes timeout during binding when targetDeviceId is set but exact
string match fails due to encoding differences. Also skips devices
with no name, and logs match result for every candidate.
2026-06-05 22:38:07 -07:00
Guoguo e4d11d30a8 feat: add BLE scan/connect/service discovery console logs 2026-06-05 22:30:01 -07:00
Guoguo 810a3a19a5 feat: support JW_ device ID format in QR scan and BLE matching
- parseDeviceId accepts hex with spaces (e.g. "672B6D5A 4DCD861")
- BLE scan does exact match on "JW_<device_id>" when target is known
- Manual input placeholder updated to show new format
2026-06-05 19:21:43 -07:00
Guoguo ba3c621294 feat: add JW_ prefix to BLE device scan filter 2026-06-05 03:59:05 -07:00
Guoguo 22110e866a feat: add Simple Peripheral back to BLE scan for dev board testing 2026-05-20 07:41:49 -07:00
Guoguo f0fdb285b5 chore: remove all mock/debug code for production release
Miniprogram:
- ENV switched to 'prod' (disables __DEV__ flag)
- Deleted mock.js and test-ble-frame.js
- Removed mockBind/mockPurchase from api.js
- Removed all debug UI panels and onMock* handlers from 6 pages
- Removed mock purchase fallback in subscribe-plans
- Removed SIMPLE PERIPHERAL dev board from BLE scan

Server:
- Removed /device/mock-bind route
- Removed /subscription/mock-purchase route
- Removed dev_openid fallback in wechat.js
- Removed mockBind() from binding.dao.js
- Removed mock fallback in purchase endpoint
- NODE_ENV default changed to 'production'

Admin:
- ENV switched to 'prod'

All mock code preserved in 'test' branch for future development use.
2026-05-20 07:19:26 -07:00
Guoguo 778167e47d Merge branch 'feat/production-ready' 2026-05-20 06:59:35 -07:00
Guoguo f1a2523cb4 fix: ADC notifications no longer emit 'status' (prevents timer jump)
- ADC (17-byte) now emits 'adc' + 'battery' events, not 'status'
- Fixes CRITICAL timer jump: remaining_ms:0 was resetting countdown
- Drop ADC packets with bad XOR checksum
- treating.js + index.js subscribe to 'battery' for live battery updates
- onStatus only updates remaining_ms when > 0
2026-05-19 03:57:47 -07:00
Guoguo 3fd7578163 feat: support 17-byte ADC status from updated vendor protocol
Protocol update adds FFE4 Status format: 7×PD sensors (little-endian)
+ VBAT battery voltage (mV) + XOR checksum = 17 bytes.

- parseVendorStatus: handles 1-byte heartbeat, 17-byte ADC, 33-byte params
- handleValueChange: ADC type extracts PD array + battery % from VBAT
- Battery calculated as linear 3000mV(0%) to 4200mV(100%)
- PD data passed through status event for treatment pages
- Updated protocol doc with full byte table and old/new comparison
2026-05-19 03:54:15 -07:00
Guoguo 92416261ee feat: production readiness — feature gaps + config hardening
Miniprogram:
- Add BLE reconnect button on home page when disconnected
- Add loading states to index, profile, subscribe-plans pages
- Add profile editing (avatar + nickname) with COS upload
- Enable pull-to-refresh on history page
- Fix auto-scan self.options → self.data inconsistency
- Add console.error to silent catch blocks
- Gate 'Simple Peripheral' BLE scan behind __DEV__ flag
- Add production config comment to env.js

Admin console:
- Add empty state '暂无数据' to all 5 list views
- Replace plain text plan input with select dropdown
- Add type="date" to record date filters
- Add production config comment

Server:
- CORS origin restricted in production (env CORS_ORIGIN)
- DB pool size configurable via DB_POOL_SIZE env var
- .env.example updated with WeChat Pay + production fields
2026-05-15 09:07:41 -07:00
Guoguo 8e306819ff fix: heartbeat no longer emits 'status' with remaining_ms=0
Heartbeat (1-byte FFE4 notify) now emits 'heartbeat' event only.
Only 33-byte state responses emit 'status' with parsed IO data.
Fixes timer jumping to 0 every second during treatment.
2026-05-12 06:22:28 -07:00
Guoguo 7d7cb9d081 feat: add 'Simple Peripheral' to BLE scan name filter for dev board 2026-05-12 06:19:12 -07:00
Guoguo 20d37982ca fix: vendor_33 BLE emits compatible 'status' event for existing pages
- handleValueChange now calls parseVendorStatus and emits 'status'
  with legacy-compatible shape (mode_state, battery, remaining_ms, etc.)
- 1-byte heartbeat mapped to mode_state, 33-byte state parsed for
  active IO detection
- Fixes regression where treating, index, wear-check, auto-scan pages
  never received status updates in vendor_33 mode
- Also emits 'vendor_raw' with full parsed data for future use
2026-05-12 06:03:28 -07:00
Guoguo cd088dbddc fix: BLE protocol handling matches actual device behavior
- discoverChars uses properties (write/notify) to distinguish FFE1
  command characteristic from FFE1 service UUID
- handleValueChange: vendor_33 mode emits vendor_status (FFE4 heartbeat)
  and vendor_data separately, no longer tries parseFrame on raw bytes
- parseVendorStatus handles 1-byte heartbeat and 33-byte state readback
  with proper IO1-IO5 field parsing
2026-05-12 05:59:16 -07:00
Guoguo 583fcb7e3d feat: add user deactivation and vendor BLE protocol 2026-05-11 21:14:41 +08:00
Guoguo 2eb38195f1 fix: address critical security and data integrity issues from cross-audit
- Add expire_time > NOW() filter to findActive() preventing stale subscriptions
- Add express-rate-limit on login endpoints (user: 10/15min, admin: 5/15min)
- Add production guard for default admin credentials
- Fix BLE bindDevice userId encoding (uint32 instead of hexToBytes on numeric)
- Wrap adminCreate in transaction to prevent race condition
- Add settings cache invalidation after admin saves
- Read trial_days from settings instead of hardcoding 7
- Fix double JSON.stringify in commandDao.finish call
- Cancel stale pending bindings before creating new ones
- Reduce token refresh grace period from 3 days to 1 day
- Fix subscribe-success to fetch expiry from server (correct for renewals)
- Add keep-alive name property to DashboardView and SettingsView
- Fix BLE disconnect() to preserve listener registrations across reconnects
2026-05-05 02:33:25 -07:00
Guoguo bb4b80f867 refactor: restructure entire project for human maintainability
Server:
- Add Express framework, replace custom router/request parser
- Create DAO layer (12 files) centralizing all 73 SQL queries
- Rewrite 7 route files as thin Express controllers calling DAOs
- Add SCF-to-Express adapter (lib/serverless.js)
- Add auth middleware (middleware/auth.js)
- Remove dead code from lib/auth.js

Admin console:
- Extract DataTable component (table + pagination)
- Extract ConfirmModal component (modal + form styles)
- Create listMixin for paginated list pages
- Move form styles to common.css for slot compatibility
- Refactor device + subscription pages as examples

Miniprogram:
- Split 734-line BLE monolith into 4 focused modules
  (protocol, connection, commands, barrel index)
- Create API module (utils/api.js) with named functions
- Create page utilities (utils/page.js)
- Refactor index + profile pages to use API module
2026-04-29 05:58:20 -07:00