Search code examples
androidalljoyn

Error on configureWiFi method alljoyn framework


I see this error when passing the target and onboardee wifinetwork configurations to the onboarding sdk.

This is the piece of code where the error occurs.

        ConfigureWifiMode res1 = this.onboardingClient.configureWiFi(this.onboardingConfiguration.getTarget().getSSID(), passForConfigureNetwork, this.onboardingConfiguration.getTarget().getAuthType());

        Log.i("OnboardingManager", "configureWiFi result=" + res1);
        switch(OnboardingManager.SyntheticClass_1.$SwitchMap$org$alljoyn$onboarding$transport$OnboardingTransport$ConfigureWifiMode[res1.ordinal()]) {
        case 1:
            this.onboardingClient.connectWiFi();
            return new OnboardingManager.DeviceResponse(OnboardingManager.DeviceResponse.ResponseCode.Status_OK);
        case 2:
            return new OnboardingManager.DeviceResponse(OnboardingManager.DeviceResponse.ResponseCode.Status_OK_CONNECT_SECOND_PHASE);
        default:
            Log.e("OnboardingManager", "configureWiFi returned an unexpected result: " + res1);
            return new OnboardingManager.DeviceResponse(OnboardingManager.DeviceResponse.ResponseCode.Status_ERROR);
        }

Here is my Logcat:

04-28 21:16:35.332 2812-2982/net.holisticlabs.august E/OnboardingManager: onboarddDevice 
                                                                          org.alljoyn.bus.BusException: ER_BUS_SECURITY_NOT_ENABLED

Any help will be great! Thanks!


Solution

  • Try to add an authentication listener to the bus attachment:

    /* set keyListener */
    String keyStoreFileName = getApplicationContext().getFileStreamPath("alljoyn_keystore").getAbsolutePath();
    
    if (keyStoreFileName != null && keyStoreFileName.length() > 0) {
          SrpAnonymousKeyListener authListener = new SrpAnonymousKeyListener(this, m_logger, new String[] { "ALLJOYN_SRP_KEYX", "ALLJOYN_ECDHE_PSK" });
          Status authStatus = m_Bus.registerAuthListener(authListener.getAuthMechanismsAsString(), authListener, keyStoreFileName);
    
          if (authStatus != Status.OK) {
               Log.d("TAG","Failed to register Auth listener status = " + authStatus.toString());
          }
    }
    
    
    private final GenericLogger m_logger = new GenericLogger() {
            @Override
            public void debug(String TAG, String msg) {
                Logg.d(msg);
        }
    
        @Override
        public void info(String TAG, String msg) {
            Logg.i(msg);
        }
    
        @Override
        public void warn(String TAG, String msg) {
            Logg.w(msg);
        }
    
        @Override
        public void error(String TAG, String msg) {
            Logg.e(msg);
        }
    
        @Override
        public void fatal(String TAG, String msg) {
            Logg.d(msg);
        }
    };