このページは、お客様の言語ではご利用いただけません。Huawei Cloudは、より多くの言語バージョンを追加するために懸命に取り組んでいます。ご協力ありがとうございました。

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
Help Center/ IoT Device Access/ Best Practices/ Device Management/ Performing OTA Firmware Upgrade for MQTT Devices

Performing OTA Firmware Upgrade for MQTT Devices

Updated on 2025-03-03 GMT+08:00

Scenarios

Message Queuing Telemetry Transport (MQTT) is a publish/subscribe messaging protocol that transports messages between clients and a server. It is suitable for remote sensors and control devices (such as smart street lights) that have limited computing capabilities and work in low-bandwidth, unreliable networks through persistent connections. Firmware upgrade is a basic function that network devices must support. Online upgrades are important especially when the firmware needs to be upgraded due to security vulnerabilities, software bugs, function optimization, and device performance improvement. This section describes how to upgrade the firmware in Huawei Cloud IoTDA using MQTT.fx to simulate a device.

NOTE:

The software upgrade process is the same as that of the firmware upgrade. The only difference is that the parameters for reporting version numbers are different. For firmware upgrade, the parameter that specifies the version number is fw_version. For software upgrade, the parameter is sw_version. For details, see Device Reporting the Software and Firmware Versions.

Development Process

Figure 1 Upgrade process
Figure 2 MQTT device upgrade process

Development Environment

  • Software: Huawei Cloud IoTDA, 64-bit Windows 7 or later (64-bit Windows 10 is used in the following demonstration), and MQTT.fx simulator.

Prerequisites

  • You have registered a Huawei Cloud account.
  • You have completed real-name authentication. Otherwise, IoTDA cannot be used.
  • You have subscribed to IoTDA. If you have not subscribed to the service, go to the IoTDA service page, and click Access Console to subscribe to the service.

Preparations

  • 1. Download and install MQTT.fx (version 1.7.1 or later).
  • Prepare the upgrade package. Obtain the firmware upgrade package and its version number from the module vendor. Temporary files are used in this demonstration.
  • Create an MQTT product. (If an MQTT product already exists, skip this step.)
  • Register an individual device.
  • Add the registered device to a device group, which will be used during upgrade task creation.

Uploading an Upgrade Package

  1. Visit the IoTDA service page and click Access Console. Click the target instance card.
  2. In the navigation pane, choose Devices > Software/Firmware Upgrades.
  3. Click the Manage Resource Package tab and click Firmware List.
  4. Click Upload. On the displayed page, upload a firmware package from OBS or your local PC.

    Figure 3 Uploading the upgrade package - OBS file
    Figure 4 Uploading the upgrade package - local file

  5. After the upgrade package is uploaded, configure package parameters and click OK.

    Figure 5 Uploading the upgrade package - OBS file parameters
    Figure 6 Uploading the upgrade package - local file parameters

  6. The uploaded upgrade package is displayed in the firmware list.

    Figure 7 Software/Firmware upgrade - Firmware list

  7. Click Create Upgrade Task. On the Firmware Upgrades tab page, click Create Task. On the displayed page, configure parameters, select upgrade packages, select devices to upgrade, and click Create Now.

    Figure 8 Creating a firmware upgrade task - Test_upgrade_1
    NOTE:

    When creating an upgrade task, you can select up to 10 upgrade packages. Supported source versions of the upgrade packages must be unique. If no source version is specified for an upgrade package, the package can be used to upgrade devices of all source versions by default.

  8. View the created task in the task list. You can click View to view the task details. On the task details page, you can stop executing upgrade tasks for up to 100 devices in batches or an upgrade task for a single device. You can retry failed upgrade tasks for up to 100 devices in batches or an upgrade task for a single device. You can click All Retry to retry the upgrade task for all failed devices.

    Figure 9 Task details - Test_upgrade_1

Performing Upgrade

  1. Use MQTT.fx to simulate device access to the platform. For details, see "Performing Connection Authentication".
  2. Use MQTT.fx to subscribe to the downstream message topic of the platform. MQTT.fx receives the version query command delivered by the platform.

    Topic

    Downstream: $oc/devices/{device_id}/sys/events/down

    Parameters

    For details, see Platform Delivering an Event to Obtain Version Information.

    Figure 10 Subscribe/Push

  3. Report the software and firmware version information using MQTT.fx.

    Topic

    Upstream: $oc/devices/{device_id}/sys/events/up

    Parameters

    For details, see Device Reporting the Software and Firmware Versions.

    Example

    Topic: $oc/devices/{device_id}/sys/events/up   
    Data format:  {
          "object_device_id": "{object_device_id}",
          "services": [{
              "service_id": "$ota",
              "event_type": "version_report",
              "event_time": "20151212T121212Z",
              "paras": {
                  "sw_version": "v1.0",
                  "fw_version": "v1.0"
              }
          }]
      } 
    Figure 11 Reporting version numbers

  4. After the version numbers are reported, the simulator receives an upgrade notification from the platform. The notification is as follows:

    Topic

    Upstream: $oc/devices/{device_id}/sys/events/down

    Parameters

    For details, see Platform Delivering an Upgrade Event.

    Figure 12 Obtaining the upgrade notification

  5. After the device receives the upgrade notification, send an HTTP request to download the upgrade package.

    A cURL command is used in this demonstration.

    Figure 13 Downloading the upgrade package

    Example

    curl -X GET -H "Authorization:Bearer ****************************" "https://**.**.**.**:8943/iodm/dev/v2.0/upgradefile/applications/********/devices/********/packages/********" -v -k
    CAUTION:
    • Add Authorization to the HTTP request header. The value of Authorization is Bearer {access_token}, where the value of {access_token} is the token in the upgrade notification. Leave a space between Bearer and {access_token}.
    • If event_type is set to firmware_upgrade_v2 or software_upgrade_v2, the request header does not need to be carried in the request for downloading the software or firmware package. An example request is as follows:

    GET https://******.obs.cn-north-4.myhuaweicloud.com:443/test.bin?AccessKeyId=DX5G7W*********

  6. Enable the device to report the upgrade status.

    Topic

    Upstream: $oc/devices/{device_id}/sys/events/up

    Parameters

    For details, see Device Reporting the Upgrade Status.

    Example

    Topic: $oc/devices/{device_id}/sys/events/up
    Data format:
      {     "object_device_id": "{object_device_id}",
         "services": [{
             "service_id": "$ota",
             "event_type": "upgrade_progress_report",
             "event_time": "20151212T121212Z",
             "paras": {
                 "result_code": 0,
                 "progress": 50,
                 "version": "V1.0",
                 "description": "upgrade processing"
             }
         }] }

    The following figure shows that the upgrade progress is 50%, which is displayed on the platform.

    Figure 14 Reporting the upgrade progress (50%)

    Figure 15 Upgrade progress - Test_upgrade_1-

  7. Complete the upgrade.

    If the upgrade progress is 100% and the current version is the target version, the upgrade task success will be displayed on the platform.

    Figure 16 Reporting the upgrade progress (100%)

    Figure 17 Software/Firmware upgrade - Firmware upgrade

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback