I am new to the MQTT
and Android Open Accessory "AOA"
. while reading a tutorial I realized that, before any attempt to write to the variable of the type ByteArrayOutputStream
,however, 0
or 0x00
should be written to that variable first.
Is this some kind of initialisation? Below is an example of that:
EX_1
variableHeader.write(0x00);
variableHeader.write(PROTOCOL_NAME.getBytes("UTF-8").length);
variableHeader.write(PROTOCOL_NAME.getBytes("UTF-8"));
EX_2
public static byte[] connect() throws UnsupportedEncodingException, IOException {
String identifier = "android";
ByteArrayOutputStream payload = new ByteArrayOutputStream();
payload.write(0);
payload.write(identifier.length());
}