mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-27 07:41:39 +01:00
Adds additional checks for parser (#15165)
Signed-off-by: Ben Rosenblum <rosenblumb@gmail.com>
This commit is contained in:
parent
7587e0c504
commit
80eeba48ce
@ -96,84 +96,99 @@ public class ShieldTVMessageParser {
|
|||||||
callback.setHostName(encHostname);
|
callback.setHostName(encHostname);
|
||||||
} else if (msg.startsWith(MESSAGE_HOSTNAME)) {
|
} else if (msg.startsWith(MESSAGE_HOSTNAME)) {
|
||||||
// Longer hostname reply
|
// Longer hostname reply
|
||||||
// 080b 12 5b08b510 12 TOTALLEN? 0a LEN Hostname 12 LEN IPADDR Padding? 22 LEN DeviceID 2a LEN arm64-v8a
|
// 080b 12 5b08b510 12 TOTALLEN? 0a LEN Hostname 12 LEN IPADDR 18 9b46 22 LEN DeviceID 2a LEN arm64-v8a
|
||||||
// 2a LEN armeabi-v7a 2a LEN armeabi 180b
|
// 2a LEN armeabi-v7a 2a LEN armeabi 180b
|
||||||
// It's possible for there to be more or less of the arm lists
|
// It's possible for there to be more or less of the arm lists
|
||||||
logger.trace("{} - Longer Hostname Reply", thingId);
|
logger.trace("{} - Longer Hostname Reply", thingId);
|
||||||
|
|
||||||
int i = 20;
|
int i = 18;
|
||||||
int length;
|
int length;
|
||||||
int current;
|
int current;
|
||||||
|
|
||||||
// Hostname
|
|
||||||
String st = "" + charArray[i] + "" + charArray[i + 1];
|
|
||||||
length = Integer.parseInt(st, 16) * 2;
|
|
||||||
i += 2;
|
|
||||||
|
|
||||||
StringBuilder hostname = new StringBuilder();
|
StringBuilder hostname = new StringBuilder();
|
||||||
current = i;
|
|
||||||
|
|
||||||
for (; i < current + length; i = i + 2) {
|
|
||||||
st = "" + charArray[i] + "" + charArray[i + 1];
|
|
||||||
hostname.append(st);
|
|
||||||
}
|
|
||||||
|
|
||||||
i += 2; // 12
|
|
||||||
|
|
||||||
// ipAddress
|
|
||||||
st = "" + charArray[i] + "" + charArray[i + 1];
|
|
||||||
length = Integer.parseInt(st, 16) * 2;
|
|
||||||
i += 2;
|
|
||||||
|
|
||||||
StringBuilder ipAddress = new StringBuilder();
|
StringBuilder ipAddress = new StringBuilder();
|
||||||
current = i;
|
|
||||||
|
|
||||||
for (; i < current + length; i = i + 2) {
|
|
||||||
st = "" + charArray[i] + "" + charArray[i + 1];
|
|
||||||
ipAddress.append(st);
|
|
||||||
}
|
|
||||||
|
|
||||||
st = "" + charArray[i] + "" + charArray[i + 1];
|
|
||||||
while (!DELIMITER_22.equals(st)) {
|
|
||||||
i += 2;
|
|
||||||
st = "" + charArray[i] + "" + charArray[i + 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
i += 2; // 22
|
|
||||||
|
|
||||||
// deviceId
|
|
||||||
|
|
||||||
st = "" + charArray[i] + "" + charArray[i + 1];
|
|
||||||
length = Integer.parseInt(st, 16) * 2;
|
|
||||||
i += 2;
|
|
||||||
|
|
||||||
StringBuilder deviceId = new StringBuilder();
|
StringBuilder deviceId = new StringBuilder();
|
||||||
current = i;
|
StringBuilder arch = new StringBuilder();
|
||||||
|
|
||||||
for (; i < current + length; i = i + 2) {
|
String st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
|
|
||||||
|
if (DELIMITER_0A.equals(st)) {
|
||||||
|
i += 2; // 0a
|
||||||
|
// Hostname
|
||||||
st = "" + charArray[i] + "" + charArray[i + 1];
|
st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
deviceId.append(st);
|
length = Integer.parseInt(st, 16) * 2;
|
||||||
|
i += 2;
|
||||||
|
|
||||||
|
current = i;
|
||||||
|
|
||||||
|
for (; i < current + length; i = i + 2) {
|
||||||
|
st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
|
hostname.append(st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
|
|
||||||
|
if (DELIMITER_12.equals(st)) {
|
||||||
|
i += 2; // 12
|
||||||
|
|
||||||
|
// ipAddress
|
||||||
|
st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
|
length = Integer.parseInt(st, 16) * 2;
|
||||||
|
i += 2;
|
||||||
|
|
||||||
|
current = i;
|
||||||
|
|
||||||
|
for (; i < current + length; i = i + 2) {
|
||||||
|
st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
|
ipAddress.append(st);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
|
if (DELIMITER_18.equals(st)) {
|
||||||
|
while (!DELIMITER_22.equals(st)) {
|
||||||
|
i += 2;
|
||||||
|
st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
|
if (DELIMITER_22.equals(st)) {
|
||||||
|
i += 2; // 22
|
||||||
|
|
||||||
|
// deviceId
|
||||||
|
|
||||||
|
st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
|
length = Integer.parseInt(st, 16) * 2;
|
||||||
|
i += 2;
|
||||||
|
|
||||||
|
current = i;
|
||||||
|
|
||||||
|
for (; i < current + length; i = i + 2) {
|
||||||
|
st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
|
deviceId.append(st);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// architectures
|
// architectures
|
||||||
st = "" + charArray[i] + "" + charArray[i + 1];
|
st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
StringBuilder arch = new StringBuilder();
|
if (DELIMITER_2A.equals(st)) {
|
||||||
while (DELIMITER_2A.equals(st)) {
|
while (DELIMITER_2A.equals(st)) {
|
||||||
i += 2;
|
i += 2;
|
||||||
st = "" + charArray[i] + "" + charArray[i + 1];
|
|
||||||
length = Integer.parseInt(st, 16) * 2;
|
|
||||||
i += 2;
|
|
||||||
current = i;
|
|
||||||
for (; i < current + length; i = i + 2) {
|
|
||||||
st = "" + charArray[i] + "" + charArray[i + 1];
|
st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
arch.append(st);
|
length = Integer.parseInt(st, 16) * 2;
|
||||||
}
|
i += 2;
|
||||||
st = "" + charArray[i] + "" + charArray[i + 1];
|
current = i;
|
||||||
if (DELIMITER_2A.equals(st)) {
|
for (; i < current + length; i = i + 2) {
|
||||||
arch.append("2c");
|
st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
|
arch.append(st);
|
||||||
|
}
|
||||||
|
st = "" + charArray[i] + "" + charArray[i + 1];
|
||||||
|
if (DELIMITER_2A.equals(st)) {
|
||||||
|
arch.append("2c");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String encHostname = ShieldTVRequest.encodeMessage(hostname.toString());
|
String encHostname = ShieldTVRequest.encodeMessage(hostname.toString());
|
||||||
String encIpAddress = ShieldTVRequest.encodeMessage(ipAddress.toString());
|
String encIpAddress = ShieldTVRequest.encodeMessage(ipAddress.toString());
|
||||||
String encDeviceId = ShieldTVRequest.encodeMessage(deviceId.toString());
|
String encDeviceId = ShieldTVRequest.encodeMessage(deviceId.toString());
|
||||||
|
Loading…
Reference in New Issue
Block a user