For a project exploring sending data from an Arduino with 433RF transmitter to Domoticz Homeautomation.
Created a B4R library rX10RF (wrapped and enhanced from X10RF lib) which enables to sent a Long (with max value FFFFFF, 3 Bytes) to a RFXMeter in Domoticz.
One of the tests is to sent the state 0 or 1 of various switches as Long. As the rX10RF library Long uses 3 Bytes, 3 switches can be defined, i.e. 010001 (switch 1=1, 2=0, 3=1).
Instead using Bytes, thinking of creating a Long value from the switch states.
Example: 5 switches, with state 0,1,1,0,1, converted to Long with leading 1 = 101101. The Long 101101 is then parsed by Domoticz (split into array with 1+5 entries).
Question: How to create the Long 101101 from the Byte array?
Start snippet but got stuck...
Created a B4R library rX10RF (wrapped and enhanced from X10RF lib) which enables to sent a Long (with max value FFFFFF, 3 Bytes) to a RFXMeter in Domoticz.
One of the tests is to sent the state 0 or 1 of various switches as Long. As the rX10RF library Long uses 3 Bytes, 3 switches can be defined, i.e. 010001 (switch 1=1, 2=0, 3=1).
Instead using Bytes, thinking of creating a Long value from the switch states.
Example: 5 switches, with state 0,1,1,0,1, converted to Long with leading 1 = 101101. The Long 101101 is then parsed by Domoticz (split into array with 1+5 entries).
Question: How to create the Long 101101 from the Byte array?
Start snippet but got stuck...
B4X:
'Byte Array for the 5 switches which have state 0 or 1
Private switches(5) As Byte
'Set random state for the switches. Use larger random range instead 0,1 to get higher probability for value changes.
For i = 0 To 4
switches(i) = IIf(Rnd(0,10) <= 5, 0, 1)
Next
' Loop over the Byte array to check the values
For Each b As Byte In switches
Log("b=", b, " (", bc.HexFromBytes(Array As Byte(b)), ")")
'b=1 (01) ...
Next
'Create Long i.e. 101101 from the Byte array
'???
Last edited: