RafaelKa / node-serialport-enocean-parser

ESP3 parser for nodes serialport
Do What The F*ck You Want To Public License
5 stars 2 forks source link

Packet factory #46

Closed Holger-Will closed 5 years ago

Holger-Will commented 5 years ago

implementation of a packet-factory

const Packet = require("./Packet.js")
Packet.from(...)

packet.from expects and ESP3Packet, a raw buffer, a string or a struct with at least { header:{ packetType:x } }

maybe we can add Packet.from(number) where number is a valid packetType

Holger-Will commented 5 years ago

TODO: when creating concrete types we should extract as much information as possible from the given data and fill the rest with meaningful defaults.

f.e. all RadioERP1 Packets have a destinationId we should not require that to be present when creating the packet. it can default to ffffffff likewise RSSI value should always be ff for the send case. it does not make much sense to require that in the struct passed to Packet.from()

Holger-Will commented 5 years ago

I'll heck this in and start work on the eep front. it might be easier then to see what is need here.