MQTT
Deployment
-
Select
MQTT
protocol, and then click on "Next Step". -
Fill in device name, device manufacturer, device type, and device model. The device name is the identifier used to distinguish different devices in Shifu Cloud. And then click on "Next Step".
-
Enter the IP address of the device you want to connect to.
-
Input the API method, API interface, and MQTT topic. Add at least one API to generate the API specification file, where the API methods include GET and POST. For MQTT, the same API cannot bind to 2 different MQTT Topic. For example, if you have an API named api1, and link it to MQTT Topic /topic1 with HTTP GET. Do not add a new api with API name api1 and MQTT Topic /topic2.
-
After adding the API, copy and paste the command from the pop-up to deploy the device into your Kubernetes cluster.
Usage
-
Use
kubectl get pods -A
to view device deployment status. -
To access the deviceshifu-mosquitto-service running in the deviceshifu namespace, use the following command to forward a local port to the service port:
kubectl port-forward service/deviceshifu-mosquitto-service -n deviceshifu 3000:80
-
Access the deviceshifu Mosquitto service via
http://localhost:3000/value
, and use curl to perform read and write operations separately. -
List all pods in the devices namespace to identify the running Mosquitto pod, then execute a command in that pod to subscribe to a specific topic and verify message reception.