Closed agodet closed 5 years ago
As I understand it, you want to make a basic 'dumb' repeater: it should just retransmit each message it receives, unmodified, without trying to interpret it.
You must handle the "data"
event from your rfxcom
object to listen to all received radio messages. This returns an array of bytes data[]
representing the received packet from the RFXtrx433:
data[0]
is the message length, not including the length byte itself, i.e. it should be data.length - 1
. If the length is wrong, an error has occurred, and you should probably ignore the packet.data[1]
is the packetNumber
of the message. The packets you are interested in (that may be valid for retransmission) will have 0x10 <= data[1] < 0x7f
. Ignore any packets with packetNumber
outside this range. Different message formats have a different packetNumber
, and generally have different lengths.data[2]
is the subtype
of the packet - the index number, generally starting at 0, of the actual model of device that uses the message format.data[3]
is the messageSequenceNumber
of the message. This increments with each message received from the RFXtrx433 and resets to 0 after 255 messages.data.slice(4)
(i.e. bytes 4 to the end) is the actual content of the data message.To retransmit messages, create a Transmitter
object, passing 0
as the subtype
parameter. Then to retransmit a received message, call transmitter.sendRaw(packetNumber, subtype, data.slice[4])
where packetNumber = data[1]
and subtype = data[2]
as described. The method calculates the length, adds the message sequence number & handles the handshake with the RFXtrx433 - you shouldn't have to do anything else.
Be aware that not all message types that can be received can also be transmitted (and this varies a bit with the exact model of RFXtrx433) and in those cases you will get an error message, as a data packet with packetNumber = 0x01
and subtype = 0xff
. A successful transmission gives an acknowledgement message with packetNumber = 0x02
and subtype = 0x00
or subtype = 0x01
.
I hope this helps!
Thank you very much, exactly what i want.
Could you send me the code that listen a command from rfxcom and retransmit the same command, is it possible ? I try to use transmitter.sendRaw with no success because i don't know what to put in the first and second parameters.
Hope you understand what i need. Thank you.