Last Updated on : 2024-09-11 08:39:29
Tuya Cube provides the Pulsar SDK for Java. In this topic, the Java development tool IntelliJ IDEA is used to receive messages.
Go to the GitHub Pulsar SDK repository, click Code, download the package to the local computer, and then decompress the package.
Open IntelliJ IDEA, click Open, and then find the downloaded and decompressed file in the previous step to open the source code project.
Modify parameters in open-mq-sdk/src/main/java/com.tuya.open.sdk/mq/
MqConsumer.java. Modify the Java project to a test environment.
private MqEnv env = MqEnv.TEST;
MqEnv.TEST represents the test environment.
MqEnv.PROD represents the production environment.
For more information about the parameters, see mq/MqEnv.java.
Modify parameters in open-mq-sdk/src/main/java/com.tuya.open.sdk/mq/
MqConsumer.java.
String url = MqConfigs.CN_SERVER_URL;
String accessId = "xt*****ff**n1****8ufo";
String accessKey = "479bcb7345******582d9c******4ef7";
The parameters are described as follows.
accessId
: Enter the value of Access ID in the Authorization Key section of the cloud project on the Tuya IoT Development Platform.
accessKey
: Enter the value of Access Secret in the Authorization Key section of the cloud project on the Tuya IoT Development Platform.
url
: For more information about the parameters, see mq/MqConfigs.java. Be sure to use the domain name URL of the private cloud.
Configure a test device.
On the page of Message Service, after your subscription is ready, Subscribed appears in the Status column. Then, click the Message Test tab.
Enter the associated device ID in the search box, click the magnifier icon, and then double-click the selected device.
If an associated device is specified as a test device, the test device will report a message to the test channel for you to debug device features.
On the IntelliJ IDEA, right-click the ConsumerExample.java file and select Run to run the program.
Control the device with a mobile app, such as the Smart Life app.
Automatically get the push messages on IntelliJ IDEA.
For more information about message types, see Message Types.
Parameter | Data type | Description |
---|---|---|
protocol | Integer | The protocol number. |
pv | String | The version of the communication protocol. |
t | Long | The timestamp. |
sign | String | The signature. |
data | String | The data body. |
{
"protocol": 4,
"pv": "2.0",
"t": 146052438362,
"data":"4FDEE3FE59Fxxxx***",
"sign": "58285279b5b5790c7d917dxxxxx***"
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback