Options
All
  • Public
  • Public/Protected
  • All
Menu

This class implements the core functionality of an EnOcean gateway. Currently it has only been tested with an EnOcean TCM310 module.

Initialization

The constructor of this class is private. To obtain an instance, the only currently available option is to use the static function connectToSerialPort.

Automatic interpretation of incoming data

This class automatically interprets all incoming data as far as possible. The receiving chain is outlined below.

Trigger: Data is received on the serial port.

  1. Try to interpret the received data as ESP3 packet:

    • on failure: do nothing and stop,
    • on success: call all listeners registered by onReceivedESP3Packet and proceed to step 2.
  2. Try to interpret the ESP3 packet:

    • on failure: call all listeners registered by onReceivedESP3PacketUnfamiliar and stop,
    • on successful interpretation of a response telegram: process response internally and stop,
    • on successful interpretation as ERP1 telegram: call all listeners registered by onReceivedERP1Telegram and proceed to step 3.
  3. Try to interpret the ERP1 telegram:

    • on failure: call all listeners registered by onReceivedERP1TelegramUnfamiliar and stop,
    • on successful interpretation of a teach in message (UTE / 4BS): handle teach in internally (if learn mode is enabled) or discard message (if learn mode is disabled) and stop,
    • on recognition of a data telegram (RPS/1BS/4BS/VLD), proceed to step 4
  4. Identify the sender (check if the device is known):

    • on failure: call all listeners registered by onReceivedERP1TelegramUnfamiliar with reason {@link ERP1TelegramParsingErrors.DeviceUnknown} and stop,
    • on success, proceed to step 5.
  5. Get the EEP:

    • on failure: call all listeners registered by onReceivedERP1TelegramUnfamiliar with reason {@link ERP1TelegramParsingErrors.EEPUnknown} and stop,
    • on success, proceed to step 6.
  6. Get a parser for the EEP:

    • on failure: call all listeners registered by onReceivedERP1TelegramUnfamiliar with reason {@link ERP1TelegramParsingErrors.EEPUnsupported} and stop,
    • on success, proceed to step 7.
  7. Parse the data:

As you can see above, for all types of involved data structures (ESP3Packet, ERP1Telegram, EEPMessage) the gateway always notifies the sucessful parsing. For the first two, it is possible that further processing fails in which case the respective unfamiliar event will be triggered. This way, you can implement your own functionality either for all data or only for data, which cannot be interpreted (yet) by built-in functionality.

Hierarchy

  • Gateway

Index

Accessors

isLearning

  • get isLearning(): boolean
  • Get the status of the gateway's learn mode.

    Returns boolean

Methods

getBaseId

  • Get the gateways's base ID. This ID can be changed a limited number of times.

    Returns Promise<DeviceId>

getBaseIdResetCounter

  • getBaseIdResetCounter(): Promise<number>
  • Get the number of available resets for the base ID. The base ID of a TCM310 transceiver can be reset up to 10 times.

    Returns Promise<number>

getChipId

  • Get the gateway's chip ID. This ID is the unique EnOcean ID of the connected transceiver and cannot be changed.

    Returns Promise<DeviceId>

getDeviceInfo

  • Get the (teach-in) meta data associated to the supplied device.

    Parameters

    • device: DeviceId

      The device to be queried.

    Returns DeviceInfo

getEEPParser

  • Get the EEPParser for the supplied EEP.

    Parameters

    • eep: EEPId

      The eep for which the parser is requested.

    Returns EEPParser

    Returns the EEPParser registered for the supplied EEP or undefined if no parser is found.

getSupportedEEPs

  • getSupportedEEPs(): EEPId[]
  • Get a list of EEPs for which a parser is registered.

    Returns EEPId[]

hasEEPParser

  • hasEEPParser(eep: EEPId): boolean
  • Checks if there is a parser for the given EEP.

    Parameters

    Returns boolean

isValidSender

  • isValidSender(sender: DeviceId): Promise<boolean>
  • Check if the supplied device id can be used for sending with this gateway. This is the case if (and only if) the supplied id is

    • the gateway's chip id,
    • the gateway's base id or one of the 127 subsequent ids.

    Parameters

    • sender: DeviceId

      The device id to be checked.

    Returns Promise<boolean>

onDeviceTeachIn

  • Register a listener to be called when a device was successfully taught in.

    Parameters

    Returns void

onReceivedEEPMessage

  • Register a listener to be called when an EEP message is received.

    Parameters

    • listener: EEPMessageListener

      This function will be called whenever an EEP message is received.

    Returns void

