Bu sayfa henüz yerel dilinizde mevcut değildir. Daha fazla dil seçeneği eklemek için yoğun bir şekilde çalışıyoruz. Desteğiniz için teşekkür ederiz.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Examples

Updated on 2024-12-31 GMT+08:00

Scenario 1: Allowing or Denying the Message Publishing Through a Specific Topic

  1. Create a product and device.
    • Create a product. Access the IoTDA service page and click Access Console. Click the target instance card. Choose Products in the navigation pane and click Create Product. Set the parameters as prompted and click OK. For details, see Creating a Product.
    • Create a device. On the IoTDA console, choose Devices > All Devices in the navigation pane, and click Register Device. Set the parameters as prompted and click OK. For details, see Registering an Individual Device.
  2. Create a policy.
    • Access the IoTDA service page and click Access Console. Click the target instance card.
    • Choose Devices > Policies in the navigation pane.
      Figure 1 Device policy - Access page
    • Click Create Policy, set policy parameters, and click Generate. The application scope of the policy is the resource space (appId). Resources starting with topic: indicate topics in MQTT communications and are used for publishing and subscription. In this example, the topic that can be published and subscribed to is /v1/test/hello.
      Figure 2 Device policy - Creating a policy
    • Bind the policy. In this example, set Target Type to Devices and select the devices to which the policy is to be bound.
      Figure 3 Device policy - Binding a device
    • Verify the policy.
      1. Obtain connection parameters. In the navigation pane, choose Devices > All Devices, find the devices bound to the policy in the preceding step, go to the device details page, and view the connection parameters.
        Figure 4 Device - Device details
        Figure 5 Device - Device details - MQTT connection parameters
      2. Use the MQTT.fx tool to connect to the cloud platform. Open the MQTT.fx tool, set authentication parameters for the devices bound to the policy in the preceding step, click Apply, and click Connect for connection authentication.
      3. Use the device to subscribe to the allowed topic /v1/test/hello. The subscription is successful.
        Figure 6 Successful subscription
      4. Use the device to subscribe to another topic /v2/test/hello. The subscription failed.
        Figure 7 Failed subscription

Scenario 2: Using Policy in E2E (M2M) Communications

In this example, you can enable device A under product A and all devices under product B to communicate with each other, and only allow them to subscribe to or publish messages through topics starting with /test/M2M/.

  1. Create a product and device.
    • Create a product. Access the IoTDA service page and click Access Console. Click the target instance card. Choose Products in the navigation pane and click Create Product. Set the parameters as prompted and click OK. For details, see Creating a Product.
    • Create a device. On the IoTDA console, choose Devices > All Devices in the navigation pane, and click Register Device. Set the parameters as prompted and click OK. For details, see Registering an Individual Device.
  2. Configure a data forwarding rule.
    • Access the IoTDA service page and click Access Console. Click the target instance card. In the navigation pane, choose Rules > Data Forwarding.
      Figure 8 Data forwarding - List
    • Click Create Rule, set the parameters as required, and click Create Rule. Set the SQL filter statement to STARTS_WITH(notify_data.body.topic,'/test/M2M/').
      Figure 9 Creating a forwarding rule - M2M
      NOTE:

      For details about how to use SQL filter statements, see SQL Statements.

      STARTS_WITH(notify_data.body.topic,'/test/M2M/') indicates that data with topics starting with /test/M2M/ is filtered.

    • Set the forwarding target. Set Forwarding Target to Device, set Topic to $topic() (indicating that the forwarded topic remains unchanged and the original topic is delivered), and click OK.
      Figure 10 Creating a forwarding target - to a device
    • Click Enable Rule in the middle of the page.
      Figure 11 Enabling a rule - Forwarding data to a device
  3. Set a policy.
    • Choose Devices > Policies in the navigation pane.
      Figure 12 Device policy - Access page
    • Click Create Policy, set policy parameters, and click Generate, as shown in the following figure.
      Figure 13 Device policy - Creating a policy (M2M)
    • Bind the policy to the target products and devices. Set Target Type to Products and select the products to which the policy is to be bound. You can later modify the policy on the policy details page to add the devices to be bound.
      Figure 14 Device policy - Binding a product
      Figure 15 Device policy - Encoding a policy

  4. Verify the policy.
    1. Open two MQTT.fx tools to simulate device A (test111) under product A and device B (test222) under product B.
    2. On the Subscribe page of device B, enter the topic /test/M2M/# and click Subscribe.
      Figure 16 Entering a topic on the Subscribe page of device B
    3. Let device A send a message to device B. On the Publish page of device A, enter the topic /test/M2M/${Any word}. Enter the message to be sent (for example, hello) in the text box, and click Publish.
      Figure 17 Entering a message on the Publish page of device A

      On the Subscribe page of device B, you can see the received message, as shown in the following figure.

      Figure 18 Subscribe page of device B
    4. For devices not belonging to product B, they cannot subscribe to or publish messages through the topic /test/M2M/#.
      Figure 19 Failed subscription

Sitemizi ve deneyiminizi iyileştirmek için çerezleri kullanırız. Sitemizde tarama yapmaya devam ederek çerez politikamızı kabul etmiş olursunuz. Daha fazla bilgi edinin

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback