我是MQTT
and的新手Android Open Accessory "AOA"
。在阅读教程时,我意识到,在尝试写入该类型的变量之前ByteArrayOutputStream
, 0
或者0x00
应该先写入该变量。
这是某种初始化吗?下面是一个例子:
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());
}