onReceivedERP1Telegram

  • Register a listener to be called when an ERP1 telegram is received. The listener will be called before any further internal processing of the ERP1 telegram.

    Parameters

    • listener: ERP1TelegramListener

      This function will be called whenever an ERP1 telegram is received.

    Returns void

onReceivedERP1TelegramUnfamiliar

  • Register a listener to be called when a received ERP1 telegram was classified as unfamiliar. This is the case if and only if the further internal processing of the telegram was unsuccessful.

    Parameters

    Returns void

onReceivedESP3Packet

  • Register a listener to be called when an ESP3 packet is received. The listener will be called before any further internal processing of the ESP3 packet.

    Parameters

    • listener: ESP3PacketListener

      This function will be called whenever an ESP3 packet is received.

    Returns void

onReceivedESP3PacketUnfamiliar

  • Register a listener to be called when a received ESP3 packet was classified as unfamiliar. This is the case if and only if the further internal processing of the packet was unsuccessful.

    Parameters

    Returns void

onStopLearning

  • onStopLearning(listener: (stoppedManually: boolean) => void): void
  • Register a listener to be called when learning mode ended.

    Parameters

    • listener: (stoppedManually: boolean) => void

      This function will be called whenever the learning mode ended.

        • (stoppedManually: boolean): void
        • Parameters

          • stoppedManually: boolean

          Returns void

    Returns void

sendERP1Telegram

  • Send a telegram via radio.

    Parameters

    • telegram: ERP1Telegram

      The telegram to be sent. If this telegram contains an invalid sender address, the telegram will be sent using:

      • the address found in the knownDevices for the destination, or
      • the chip id.

    Returns Promise<SendingResults>

sendESP3Packet

  • Send the supplied ESP3 packet. Note: this low level method does not perform any checks/replacements on the sender id for ERP1 telegrams.

    Parameters

    Returns Promise<SendingResults>

setEEPParser

  • Registers a parser for the given EEP. This parser is used to interpret received telegrams for devices with this EEP.

    Parameters

    Returns void

startLearning

  • startLearning(timeout?: number, sender?: DeviceId): Promise<void>
  • Set the gateway into learning mode.

    • Universal Teach-In (UTE): The gateway will respond to Universal Teach-In (UTE) queries and add the respective device to the list of known devices.
    • 4BS teach in: The gateway will interpret 4BS telegrams, whose learn bit is set, and add the device and its EEP to the list of known devices.
    • RPS: Upon receipt of RPS (data) telegrams from yet unknown devices also these will be added to the list of known devices. As RPS communication has no teach-in telegram, the correct EEP has to be added manually afterwards.

    Parameters

    • timeout: number = 60

      The timeout (in seconds) after which the learning mode will be disabled automatically.

    • sender: DeviceId = ...

      The sender ID to be used for the learning process. Can be either the sender's chip id or one of the 128 consecutive adresses starting at the sender's base id. Defaults to the sender's chip id.

    Returns Promise<void>

stopLearning

  • stopLearning(): void
  • Manually stop the learning mode.

    Returns void

teachDevice

  • Manual teach in of a device. Use with care: might overwrite existing info.

    Parameters

    • device: DeviceId

      The device id of the device to be taught in.

    • eep: EEPId

      The device's EEP.

    • manufacturer: Manufacturers = ...

      The device's manufacturer.

    • localId: DeviceId = ...

      The local id which shall be used when sending to the device. Defaults to the gateway's chip id.

    Returns Promise<void>

Static connectToSerialPort

  • Return a new instance using the supplied serial port.

    Parameters

    • portString: string

      A string identifying the serial port to which the TCM310 module is connected; this might e.g. be "/dev/ttyAMA0" (for the EnOceanPi module on a Raspberry Pi) or "COM3" (for a USB300 module in Windows).

    • deviceInfoMap: DeviceInfoMap = ...

      A DeviceInfoMap implementation to be used for storing and retreiving information about the EnOcean devices with which this gateway can communicate. Default is a JSONFileDeviceInfoMap using the default file '.known_enocean_devices'.

    Returns Gateway

Static getAvailableSerialPorts

  • getAvailableSerialPorts(): Promise<string[]>
  • Get a list of all available serial ports. Note that this function returns all ports - it does not check whether a suitable transceiver module is connected to the port!

    Returns Promise<string[]>

Generated using TypeDoc