I am developing an application in which i need to pass a array of 12 element. i am sending this array as a request using socket. I have lots of button on which i am performing this action.
The whole array remains same to send different action except the element no 10 and 11 gets changed for different buttons.
for example i am sending this values for Button 1 to ON
byte[] data1 = new byte[1024], packet1 =
{
(byte) 0x00,(byte) 0x00, (byte) 0x00,
(byte) 0x00,(byte) 0x00, (byte) 0x06,
(byte) 0x01,(byte) 0x05, (byte) 0x00,
(byte) 0x01,(byte) 0xff, (byte) 0x00
};
Here only element no 10(0x01)
will changed for Button 2 which will be (0x02)
and i am changing element no 11 for ON|OFF.
So i want to create such a method in which i can pass this two elements only. if i pass (0x01,0xff)
button 1 ON and (0x01,0x00)
button 1 off.
If you have any idea give me some guidance and advice to achieve my goal. currently i am passing all those elements for all buttons. but i want to do this dynamically.
Edit Button 1 OFF
byte[] data1 = new byte[1024], packet1 =
{
(byte) 0x00,(byte) 0x00, (byte) 0x00,
(byte) 0x00,(byte) 0x00, (byte) 0x06,
(byte) 0x01,(byte) 0x05, (byte) 0x00,
(byte) 0x01,(byte) 0x00, (byte) 0x00
};
Button 2 on
byte[] data1 = new byte[1024], packet1 =
{
(byte) 0x00,(byte) 0x00, (byte) 0x00,
(byte) 0x00,(byte) 0x00, (byte) 0x06,
(byte) 0x01,(byte) 0x05, (byte) 0x00,
(byte) 0x02,(byte) 0xff, (byte) 0x00
};
Button 2 off
byte[] data1 = new byte[1024], packet1 =
{
(byte) 0x00,(byte) 0x00, (byte) 0x00,
(byte) 0x00,(byte) 0x00, (byte) 0x06,
(byte) 0x01,(byte) 0x05, (byte) 0x00,
(byte) 0x02,(byte) 0x00, (byte) 0x00
};
Button 3 ON
byte[] data1 = new byte[1024], packet1 =
{
(byte) 0x00,(byte) 0x00, (byte) 0x00,
(byte) 0x00,(byte) 0x00, (byte) 0x06,
(byte) 0x01,(byte) 0x05, (byte) 0x00,
(byte) 0x03,(byte) 0xff, (byte) 0x00
};
button 3 Off
byte[] data1 = new byte[1024], packet1 =
{
(byte) 0x00,(byte) 0x00, (byte) 0x00,
(byte) 0x00,(byte) 0x00, (byte) 0x06,
(byte) 0x01,(byte) 0x05, (byte) 0x00,
(byte) 0x03,(byte) 0x00, (byte) 0x00
};
Thanks & Regards