Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto discovery feature #4

Open
hllhll opened this issue Nov 11, 2020 · 2 comments
Open

Auto discovery feature #4

hllhll opened this issue Nov 11, 2020 · 2 comments

Comments

@hllhll
Copy link
Owner

hllhll commented Nov 11, 2020

com.airconet.plus.info.activity.AddDeviceActivity.lambda$search$1$AddDeviceActivity Sends b'cast to 255.255.255.255:1025 with "Are You AirM2M IOT Smart Device?"

lambda$search$2$AddDeviceActivity Listens on the same socket and recives back some data that is later parsed as AirConDevice

    public static final Pattern SEARCH_PATTERN = Pattern.compile("^I'm\\s*(\\w+)\\.\\s*((\\p{XDigit}{2}:?){5}\\p{XDigit}{2})\\s*((\\d{1,3}\\.){3}\\d{1,3})")
    ...
    private AirConDevice parse(String str) {
        Matcher matcher = SEARCH_PATTERN.matcher(str);
        if (!matcher.find()) {
            return null;
        }
        String group = matcher.group(1);  // Type?
        String group2 = matcher.group(2);   // Mac address
        String group3 = matcher.group(4);   // Private ip
        if (group2 != null) {
            return AirConDevice.create(group, group2.replaceAll(":", "").toUpperCase(), group3);
        }
        return null;
    }
@hllhll
Copy link
Owner Author

hllhll commented Nov 11, 2020

Or in PCRE terms:
^I'm\s*(\w+)\.\s*(([0-9a-fA-F]{2}:?){5}[0-9a-fA-F]{2})\s*((\d{1,3}\.){3}\d{1,3})
Matches something like
I'm typeOfDevice. 01:23:45:67:89:ab 192.168.1.20

@hllhll
Copy link
Owner Author

hllhll commented Feb 9, 2021

Example how to issue:
ncat -u 192.168.1.102 1025 < a.txt
a.txt:
Are You AirM2M IOT Smart Device?
Response:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant