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

[tlv] add new tlvs for network diagnostic #266

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ Makefile.in
/build
cmake-build-*

# Test
/tmp

#tools
.vscode
.idea
Expand Down
2 changes: 1 addition & 1 deletion android/openthread_commissioner/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ android {

defaultConfig {
applicationId "io.openthread.commissioner.app"
minSdkVersion 24
minSdkVersion 26
targetSdkVersion 34
versionCode 1
versionName "0.0.1"
Expand Down
3 changes: 3 additions & 0 deletions android/openthread_commissioner/examples/qrcode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# QR code

- file `v=1&&eui=0000b57fffe15d68&&cc=J01NU5.png` is the Thread joiner device QR code which encodes the joiner EUI and PSKd as a text string (the content is `v=1&&eui=0000b57fffe15d68&&cc=J01NU5`)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion android/openthread_commissioner/service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ android {
compileSdkVersion 34

defaultConfig {
minSdkVersion 24
minSdkVersion 26
targetSdkVersion 34

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -73,10 +73,13 @@ dependencies {

implementation fileTree(dir: "libs", include: ["*.jar"])

implementation 'com.google.guava:guava:31.1-jre'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation "androidx.concurrent:concurrent-futures:1.1.0"
implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'com.google.android.gms:play-services-vision:20.1.3+'
implementation 'com.google.android.gms:play-services-threadnetwork:16.0.0'
implementation 'com.google.android.material:material:1.2.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import android.net.nsd.NsdServiceInfo;
import android.net.wifi.WifiManager;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresPermission;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;
Expand All @@ -47,7 +48,7 @@ public class BorderAgentDiscoverer implements NsdManager.DiscoveryListener {
private static final String TAG = BorderAgentDiscoverer.class.getSimpleName();

private static final String SERVICE_TYPE = "_meshcop._udp";
private static final String KEY_DISCRIMINATOR = "discriminator";
private static final String KEY_ID = "id";
private static final String KEY_NETWORK_NAME = "nn";
private static final String KEY_EXTENDED_PAN_ID = "xp";

Expand All @@ -62,9 +63,10 @@ public class BorderAgentDiscoverer implements NsdManager.DiscoveryListener {
private boolean isScanning = false;

public interface BorderAgentListener {

void onBorderAgentFound(BorderAgentInfo borderAgentInfo);

void onBorderAgentLost(String discriminator);
void onBorderAgentLost(byte[] id);
}

@RequiresPermission(permission.INTERNET)
Expand Down Expand Up @@ -182,10 +184,10 @@ public void onServiceFound(NsdServiceInfo nsdServiceInfo) {

@Override
public void onServiceLost(NsdServiceInfo nsdServiceInfo) {
String discriminator = getBorderAgentDiscriminator(nsdServiceInfo);
if (discriminator != null) {
Log.d(TAG, "a Border Agent service is gone");
borderAgentListener.onBorderAgentLost(discriminator);
byte[] id = getBorderAgentId(nsdServiceInfo);
if (id != null) {
Log.d(TAG, "a Border Agent service is gone: " + nsdServiceInfo.getServiceName());
borderAgentListener.onBorderAgentLost(id);
}
}

Expand All @@ -199,40 +201,29 @@ public void onStopDiscoveryFailed(String serviceType, int errorCode) {
Log.d(TAG, "stop discovering Border Agent failed: " + errorCode);
}

@Nullable
private BorderAgentInfo getBorderAgentInfo(NsdServiceInfo serviceInfo) {
Map<String, byte[]> attrs = serviceInfo.getAttributes();

// Use the host address as default discriminator.
String discriminator = serviceInfo.getHost().getHostAddress();

if (attrs.containsKey(KEY_DISCRIMINATOR)) {
discriminator = new String(attrs.get(KEY_DISCRIMINATOR));
}
byte[] id = getBorderAgentId(serviceInfo);

if (!attrs.containsKey(KEY_NETWORK_NAME) || !attrs.containsKey(KEY_EXTENDED_PAN_ID)) {
return null;
}

return new BorderAgentInfo(
discriminator,
id,
new String(attrs.get(KEY_NETWORK_NAME)),
attrs.get(KEY_EXTENDED_PAN_ID),
serviceInfo.getHost(),
serviceInfo.getPort());
}

private String getBorderAgentDiscriminator(NsdServiceInfo serviceInfo) {
@Nullable
private byte[] getBorderAgentId(NsdServiceInfo serviceInfo) {
Map<String, byte[]> attrs = serviceInfo.getAttributes();

if (attrs.containsKey(KEY_DISCRIMINATOR)) {
return new String(attrs.get(KEY_DISCRIMINATOR));
}

if (serviceInfo.getHost() != null) {
// Use the host address as default discriminator.
return serviceInfo.getHost().getHostAddress();
if (attrs.containsKey(KEY_ID)) {
return attrs.get(KEY_ID).clone();
}

return null;
}
}
Loading
Loading