コード例 #1
0
OSStatus fogCloudDevAuthorize(app_context_t* const inContext,
                              MVDAuthorizeRequestData_t devAuthorizeReqData)
{
    cloud_if_log_trace();
    OSStatus err = kUnknownErr;
    easycloud_service_state_t cloudServiceState = FOGCLOUD_STOPPED;

    cloud_if_log("Device authorize...");

    cloudServiceState = FogCloudServiceState(&easyCloudContext);
    if (FOGCLOUD_STOPPED == cloudServiceState)
    {
        return kStateErr;
    }

    //ok, set cloud context
    strncpy(easyCloudContext.service_config_info.loginId,
            devAuthorizeReqData.loginId, MAX_SIZE_LOGIN_ID);
    strncpy(easyCloudContext.service_config_info.devPasswd,
            devAuthorizeReqData.devPasswd, MAX_SIZE_DEV_PASSWD);
    strncpy(easyCloudContext.service_config_info.userToken,
            devAuthorizeReqData.user_token, MAX_SIZE_USER_TOKEN);

    err = FogCloudAuthorize(&easyCloudContext);
    require_noerr_action( err, exit, cloud_if_log("ERROR: authorize failed! err=%d", err) );
    return kNoErr;

exit:
    return err;
}
コード例 #2
0
ファイル: fogCloud.c プロジェクト: hujg/mico_v2.2.0
OSStatus fogCloudDevAuthorize(mico_Context_t* const inContext,
                                       MVDAuthorizeRequestData_t devAuthorizeReqData)
{
  cloud_if_log_trace();
  OSStatus err = kUnknownErr;
  easycloud_service_state_t cloudServiceState = FOGCLOUD_STOPPED;
  
  cloud_if_log("Device authorize...");

  cloudServiceState = FogCloudServiceState(&easyCloudContext);
  if (FOGCLOUD_STOPPED == cloudServiceState){
    return kStateErr;
  }
  
  // dev_passwd ok ?
  if(0 != strncmp(inContext->flashContentInRam.appConfig.fogcloudConfig.devPasswd, 
                  devAuthorizeReqData.devPasswd, 
                  strlen(inContext->flashContentInRam.appConfig.fogcloudConfig.devPasswd)))
  {
    // devPass err
    cloud_if_log("ERROR: fogCloudDevAuthorize: devPasswd mismatch!");
    return kMismatchErr;
  }
  cloud_if_log("fogCloudDevAuthorize: devPasswd ok!");
  
  //ok, set cloud context
  strncpy(easyCloudContext.service_config_info.loginId, 
          devAuthorizeReqData.loginId, MAX_SIZE_LOGIN_ID);
  strncpy(easyCloudContext.service_config_info.devPasswd, 
          devAuthorizeReqData.devPasswd, MAX_SIZE_DEV_PASSWD);
  strncpy(easyCloudContext.service_config_info.userToken, 
          devAuthorizeReqData.user_token, MAX_SIZE_USER_TOKEN);
  
  err = FogCloudAuthorize(&easyCloudContext);
  require_noerr_action( err, exit, cloud_if_log("ERROR: authorize failed! err=%d", err) );
  return kNoErr;
  
exit:
  return err;
}