ASH Protocol handler.

Hierarchy

  • EventEmitter<UartAshEventMap>
    • UartAsh

Constructors

Properties

counters: UartAshCounters
ncpHasCallbacks: boolean

Set when the ncp has indicated it has a pending callback by seting the callback flag in the frame control byte or (uart version only) by sending an an ASH_WAKE byte between frames.

ncpSleepEnabled: boolean

NCP is enabled to sleep, set by EZSP, not supported atm, always false

reTxQueue: EzspQueue
rxFree: EzspFreeList
rxQueue: EzspQueue
txFree: EzspFreeList
txQueue: EzspQueue

Accessors

  • get connected(): boolean
  • Indicates if the host is in the Connected state. If not, the host and NCP cannot exchange DATA frames. Note that this function does not actively confirm that communication with NCP is healthy, but simply returns its last known status.

    Returns boolean

    • true - host and NCP can exchange DATA frames
    • false - host and NCP cannot now exchange DATA frames

Methods

  • Get the frame type from the control byte and validate it against the frame length.

    Parameters

    • control: number
    • len: number

      Frame length

    Returns AshFrameType

    AshFrameType.INVALID if bad control/length otherwise the frame type.

  • Randomizes array contents by XORing with an 8-bit pseudo random sequence. This reduces the likelihood that byte-stuffing will greatly increase the size of the payload. (This could happen if a DATA frame contained repeated instances of the same reserved byte value.)

    Parameters

    • seed: number

      zero initializes the random sequence a non-zero value continues from a previous invocation

    • buf: Buffer

      IN/OUT pointer to the array whose contents will be randomized

    • len: number

      number of bytes in the array to modify

    Returns number

    last value of the sequence. If a buffer is processed in two or more chunks, as with linked buffers, this value should be passed back as the value of the seed argument

  • Same as randomizeArray(0, buffer, len). Returns buffer as-is if randomize is OFF.

    Parameters

    • buffer: Buffer

      IN/OUT

    • len: number

    Returns void

  • Initializes the ASH serial port and (if enabled) resets the NCP. The method used to do the reset is specified by the the host configuration parameter resetMethod.

    When the reset method is sending a RST frame, the caller should retry NCP resets a few times if it fails.

    Returns Promise<EzspStatus>

    • EzspStatus.SUCCESS
    • EzspStatus.HOST_FATAL_ERROR
  • Adds a DATA frame to the transmit queue to send to the NCP. Frames that are too long or too short will not be sent, and frames will not be added to the queue if the host is not in the Connected state, or the NCP is not ready to receive a DATA frame or if there is no room in the queue;

    Parameters

    • len: number

      length of data field

    • inBuf: Buffer

      array containing the data to be sent

    Returns EzspStatus

    • EzspStatus.SUCCESS
    • EzspStatus.NO_TX_SPACE
    • EzspStatus.DATA_FRAME_TOO_SHORT
    • EzspStatus.DATA_FRAME_TOO_LONG
    • EzspStatus.NOT_CONNECTED
  • Manages outgoing communication to the NCP, including DATA frames as well as the frames used for initialization and error detection and recovery.

    Returns void

  • Initializes the ASH protocol, and waits until the NCP finishes rebooting, or a non-recoverable error occurs.

    Returns Promise<EzspStatus>

    • EzspStatus.SUCCESS
    • EzspStatus.HOST_FATAL_ERROR
    • EzspStatus.ASH_NCP_FATAL_ERROR)
  • Stops the ASH protocol - flushes and closes the serial port, clears all queues, stops timers, etc.

    Returns Promise<void>