文件
jw-beauty/miniprogram/services/ble/index.js
T
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

60 行
1.7 KiB
JavaScript

// BLE service barrel — re-exports a unified API
// Usage: var ble = require('../../services/ble')
var protocol = require('./protocol')
var connection = require('./connection')
var commands = require('./commands')
module.exports = {
// Constants
SERVICE: protocol.SERVICE,
CHAR: protocol.CHAR,
CMD: protocol.CMD,
NOTIFY: protocol.NOTIFY,
MODE_STATE: protocol.MODE_STATE,
WAVELENGTH: protocol.WAVELENGTH,
TREAT_MODE: protocol.TREAT_MODE,
REGION: protocol.REGION,
DEVICE_ERR: protocol.DEVICE_ERR,
// Connection
isConnected: connection.isConnected,
getDeviceId: connection.getDeviceId,
startScan: connection.startScan,
stopScan: connection.stopScan,
connect: connection.connect,
disconnect: connection.disconnect,
setAutoReconnect: connection.setAutoReconnect,
on: connection.on,
off: connection.off,
// Commands
readDeviceInfo: commands.readDeviceInfo,
setParams: commands.setParams,
startTreatment: commands.startTreatment,
stopTreatment: commands.stopTreatment,
queryStatus: commands.queryStatus,
bindDevice: commands.bindDevice,
unbindDevice: commands.unbindDevice,
// Protocol utilities
buildFrame: protocol.buildFrame,
parseFrame: protocol.parseFrame,
parseStatusReport: protocol.parseStatusReport,
parseAck: protocol.parseAck,
parseTreatmentComplete: protocol.parseTreatmentComplete,
parseException: protocol.parseException,
// Display helpers
REGION_NAMES: protocol.REGION_NAMES,
getRegionName: protocol.getRegionName,
getWavelengthName: protocol.getWavelengthName,
getModeStateName: protocol.getModeStateName,
// Byte utilities
bufferToBytes: protocol.bufferToBytes,
bytesToBuffer: protocol.bytesToBuffer,
hexToBytes: protocol.hexToBytes,
bytesToHex: protocol.bytesToHex
}