rfxcom / node-rfxcom

Node.js client for talking to an RFXtrx433 device
MIT License
61 stars 45 forks source link

re-transmit a receive code #85

Closed agodet closed 5 years ago

agodet commented 5 years ago

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.

maxwellhadley commented 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:

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!

agodet commented 5 years ago

Thank you very much, exactly what i want.