@@ -229,10 +229,6 @@ public void onEvent(DeviceConnectionEvent event) {
229229
230230 case ESPConstants .EVENT_DEVICE_CONNECTED :
231231
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- }
236232 Log .d (TAG , "Device Connected Event Received" );
237233 setSecurityTypeFromVersionInfo ();
238234 break ;
@@ -540,6 +536,14 @@ private void goToWiFiScanActivity() {
540536 startActivity (wifiListIntent );
541537 }
542538
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+
543547 private void goToWiFiConfigActivity () {
544548
545549 finish ();
@@ -724,6 +728,17 @@ private void setSecurityTypeFromVersionInfo() {
724728 default :
725729 securityType = AppConstants .SEC_TYPE_2 ;
726730 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+ }
727742 break ;
728743 }
729744 } else {
@@ -754,8 +769,12 @@ private void setSecurityTypeFromVersionInfo() {
754769
755770 private void processDeviceCapabilities () {
756771 ArrayList <String > deviceCaps = espDevice .getDeviceCapabilities ();
757- if (deviceCaps .contains ("wifi_scan" )) {
772+ if (deviceCaps .contains (AppConstants . CAPABILITY_WIFI_SCAN )) {
758773 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 );
759778 } else {
760779 goToWiFiConfigActivity ();
761780 }
0 commit comments