-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Surface a NetworkLocation on Android for ChipDeviceController (#13797)
Currently there is a method to getIpAddress(), but we also need to know the port. This adds a Java wrapper class that combines both properties, and the JNI bindings to resolve. Tested: - Commissioned an m5stack, and verified that the resolved NetworkLocation on the Java side matched Addr 0 logged from DIS after mDNS discovery completed.
- Loading branch information
Showing
4 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/controller/java/src/chip/devicecontroller/NetworkLocation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package chip.devicecontroller; | ||
|
||
import java.util.Locale; | ||
|
||
/** Represents a location on an operational network. */ | ||
public final class NetworkLocation { | ||
private final String ipAddress; | ||
private final int port; | ||
|
||
public NetworkLocation(String ipAddress, int port) { | ||
this.ipAddress = ipAddress; | ||
this.port = port; | ||
} | ||
|
||
/** Returns the IP address (e.g. fe80::3e61:5ff:fe0c:89f8). */ | ||
public String getIpAddress() { | ||
return ipAddress; | ||
} | ||
|
||
public int getPort() { | ||
return port; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format(Locale.ROOT, "%s[%d]", ipAddress, port); | ||
} | ||
} |