Java 类com.amazonaws.services.iotdata.AWSIotDataClient 实例源码

项目:alexa-skills-kit-states-java    文件:AWSIotStateHandlerTest.java   
@Test
public void getAwsClients() throws Exception {
    // first check if client is constructed if no one is given
    final AWSIotStateHandler handler2 = new AWSIotStateHandler(session);
    assertNotNull(handler2.getAwsClient());
    assertNotNull(handler2.getAwsDataClient());

    // check if the client given is the client returned
    final AWSIot iotClient = new AWSIotClient();
    final AWSIotData iotData = new AWSIotDataClient();
    final AWSIotStateHandler handler3 = new AWSIotStateHandler(session, iotClient, iotData);
    assertNotNull(handler3.getAwsClient());
    assertNotNull(handler3.getAwsDataClient());
    assertEquals(iotClient, handler3.getAwsClient());
    assertEquals(iotData, handler3.getAwsDataClient());
}
项目:aws-sdk-android-samples    文件:TemperatureActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Initialize the Amazon Cognito credentials provider
    credentialsProvider = new CognitoCachingCredentialsProvider(
            getApplicationContext(),
            COGNITO_POOL_ID, // Identity Pool ID
            MY_REGION // Region
    );

    iotDataClient = new AWSIotDataClient(credentialsProvider);
    String iotDataEndpoint = CUSTOMER_SPECIFIC_ENDPOINT;
    iotDataClient.setEndpoint(iotDataEndpoint);

    NumberPicker np = (NumberPicker) findViewById(R.id.setpoint);
    np.setMinValue(60);
    np.setMaxValue(80);
    np.setWrapSelectorWheel(false);

    getShadows();
}
项目:alexa-skills-kit-states-java    文件:AWSIotStateHandlerIT.java   
@Override
public AWSIotStateHandler givenHandler() {
    // credentials need to be set in local environment
    // see http://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html
    return new AWSIotStateHandler(session, new AWSIotClient(), new AWSIotDataClient());
}
项目:DeviceConnect-Android    文件:AWSIotController.java   
/**
 * AWSIoTサーバにログインします.
 *
 * @param accessKey アクセスキー
 * @param secretKey シークレットキー
 * @param region    リージョン
 */
public void login(final String accessKey, final String secretKey, final Regions region, final LoginCallback callback) {

    if (accessKey == null || secretKey == null || region == null) {
        if (callback != null) {
            callback.onLogin(new RuntimeException("Arguments is null."));
        }
        return;
    }

    BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
    mCredentialsProvider = new StaticCredentialsProvider(credentials);

    mIotClient = new AWSIotClient(mCredentialsProvider);
    mIotClient.setRegion(Region.getRegion(region));
    mIotDataClient = new AWSIotDataClient(mCredentialsProvider);

    new DescribeEndpointTask() {
        @Override
        protected void onPostExecute(final AsyncTaskResult<String> result) {
            Exception exception = null;
            if (result.getError() == null) {
                JSONObject json;
                try {
                    json = new JSONObject(result.getResult());
                    if (json.has(END_POINT_ADDRESS)) {
                        String endpoint = json.getString(END_POINT_ADDRESS);
                        mAWSIotEndPoint = endpoint;
                        mIotDataClient.setEndpoint(endpoint);
                        for (OnAWSIotEventListener l : mOnAWSIotEventListeners) {
                            l.onLogin();
                        }
                        connectMQTT();
                    } else {
                        exception = new Exception("Not found endpointAddress.");
                    }
                } catch (JSONException e) {
                    exception = e;
                }
            } else {
                exception = result.getError();
            }
            callback.onLogin(exception);
        }
    }.execute();
}