asyncapi: 2.6.0
info:
  title: BinarySensorNode
  version: 1.1.0+hw.revB.fw.2.0.1
  description: Binary UART protocol for multi-channel environmental sensor node with
    CRC16-Modbus
  contact:
    name: IoT Engineering Team
servers:
  serial_link:
    url: serial://tty/115200
    protocol: serial
    description: Physical UART Transport (115200 bps, 8N1.0)
    bindings:
      serial:
        baudRate: 115200
        dataBits: 8
        parity: none
        stopBits: 1.0
        framingType: binary
        integrity: crc16_modbus
channels:
  omniuart/cmd/ping:
    publish:
      summary: 'Send command ping (ID: 0x01)'
      description: Echo / ping command to check device presence
      message:
        name: ping_Message
        title: ping Command
        payload:
          $ref: '#/components/schemas/ping_Request'
  omniuart/resp/ping:
    subscribe:
      summary: Receive response for ping
      description: Decoded async payload stream from device after command ping
      message:
        name: ping_Response_Message
        title: ping Response
        payload:
          $ref: '#/components/schemas/ping_Response'
  omniuart/cmd/get_readings:
    publish:
      summary: 'Send command get_readings (ID: 0x02)'
      description: Query latest sensor measurements
      message:
        name: get_readings_Message
        title: get_readings Command
        payload:
          $ref: '#/components/schemas/get_readings_Request'
  omniuart/resp/get_readings:
    subscribe:
      summary: Receive response for get_readings
      description: Decoded async payload stream from device after command get_readings
      message:
        name: get_readings_Response_Message
        title: get_readings Response
        payload:
          $ref: '#/components/schemas/get_readings_Response'
  omniuart/cmd/set_sampling_rate:
    publish:
      summary: 'Send command set_sampling_rate (ID: 0x03)'
      description: Configure sensor update frequency
      message:
        name: set_sampling_rate_Message
        title: set_sampling_rate Command
        payload:
          $ref: '#/components/schemas/set_sampling_rate_Request'
  omniuart/resp/set_sampling_rate:
    subscribe:
      summary: Receive response for set_sampling_rate
      description: Decoded async payload stream from device after command set_sampling_rate
      message:
        name: set_sampling_rate_Response_Message
        title: set_sampling_rate Response
        payload:
          $ref: '#/components/schemas/set_sampling_rate_Response'
  omniuart/telemetry/periodic_status:
    subscribe:
      summary: 'Unsolicited telemetry message periodic_status (ID: 0x30)'
      description: Spontaneous periodic heartbeat broadcast
      message:
        name: periodic_status_Telemetry_Message
        title: periodic_status Telemetry
        payload:
          $ref: '#/components/schemas/periodic_status_Telemetry'
components:
  messages: {}
  schemas:
    ping_Request:
      type: object
      properties:
        command_id:
          type: integer
          const: 1
          description: Opcode ID for ping
      description: Echo / ping command to check device presence
    ping_Response:
      type: object
      properties:
        uptime_seconds:
          type: integer
          unit: s
      description: Decoded response frame payload for ping
    get_readings_Request:
      type: object
      properties:
        command_id:
          type: integer
          const: 2
          description: Opcode ID for get_readings
        channel:
          type: integer
          minimum: 0.0
          maximum: 3.0
          default: 0
      description: Query latest sensor measurements
    get_readings_Response:
      type: object
      properties:
        channel:
          type: integer
        temperature:
          type: number
          unit: "\xB0C"
        humidity:
          type: number
          unit: '%'
        pressure_hpa:
          type: number
          unit: hPa
      description: Decoded response frame payload for get_readings
    set_sampling_rate_Request:
      type: object
      properties:
        command_id:
          type: integer
          const: 3
          description: Opcode ID for set_sampling_rate
        rate_hz:
          type: string
          enum:
          - 1
          - 5
          - 10
          - 50
          default: 1
      description: Configure sensor update frequency
    set_sampling_rate_Response:
      type: object
      properties:
        status:
          type: integer
      description: Decoded response frame payload for set_sampling_rate
    periodic_status_Telemetry:
      type: object
      properties:
        battery_millivolts:
          type: integer
          unit: mV
        error_flags:
          type: integer
      description: Spontaneous periodic heartbeat broadcast
