Skip to content

Commit 12c3487

Browse files
committed
Fixes issues found in review.
1 parent 889dcc1 commit 12c3487

File tree

8 files changed

+25
-70
lines changed

8 files changed

+25
-70
lines changed

iot/api-client/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Google Cloud IoT Core platform.
1111

1212
3. Add the special account `cloud-iot@system.gserviceaccount.com` to that
1313
PubSub topic from the [Cloud Developer Console](https://console.cloud.google.com)
14-
or by using the helper script in the /scripts folder.
14+
or by using the helper script in the [/scripts](./scripts) folder.
1515

1616
4. Create a registry:
1717

@@ -20,7 +20,7 @@ or by using the helper script in the /scripts folder.
2020
--region=us-central1 \
2121
--pubsub-topic=projects/my-iot-project/topics/device-events
2222

23-
5. Use the `generate_keys.sh` script to generate your signing keys:
23+
5. Use the [`generate_keys.sh`](generate_keys.sh) script to generate your signing keys:
2424

2525
./generate_keys.sh
2626

@@ -32,7 +32,7 @@ or by using the helper script in the /scripts folder.
3232
--registry=my-registry \
3333
--public-key path=rsa_cert.pem,type=rs256
3434

35-
7. Connect a sample device using the sample app in the `mqtt_example` folder.
35+
7. Connect a sample device using the sample app in the [`mqtt_example`](./mqtt_example) folder.
3636
8. Learn how to manage devices programatically with the sample app in the
3737
`manager` folder.
3838

iot/api-client/manager/README.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
# Cloud IoT Core Java Device Management example
1+
r)# Cloud IoT Core Java Device Management example
22

33
This sample app demonstrates device management for Google Cloud IoT Core.
44

55
Note that before you can run the sample, you must configure a Google Cloud
6-
PubSub topic for Cloud IoT as described in the parent README.
6+
PubSub topic for Cloud IoT as described in [the parent README](../README.md).
77

88
## Setup
99

10+
Manually install [the provided client library](https://cloud.google.com/iot/resources/java/cloud-iot-core-library.jar)
11+
for Cloud IoT Core to Maven:
12+
13+
mvn install:install-file -Dfile=cloud-iot-core-library.jar -DgroupId=com.google.apis \
14+
-DartifactId=google-api-services-cloudiot -Dversion=v1beta1-rev20170418-1.22.0-SNAPSHOT \
15+
-Dpackaging=jar
16+
1017
Run the following command to install the libraries and build the sample with
1118
Maven:
1219

iot/api-client/manager/pom.xml

-11
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,6 @@
3131
<relativePath>../../../</relativePath>
3232
</parent>
3333

34-
<!-- Start local repo -->
35-
<repositories>
36-
<!-- Use a local directory for the Cloud IoT Core API dependency. -->
37-
<repository>
38-
<id>project.local</id>
39-
<name>project</name>
40-
<url>file:./repo</url>
41-
</repository>
42-
</repositories>
43-
<!-- End of extra repo -->
44-
4534
<properties>
4635
<maven.compiler.source>1.7</maven.compiler.source>
4736
<maven.compiler.target>1.7</maven.compiler.target>

iot/api-client/manager/repo/com/google/apis/google-api-services-cloudiot/maven-metadata.xml

-11
This file was deleted.

iot/api-client/manager/repo/com/google/apis/google-api-services-cloudiot/v1beta1-rev20170418-1.22.0-SNAPSHOT/maven-metadata.xml

-25
This file was deleted.

iot/api-client/manager/src/main/java/com/google/cloud/iot/examples/DeviceRegistryExample.java

+8-13
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,15 @@
4646
* IoT devices and registries, using both RSA and eliptic curve keys for authentication.
4747
*
4848
* <p>To start, follow the instructions on the Developer Guide at cloud.google.com/iot to create a
49-
* service_account.json file. Also create a Cloud Pub/Sub topic as discussed in the guide. After
50-
* doing this, you should have service_account.json in your directory. Tell gcloud about this file
51-
* by setting it in an environment variable:
52-
*
53-
* <pre>
54-
* <code>
55-
* $ export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account.json
56-
* </code>
57-
* </pre>
49+
* service_account.json file and Cloud Pub/Sub topic as discussed in the guide. You will then need
50+
* to point to the service_account.json file as described in
51+
* https://developers.google.com/identity/protocols/application-default-credentials#howtheywork
5852
*
5953
* <p>Before running the example, we have to create private and public keys, as described in
6054
* cloud.google.com/iot. Since we are interacting with the device manager, we will only use the
61-
* public keys. The private keys are used to sign JWTs to authenticate devices. See the MQTT client
62-
* example in the developer guide for an example of this.
55+
* public keys. The private keys are used to sign JWTs to authenticate devices. See the
56+
* <a href="https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/iot/api-client/mqtt_example">MQTT client example</a>
57+
* for more information.
6358
*
6459
* <p>Finally, compile and run the example with:
6560
*
@@ -76,7 +71,7 @@
7671
* </pre>
7772
*/
7873
public class DeviceRegistryExample {
79-
// CloudIot service for administering Cloud IoT devices, registries and projects.
74+
// Service for administering Cloud IoT Core devices, registries and projects.
8075
private CloudIot service;
8176
// Path to the project and location: "projects/my-project-id/locations/us-central1"
8277
private String projectPath;
@@ -255,7 +250,7 @@ public void modifyCloudToDeviceConfig(String deviceId, String configData) throws
255250
ModifyCloudToDeviceConfigRequest request = new ModifyCloudToDeviceConfigRequest();
256251
DeviceConfigData data = new DeviceConfigData();
257252
data.setBinaryData(DatatypeConverter.printBase64Binary(configData.getBytes(Charsets.UTF_8)));
258-
request.setVersionToUpdate(0L);
253+
request.setVersionToUpdate(0L); // 0L indicates update all versions
259254
request.setData(data);
260255
DeviceConfig config =
261256
service

iot/api-client/mqtt_example/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ as part of Google Cloud IoT Core.
55

66
Note that before you can run the sample, you must configure a Google Cloud
77
PubSub topic for Cloud IoT Core and register a device as described in the
8-
parent README.
8+
[parent README](../README.md).
99

1010
## Setup
1111

@@ -27,8 +27,8 @@ The following command summarizes the sample usage:
2727

2828
For example, if your project ID is `blue-jet-123`, your service account
2929
credentials are stored in your home folder in creds.json and you have generated
30-
your credentials using the shell script provided in the parent folder, you can
31-
run the sample as:
30+
your credentials using the [`generate_keys.sh`](../generate_keys.sh) script
31+
provided in the parent folder, you can run the sample as:
3232

3333
mvn exec:java \
3434
-Dexec.mainClass="com.google.cloud.iot.examples.MqttExample" \

iot/api-client/mqtt_example/src/main/java/com/google/cloud/iot/examples/MqttExample.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
* <p>To run this example, first create your credentials and register your device as
2626
* described in the README located in the sample's parent folder.
2727
*
28-
* <p>After you have registered your device and generated ompile and run with the
29-
* corresponding algorithm flag, for example:
28+
* <p>After you have registered your device and generated your credentials, compile and
29+
* run with the corresponding algorithm flag, for example:
3030
*
3131
* <pre>
3232
* $ mvn compile

0 commit comments

Comments
 (0)