@@ -229,10 +229,6 @@ public void onEvent(DeviceConnectionEvent event) {
229
229
230
230
case ESPConstants .EVENT_DEVICE_CONNECTED :
231
231
232
- if (TextUtils .isEmpty (provisionManager .getEspDevice ().getUserName ())) {
233
- String userName = sharedPreferences .getString (AppConstants .KEY_USER_NAME , AppConstants .DEFAULT_USER_NAME );
234
- provisionManager .getEspDevice ().setUserName (userName );
235
- }
236
232
Log .d (TAG , "Device Connected Event Received" );
237
233
setSecurityTypeFromVersionInfo ();
238
234
break ;
@@ -540,6 +536,14 @@ private void goToWiFiScanActivity() {
540
536
startActivity (wifiListIntent );
541
537
}
542
538
539
+ private void goToThreadScanActivity (boolean scanCapAvailable ) {
540
+
541
+ finish ();
542
+ Intent threadConfigIntent = new Intent (getApplicationContext (), ThreadConfigActivity .class );
543
+ threadConfigIntent .putExtra (AppConstants .KEY_THREAD_SCAN_AVAILABLE , scanCapAvailable );
544
+ startActivity (threadConfigIntent );
545
+ }
546
+
543
547
private void goToWiFiConfigActivity () {
544
548
545
549
finish ();
@@ -724,6 +728,17 @@ private void setSecurityTypeFromVersionInfo() {
724
728
default :
725
729
securityType = AppConstants .SEC_TYPE_2 ;
726
730
provisionManager .getEspDevice ().setSecurityType (ESPConstants .SecurityType .SECURITY_2 );
731
+ ArrayList <String > deviceCaps = provisionManager .getEspDevice ().getDeviceCapabilities ();
732
+
733
+ if (deviceCaps != null && deviceCaps .size () > 0
734
+ && (deviceCaps .contains (AppConstants .CAPABILITY_THREAD_SCAN ) || deviceCaps .contains (AppConstants .CAPABILITY_THREAD_PROV ))
735
+ ) {
736
+ String userName = sharedPreferences .getString (AppConstants .KEY_USER_NAME_THREAD , AppConstants .DEFAULT_USER_NAME_THREAD );
737
+ provisionManager .getEspDevice ().setUserName (userName );
738
+ } else if (TextUtils .isEmpty (provisionManager .getEspDevice ().getUserName ())) {
739
+ String userName = sharedPreferences .getString (AppConstants .KEY_USER_NAME_WIFI , AppConstants .DEFAULT_USER_NAME_WIFI );
740
+ provisionManager .getEspDevice ().setUserName (userName );
741
+ }
727
742
break ;
728
743
}
729
744
} else {
@@ -754,8 +769,12 @@ private void setSecurityTypeFromVersionInfo() {
754
769
755
770
private void processDeviceCapabilities () {
756
771
ArrayList <String > deviceCaps = espDevice .getDeviceCapabilities ();
757
- if (deviceCaps .contains ("wifi_scan" )) {
772
+ if (deviceCaps .contains (AppConstants . CAPABILITY_WIFI_SCAN )) {
758
773
goToWiFiScanActivity ();
774
+ } else if (deviceCaps .contains (AppConstants .CAPABILITY_THREAD_SCAN )) {
775
+ goToThreadScanActivity (true );
776
+ } else if (deviceCaps .contains (AppConstants .CAPABILITY_THREAD_PROV )) {
777
+ goToThreadScanActivity (false );
759
778
} else {
760
779
goToWiFiConfigActivity ();
761
780
}
0 commit comments