예제 #1
0
/**
 * It will do onboarding based on the user's configuration.
 */
bool ESOnboard(const char * ssid, const char* passwd, NetworkEventCallback cb)
{
    OIC_LOG(DEBUG, ES_ENROLLEE_TAG, "ESOnboard IN");

    if (ESSoftapOnboarding())
    {
        if (ESSoftapAtEnrollee())
        {
            OIC_LOG(DEBUG, ES_ENROLLEE_TAG, "Create SoftAp at enrollee");
            ESCreateSoftap(ssid, passwd, cb);
        }
        else
        {
            OIC_LOG(DEBUG, ES_ENROLLEE_TAG, "Connecting to Mediator SoftAp");
            ConnectToWiFiNetwork(ssid, passwd, cb);
        }
        return true;
    }
    else if (ESBleOnboarding())
    {
        OIC_LOG(ERROR, ES_ENROLLEE_TAG, "ESOnboard::Ble onboarding is not supported");
        // TODO:
        return false;
    }
    else
    {
        // TODO:
        OIC_LOG(ERROR, ES_ENROLLEE_TAG, "ESOnboard::Invalid onboarding option");
        return false;
    }
}
예제 #2
0
/**
 * It will do onboarding based on the user's configuration.
 */
bool ESOnboard(const char * ssid, const char* passwd, NetworkEventCallback cb)
{
    OIC_LOG(DEBUG, ES_ENROLLEE_TAG, "ESOnboard IN");

    if (ESSoftapOnboarding())
    {
        //Arduino does not need to check ESSoftapAtEnrollee()
        //As SoftAP for Arduino Enrollee will be created at Mediator side &
        //Arduino Enrollee always connects to the mediator's softAp.

        OIC_LOG(DEBUG, ES_ENROLLEE_TAG, "Connecting to Mediator SoftAp");
        ConnectToWiFiNetwork(ssid, passwd, cb);
        return true;
    }
    else if (ESBleOnboarding())
    {
        OIC_LOG(ERROR, ES_ENROLLEE_TAG, "ESOnboard::Ble onboarding is not supported");
        // TODO:
        return false;
    }
    else
    {
        // TODO:
        OIC_LOG(ERROR, ES_ENROLLEE_TAG, "ESOnboard::Invalid onboarding option");
        return false;
    }
}
예제 #3
0
void ESProvisioningCallback(ESResult esResult)
{
    OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "ESProvisioningCallback with  result = %d", esResult);

    if (esResult == ES_RECVTRIGGEROFPROVRES)
    {
        GetTargetNetworkInfoFromProvResource(gTargetSsid, gTargetPass);
        gEnrolleeStatusCb(ES_OK, ES_PROVISIONED_STATE);
        OIC_LOG(DEBUG, ES_ENROLLEE_TAG, "Connecting with target network");

        // Connecting/onboarding to target network
        ConnectToWiFiNetwork(gTargetSsid, gTargetPass, ESOnboardingCallbackTargetNet);
    }
    else
    {
       OIC_LOG_V(DEBUG, ES_ENROLLEE_TAG, "Provisioning is failed callback result is = %d", esResult);
       // Resetting Enrollee to ONBOARDED_STATE as Enrollee is alreday onboarded in previous step
       gEnrolleeStatusCb(ES_OK, ES_ON_BOARDED_STATE);
    }
}