// 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,
  CONTROL: protocol.CONTROL,
  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
  PROTOCOL_MODE: protocol.PROTOCOL_MODE,
  buildFrame: protocol.buildFrame,
  parseFrame: protocol.parseFrame,
  buildVendorCommand: protocol.buildVendorCommand,
  buildVendorCommand33: protocol.buildVendorCommand33,
  parseVendorStatus: protocol.parseVendorStatus,
  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
}
