{"version":3,"sources":["../src/profiles/serial-ffe0.ts"],"names":["FFE0_SERVICE","FFE1_CHAR","HM10SerialProfile","BaseProfile","callback","data"],"mappings":"qCAGA,IAAMA,CAAAA,CAAe,sCAAA,CAEfC,CAAAA,CAAY,sCAAA,CAkCLC,EAAN,cAAgCC,CAAY,CAA5C,WAAA,EAAA,CAAA,KAAA,CAAA,GAAA,SAAA,CAAA,CACL,IAAA,CAAmB,OAAA,CAAUH,EAAAA,CAS7B,SAAA,CAAUI,EAAiD,CACzD,OAAO,IAAA,CAAK,SAAA,CAAUH,CAAAA,CAAWG,CAAQ,CAC3C,CAUA,MAAM,IAAA,CAAKC,CAAAA,CAAmC,CAI5C,MAAM,IAAA,CAAK,WAAA,CAAYJ,CAAAA,CAAWI,CAAI,EACxC,CACF","file":"chunk-2PX7ZYHS.mjs","sourcesContent":["import { BaseProfile } from './base';\n\n/** HM-10 / CC2541 \"transparent serial\" service UUID. */\nconst FFE0_SERVICE = '0000ffe0-0000-1000-8000-00805f9b34fb';\n/** Single bidirectional characteristic: write AND notify share this handle. */\nconst FFE1_CHAR = '0000ffe1-0000-1000-8000-00805f9b34fb';\n\n/**\n * HM-10 (and compatible CC2540/CC2541 modules: HM-11, AT-09, JDY-08, …)\n * transparent-serial profile.\n *\n * Unlike Nordic UART's two-characteristic design, the HM-10 multiplexes both\n * directions onto a *single* characteristic `0000ffe1-…` on service\n * `0000ffe0-…`: the host writes to it (write-without-response) and the device\n * pushes inbound bytes back via notifications on the very same handle.\n *\n * Strictly W3C `navigator.bluetooth` GATT: notifications are enabled through\n * {@link BaseProfile.subscribe} (`startNotifications()`); this profile never\n * reads or writes a CCCD/SCCD descriptor itself.\n *\n * @example\n * ```ts\n * import { HM10SerialProfile } from '@beacio/core/profiles';\n *\n * // requestDevice({ filters: [{ services: ['0000ffe0-0000-1000-8000-00805f9b34fb'] }] })\n * const serial = new HM10SerialProfile(device);\n * await serial.connect();\n *\n * const decoder = new TextDecoder();\n * const unsubscribe = serial.onReceive((chunk) => {\n *   console.log(decoder.decode(chunk));\n * });\n *\n * await serial.send(new TextEncoder().encode('AT+NAME?\\r\\n'));\n *\n * unsubscribe();\n * serial.stop();\n * ```\n */\nexport class HM10SerialProfile extends BaseProfile {\n  protected readonly service = FFE0_SERVICE;\n\n  /**\n   * Subscribe to inbound data from the module (FFE1 notify).\n   * Each notification is delivered as a raw {@link DataView} chunk.\n   *\n   * @param callback - Invoked with every inbound chunk.\n   * @returns Unsubscribe function. Also cleaned up by {@link BaseProfile.stop}.\n   */\n  onReceive(callback: (chunk: DataView) => void): () => void {\n    return this.subscribe(FFE1_CHAR, callback);\n  }\n\n  /**\n   * Send data to the module (FFE1 write-without-response — the same handle\n   * used for inbound notifications). Payloads larger than the negotiated\n   * write-without-response limit are split into MTU-sized chunks and written\n   * sequentially.\n   *\n   * @param data - Bytes to send. Accepts any {@link BufferSource}.\n   */\n  async send(data: BufferSource): Promise<void> {\n    // Delegate fragmentation to the core write-chunker (via BaseProfile.sendChunked),\n    // which derives a branded, always-positive ChunkSize from the negotiated\n    // write-without-response limit / MTU. No hand-rolled offset loop here.\n    await this.sendChunked(FFE1_CHAR, data);\n  }\n}\n"]}