tencent cloud

All product documents
IoT Hub
SDK for Java Use Instructions
Last updated: 2024-12-27 17:03:43
SDK for Java Use Instructions
Last updated: 2024-12-27 17:03:43
In addition to the device connection feature, the SDK for Java also provides gateway subdevice and device shadow features with the following APIs.

MQTT APIs

The APIs related to MQTT are defined in the TXMqttConnection class and support publishing and subscribing. If you want to support the device shadow feature, you need to use the TXShadowConnection class and its methods. TXMqttConnection class APIs are as detailed below:
Method
Description
connect
Establishes MQTT connection
reconnect
Reestablishes MQTT connection
disConnect
Closes MQTT connection
publish
Publishes MQTT message
subscribe
Subscribes to MQTT topic
unSubscribe
Unsubscribes from MQTT topic
getConnectStatus
Gets MQTT connection status
setBufferOpts
Sets buffer for disconnection status

MQTT Gateway APIs

Devices that don't have direct access to the Ethernet can be connected to the network of the local gateway device first and then connected to the IoT Hub platform through the communication feature of the gateway device.
For the subdevices that join or leave the LAN, they need to be bound or unbound through the platform.
Note:
After a subdevice is connected once, as long as the gateway is successfully connected subsequently, the backend will show that the subdevice is online until it is disconnected.
The APIs related to MQTT gateway are defined in the TXGatewayConnection class as detailed below:
Method
Description
connect
Establishes gateway MQTT connection
reconnect
Reestablishes gateway MQTT connection
disConnect
Closes gateway MQTT connection
publish
Publishes MQTT message
subscribe
Subscribes to MQTT topic
unSubscribe
Unsubscribes from MQTT topic
getConnectStatus
Gets MQTT connection status
setBufferOpts
Sets buffer for disconnection status
gatewaySubdevOffline
Connects subdevice
gatewaySubdevOnline
Disconnects subdevice
gatewayBindSubdev
Binds subdevice
gatewayUnbindSubdev
Unbinds subdevice

Device Shadow APIs

If you want to support the device shadow feature, you need to use the APIs in the TXShadowConnection class as detailed below:
Method
Description
connect
Establishes MQTT connection
reconnect
Reestablishes MQTT connection
disConnect
Closes MQTT connection
publish
Publishes MQTT message
subscribe
Subscribes to MQTT topic
unSubscribe
Unsubscribes from MQTT topic
update
Updates device shadow document
get
Gets device shadow document
reportNullDesiredInfo
Reports the empty desired information after updating delta information
setBufferOpts
Sets buffer for disconnection status
getMqttConnection
Gets TXMqttConnection instance
getConnectStatus
Gets MQTT connection status
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon