Trainee Guide For IoT Engineers
Trainee Guide For IoT Engineers
HCIA-IoT
ISSUE: 2.5
and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.
All other trademarks and trade names mentioned in this document are the property of their respective
holders.
Notice
The purchased products, services and features are stipulated by the contract made between Huawei and
the customer. All or part of the products, services and features described in this document may not be
within the purchase scope or the usage scope. Unless otherwise specified in the contract, all statements,
information, and recommendations in this document are provided "AS IS" without warranties,
guarantees or representations of any kind, either express or implied.
The information in this document is subject to change without notice. Every effort has been made in the
preparation of this document to ensure accuracy of the contents, but all statements, information, and
recommendations in this document do not constitute a warranty of any kind, express or implied.
Website: http://e.huawei.com
Overview
Driven by the global informatization tide, China's computer industry has developed
rapidly in recent years. Various emerging technologies have become increasingly mature.
The Internet of Things (IoT) has become an integral part of our lives. Things like smart
watches, smart bands, vending machines, and smart vehicles are all powered by IoT
technology.
Many traditional industries, such as electric power and transportation, are also leveraging
IoT technology. In addition, IoT is being used together with emerging technologies such
as artificial intelligence (AI) to form AIoT, which has become popular. Whether you are
from an ICT industry or a traditional one, learning and understanding IoT technology is
an important means to innovate solutions.
HCIA-IoT V2.5 trains and certifies engineers to develop end-to-end IoT services based on
the Huawei IoT solution architecture.
Description
This guide is used together with the HCIA-IoT V2.5 courses. It supplements course slides
and adds related knowledge points.
This guide is divided into 13 chapters corresponding to the 13 courses slides that are
based on the IoT architecture. The following is a summary of each chapter:
Chapter 1 describes the concept and development history of the IoT, layers of the IoT
architecture, and Huawei's IoT solution.
Chapter 2 describes IoT industry applications and solutions, covering smart city,
smart campus, smart grid, IoV, and industrial IoT scenarios. It also describes the
difficulties facing each industry and the transformation and benefits brought by IoT
technology. In addition, it explores the combination of the IoT with six emerging
technologies and describes the development trends of the IoT industry.
Chapter 3 describes the security challenges faced by the IoT industry, and introduces
Huawei's IoT security solutions and related applications.
Chapter 4 describes common network communications technologies of the IoT based
on the solutions described in chapter 2.
Chapter 5 describes key technologies and corresponding solutions of the widely used
NB-IoT communications technology in the IoT field.
Chapter 6 describes the popular communication technology 5G, including its
development process, core technologies, application scenarios, and commercial
solutions.
Chapter 7 describes difficulties and challenges faced by IoT gateways in industrial
scenarios, edge computing, and mesh networking.
Trainee Guide for IoT Engineers Page 4
Contents
4.2.1.3 ZigBee......................................................................................................................................................................... 37
4.2.2.2 3G................................................................................................................................................................................. 39
4.2.2.3 4G................................................................................................................................................................................. 39
4.2.2.4 5G................................................................................................................................................................................. 40
Since the advent of the Internet, people have become closer to each other. The IoT
connects everything. In the era of information explosion, what we see on the Internet can
be described as data. We can say that the IoT is actually a data service technology. To
build such an IoT world, the connected devices need to be smart enough to understand
our needs and provide us with more intelligent services.
The IoT architecture consists of four layers: application, platform, network, and sensing.
The sensing layer is the layer of things. It contains various types of sensors, chipsets, and
modules. This layer is used to collect data, process signals, and communicate with and
send data to the platform layer using a communications module.
The network layer is equivalent to a communications medium between the sensing layer
and the platform layer. We can use a wireless network, such as GPRS, NB-IoT, or 4G, or
use wired access, such as gateways, to transmit data to the platform layer.
The platform layer is responsible for storing, using, and maintaining the data. We can use
the obtained data for data processing and other operations.
The application layer is oriented to customers. It is responsible for presenting the
collected data specifically.
and platforms of partners in the industry, greatly shortening the development time of the
IoT industry.
Trainee Guide for IoT Engineers Page 16
This chapter describes problems encountered in the domains of smart city, smart campus,
smart grid, IoV, and industrial IoT, and benefits of using IoT technology. It also introduces
the development trends of the IoT based on other popular technologies.
In terms of parking experience, drivers cannot find idle parking spaces because it is
difficult to obtain parking space details. It is also difficult to find cars in parking lots. For
example, you park your car in the large parking lot of a shopping mall, but when you
finish shopping and head back to your car, you cannot find it. Congestion at the
entrances and exits of parking lots during peak hours is also a problem. These are the
parking problems we may encounter.
Street lamp issues also exist in cities. Currently, most street lamps in cities are controlled
by time-based rules. When the sky is almost dark, street lamps are turned on. When the
sun comes out in the morning, street lamps are turned off. However, the time when the
sky turns dark varies seasonally. Lights come on too early in the summer and too late in
the winter. In these cases, street lamps controlled by time waste electricity.
There are also special cases, for example, solar eclipses. Although a solar eclipse occurs in
the daytime, the sky is as dark as at night. Street lamps controlled by time cannot be
turned on for emergencies. Problems also occur when street lamps are faulty and need to
be repaired. Maintenance is often performed in the morning. When street lamps are not
turned on in the morning, maintenance personnel need to check them one by one to
locate faulty ones, which is time- and labor-consuming. If maintenance personnel do not
perform maintenance in time, faults may not be detected. If a technology can be used to
monitor the running status of each street lamp in real time and report an error once a
street lamp becomes faulty, maintenance will be more convenient.
Energy conservation is a problem, too. For example, in the second half of the night, there
are fewer vehicles on the road. Leaving street lamps on is a waste of energy. A relatively
intelligent system is required to automatically detect pedestrians or vehicles on the road
and adjust the brightness of street lamps.
The next problem is the revenue of lamp pole resources. There used to be many utility
poles on the road, but now they can hardly be seen. This forces us to seek more revenue
from rare pole position resources. For example, we can install surveillance cameras and
5G base stations on street lamp poles. We can also install charging piles for new energy
vehicles under street lamp poles. In this way, we can maximize the utilization of pole
position resources. These are the street lamp problems that we may encounter.
Firefighting management also has problems. In our cities, firefighting is still an issue that
we need to pay attention to, because fires can cause great damage to our personal and
public property. Small public areas in cities are the most prone to fires. Why? First, these
areas are small and things are placed haphazardly. Flammable materials are likely to be
dangerously placed. Second, in older places, electric cables are aged. Cable aging is a
more serious threat in old restaurants, because they use more electricity. In addition,
electricity piracy is severe in these places, which increases fire risks. To sum up, fire
hazards are prominent, fire facilities are weak, and fire warnings are not responsive.
Manhole cover management is also an obvious problem in cities. There are a large
number of manhole covers, which belong to different bureaus, such as water,
communications, and gas bureaus. Therefore, quantity and ownership issues make
managing these manhole covers difficult. Which bureau is responsible for managing
these manhole covers? How can they manage a large quantity of manhole covers?
Another problem is theft and loss. Manholes with missing covers pose a serious safety
risk to drivers and pedestrians. In addition, the sewage pipes under manhole covers may
contain toxic gas, which can float upwards from manholes with missing covers, posing
Trainee Guide for IoT Engineers Page 18
additional public health and safety risks. Manhole cover management is a significant
issue that requires the coordination of multiple bureaus.
Similarly, there are problems with sanitation management in cities. We can roughly
divide the problems into four directions: outdated, low, disordered, and slow. First, the
sanitation bureau does not collect information about public garbage bins on the road.
The management mode of regular clearing is outdated. Second, sanitation is mainly
managed by people. Human factors seriously impede sanitation management, causing
problems such as command and dispatch difficulties. Third, sanitation bureaus are often
averse to using new technologies. They are still using conventional methods to manage
urban sanitation. The sanitation industry lacks innovation and develops slowly.
2.1.2 Solutions
Various problems in different aspects of city management hinder the development of
cities. City managers need to find better ways to solve these problems. Huawei has
designed a comprehensive smart city solution to solve problems related to transportation,
parking, street lamps, firefighting, manhole covers, and sanitation.
The smart city solution corresponds to the architecture of the IoT. At the sensing layer,
there are a large number of IoT devices, such as surveillance cameras on roads, gateways
that control various sensors, and low-power consumption devices such as electricity
meters and water meters. We can select the most appropriate network technologies for
different IoT devices. For example, we can use the wireless 2G, 3G, 4G or NB-IoT or wired
network to connect devices to the IoT platform. After the devices are managed on the IoT
platform, data can be uploaded to the platform database and analyzed to solve
problems. At the top are the solutions for different smart city applications.
The advantages of the smart city solution lie in three aspects: lowering the development
threshold of IoT applications, reducing the development difficulty for developers, and
shortening the incubation time of the entire IoT city ecosystem. In this way, a smart city
ecosystem can be quickly implemented. The platform can aggregate information from all
aspects of cities and provide more convenient services for comprehensive city
management. For devices and networks, this solution adapts devices and standards used
and provides a unified management model for city managers, avoiding fragmented
access of IoT applications to the platform.
Detailed solutions to some of the problems described earlier are provided. The first is the
intelligent transportation solution. This solution uses application systems such as e-Police
and signal control to control traffic in real time. It uses sensors such as cameras on roads
to remotely manage city roads and relieve traffic pressure. In addition, it uses electronic
and automatic patrolling methods to handle vehicles violating traffic laws and
regulations, thereby reducing congestion caused by the handling of traffic violations,
reducing the time spent on roads, and reducing pollution.
The smart parking solution is similar to the smart city solution. The IoT devices used in
the smart parking solution are geomagnetic vehicle detectors. A geomagnetic vehicle
detector can be placed or buried under each parking space. The detector can detect the
change in the geomagnetic field to determine whether a vehicle is parked. If these
devices are connected to the Internet, they can also tell drivers where there are idle
parking spaces. In addition to detection, they can be used as collectors of parking
information. The wireless technology NB-IoT is used to connect devices to the platform
Trainee Guide for IoT Engineers Page 19
because NB-IoT applies to low power wide coverage scenarios. The smart parking
solution not only obtains information of many parking lots, but also enables drivers to
use self-service charging, reducing parking management costs.
In the smart street lamp solution, smart street lamp control devices, including various
sensing components such as photosensitive sensors, are deployed at the sensing layer. At
the network layer, a wide range of street lamps are connected to the Internet through a
carrier's wireless WANs or a self-established mesh network such as ZigBee. Then, the
information is collected to the platform, and the platform interconnects with the public
cloud to manage and centrally monitor resources. As mentioned above, street lamps
occupy rare pole position resources in cities. In addition to being used for lighting, street
lamp poles can also be used for other purposes.
In the smart firefighting solution, intelligent smoke sensors are used. Smoke sensors can
automatically report alarms when a fire occurs, helping us control fires on time. This
solution uses networks such as NB-IoT to transmit data, so the data can be uploaded to
the platform for processing. This solution also uses applications such as alarm handling,
remote muting, device self-check, and fire prevention linkage for fire management.
In the smart manhole cover solution, sensors such as accelerometers are installed under
manhole covers to monitor manhole data. These sensors are triggered when the manhole
cover is moved. When manhole covers are taken away, toxic gases in the sewers may
float up to the street. Therefore, gas detection sensors need to be placed near manhole
covers. The smart manhole cover solution is similar to the smart street lamp solution. It
can monitor a large number of manhole covers and implement intelligent O&M.
The last solution is the smart sanitation solution. This solution manages sanitation
personnel, vehicles, and garbage collection in real time. It supervises the working time,
routes, fuel consumption, and water spraying of sanitation vehicles, the status of garbage
bins, and the tracking of garbage collection in real time. In addition, real-time visualized
supervision refines sanitation management, standardizes operations, and makes appraisal
intelligent, making sanitation work orderly, effective, and controllable.
The first common problem that campuses meet is visitor management problem. Let's
take Huawei as an example. After arriving at a Huawei campus, visitors need to register
and obtain visitor cards at a guardhouse and wait for employees to accompany them.
This is time-consuming. 6,300 working days are estimated to be wasted in a year.
Similarly, employees need to swipe their cards at entrances and register when they forget
their cards. This wastes 7,800 working days in a year. Intelligent management and
control methods are urgently needed to help Huawei save labor costs.
Power is wasted in traditional campuses because lighting, fresh air, and air conditioning
systems are managed and controlled by facilities and property management personnel.
Electricity is wasted whenever someone forgets to turn off the lights or the air-
conditioner, or when someone turns on a light during the daytime instead of opening
curtains to let in sunlight. Power consumption accounts for about 60% of the total
operational cost of Huawei's campuses.
The preceding problems can be categorized into three major types. The first is high
operational costs of traditional campuses. The second is traditional campuses are mainly
managed by people. The last is poor employee satisfaction with campus services due to
the lack of a well-developed management system to coordinate various parts. Due to
lack of intelligent management, problems can only be resolved reactively after they
occur.
2.2.2 Solutions
To solve these problems, Huawei has designed an overall solution for campuses. The
overall architecture of the solution is divided into three parts. At the sensing layer are
various devices in smart campuses. The devices transmit data to the management
platform. The platform processes and analyzes the data and uploads it to the cloud to
provide services for users.
For visitor management, a visitor can make a reservation in advance. The visitor will then
receive an SMS containing a verification code. The visitor can show the verification code
to a security guard and obtain a temporary pass to visit the campus. In this way, the
visitor can save a lot of time.
As we mentioned, energy costs account for nearly 60% of the total cost. Therefore,
energy control is an important part of campus management. In this regard, Huawei's
solution is divided into four parts: power generation, distribution, utilization, and
management. In a smart campus, in addition to the mains, the solution uses PV to
generate more power. This method not only saves costs but also is environmentally
friendly. In terms of power distribution, the solution uses uninterruptible power supply
(UPS) to achieve a balanced power supply during peak and off-peak hours, thereby
reducing power costs.
For power utilization, the solution uses sensors to monitor environmental data. For
example, sensors can first check whether there are people in the room. If there are, the
lights and air conditioner are turned on. Then, sensors can check the temperature and
humidity and adjust the air conditioner to control the temperature and humidity. At the
same time, the solution can use smart meters to check overall energy usage and control
energy use. Last, in terms of power management, the solution can analyze the uploaded
data and design an appropriate solution to manage and control energy. This improves
energy utilization and reduces operational costs.
Trainee Guide for IoT Engineers Page 21
The major difference between a smart grid and a traditional grid is that a smart grid
establishes bidirectional information flows between power generation and consumption.
In a traditional power grid, only electric power is transmitted between power distribution
centers and users, and no information is exchanged. In a smart grid, this situation is
transformed. In addition to power transmission between power distribution centers and
users, information and data is also transmitted. Scheduling centers support intelligent,
real-time scheduling. They can schedule resources in each step of the power supply
process in real time, building an intelligent grid. In addition, new energy supplies and
services can be accessed to build green grids. For example, clean energy such as solar and
wind energy is used at the power generation side and new services such as charging piles
and electric vehicles are provided at the power consumption side. With these new energy
supplies and services, smart grids have evolved into a global energy Internet. Non-
renewable power generation, such as thermal power generation, will be gradually
replaced by renewable power generation. Global energy data will be exchanged on this
energy Internet to maximize resource utilization.
2.3.2 Solutions
We are gradually moving towards smart grids. Huawei's smart grid solution is called AMI.
AMI is short for Advanced Metering Infrastructure. The AMI solution can solve the pain
points of electric power companies. Smart metering replaces manual metering, improving
metering efficiency and accuracy and reducing metering costs. In addition, the accurate
data sent back by smart metering can be used to estimate the power consumption status
of each area or even each home. The subsequent power generation can be arranged
purposefully, the power consumption of users can be analyzed, and energy-saving
solutions can be provided for users.
To build fully connected grids, in addition to transmitting electric power, this solution
also needs to transmit data flows. Fully connected grids mean that all devices used in the
power transportation process are centrally managed and data generated by these devices
is uploaded to the cloud. The cloud centrally schedules the operation of the entire power
system. In addition, different new technologies are used in production, management, and
marketing of power grids, thereby building fully connected power grids that connect
numerous devices and feature high security, low latency, wide coverage, and low power
consumption.
drivers identify road situations and drive cars automatically, driving experiences will be
greatly improved.
There are also some value-added services, such as insurance. The traditional vehicle
insurance pricing model is based on vehicles, that is, calculating premiums based on the
number of claims customers have made. But this mode is unreasonable. There is usually
only a small difference between the premiums of people with good driving habits and
those with bad driving habits. Vehicle insurance premiums should be calculated based on
drivers instead of vehicles. The premiums should be determined based on people's driving
habits.
2.4.2 Solutions
The technology that can solve the preceding problems is the IoV. IoV uses in-vehicle
devices and wireless communications technologies to utilize all vehicle information on
the information network platform and implement different functions. IoV is part of the
IoT. First, it has in-vehicle devices at the sensing layer. In addition, it uses wireless
communications technologies to transmit vehicle data to the platform for analysis. The
platform provides the data to applications for analysis and function implementation.
In addition, the IoV in the future will have edge computing features. Vehicles in the IoV
will be intelligent and can control the distances between them and other vehicles to
reduce accidents, regardless of whether other vehicles are intelligent or not. Vehicles in
the IoV can communicate with each other to improve traffic efficiency.
When discussing the IoV, we have to mention V2X, which is also called the vehicle-road
cooperation solution. It integrates digital technologies such as cloud, IoT, AI, and 5G to
implement efficient coordination between pedestrians, vehicles, roads, and clouds.
A vehicle is regarded as a device like a mobile phone or a computer. It senses all things
on the road, including other vehicles, pedestrians, roadside infrastructure, and networks
for information exchange, that is, V2V, V2P, V2I, and V2N.
In addition to the V2X, another concept to share with you is the Digital Road
Infrastructure Service (DRIS). The DRIS does not differ greatly from the V2X. The slight
difference between the two is that V2X focuses more on vehicles and the intelligence that
can be achieved by them, whereas DRIS focuses on a variety of roadside devices. DRIS
includes services on the cloud side and the edge side. DRIS on the cloud side provides
data analysis and collaboration with the edge side on the cloud platform. DRIS on the
edge side provides real-time service processing capabilities related to edge computing,
such as sensor data access and road event identification. The goal of DRIS is to connect
multiple roadside sensors to implement digital sensing of roads and provide useful traffic
information to traffic participants.
The development of the IoV is divided into three phases. The first phase is to meet the
requirements of entertainment and navigation. In this phase, vehicles are connected to
the Internet so drivers can listen to music online and obtain road information. The
navigation system can update road information in real time. In the second phase, IoV
pays more attention to vehicle status and collect information such as fault detection, fuel
consumption, and mileage. In the third phase, IoV can analyze surrounding environment
information through sensors installed on vehicles to achieve automated driving.
Currently, the development of the IoV industry is in the second phase and is moving
towards the third phase.
Trainee Guide for IoT Engineers Page 24
2.5.2 Solutions
How can we achieve full connectivity? We need to use various emerging ICT technologies.
First, we need to make the devices at the sensing layer intelligent. Devices using multiple
different communications protocols can be connected and communicate with each other,
thereby achieving collaborative operation between them.
In addition, networks need to meet the requirements of connections in large quantities
and in different scenarios. In the same industrial scenario, devices in different
environments or in different applications have different requirements for networks. For
example, when we control precision mechanical devices, we need networks with low
latency and high reliability. For video surveillance applications, networks must provide
high bandwidth. For metering applications, the network rate can be low and the network
cost must be low. All these devices are used in the same industrial scenario. Therefore,
we hope that networks can connect all these devices.
After the requirements of devices and networks are met, we need to process the collected
data to maximize data value. In this way, we can achieve intelligent coordination and
linkage between devices and full connectivity.
Based on the preceding ICT technologies, Huawei designs an overall industrial IoT
solution. Like other IoT solutions in the industry, the Industrial IoT solution is also divided
into four layers. At the sensing layer, various devices are used in the industrial field. At
the network layer, wired and wireless access modes are used, for example, Ethernet or
industrial IoT gateway. Most devices in the industrial field are huge and cannot be
moved. Therefore, wired connections are used to ensure the stability of data
transmission. Wireless connections will be gradually used to make the industrial IoT more
flexible.
The platform layer provides capabilities such as device access, device management, and
device data processing. It analyzes the data collected by devices, and transfers the
processing results to various applications at the application layer for display.
The industrial IoT solution has typical applications. The first is production visualization,
which is important in the industrial IoT. Production visualization means that data
collected by the platform is displayed in graphics or other easy-to-understand modes. It
can convert the data into a production management execution process and decision-
making basis that are easy to understand.
For the industry, production visualization can improve the production reliability of
factories and help enterprises better control equipment in the production process,
thereby allowing factories and enterprises to control costs more easily. In addition, it
provides valuable experience capital for product update, iteration, and development. For
plant managers and decision makers, production visualization is a comprehensive
decision-making tool that helps them better understand where problems occur, increase
production output, and reduce costs.
Different parts in industrial production applications, for example, process flow, process
operation efficiency, and production data sorting, can be presented in a visualized
manner.
The second application is asset locating. Asset locating is a common application in
campus and industrial scenarios, because warehouses are used to store assets in campus
and industrial scenarios. It is important to make the best use of every item in a
Trainee Guide for IoT Engineers Page 26
warehouse. We need to be able to locate the items easily and know their validity periods.
That's where asset locating and tracking comes in. Asset locating can be used in
campuses and industrial scenarios to help managers locate the assets that need to be
used.
In industrial scenarios, all transport vehicles or machine tools can also be located. The
location of a transport vehicle can be displayed on the platform and the shortest
transport path can be planned for the transport vehicle. Some industrial valuables also
need to be located. When these valuables are taken out of certain areas, the platform
can report alarms to supervisors.
How are locating and tracking performed? First, tags are attached to all objects to be
located. These tags contain wireless communications chips. Positioning base stations send
signals to the tags to determine the locations of the objects. In addition, different devices
are classified into the high-precision positioning scenario and low-precision positioning
scenario according to their application scenarios. For example, devices that do not need
to be moved frequently adopt low-precision positioning, and devices that often need to
be moved adopt high-precision positioning. The location information is reported to the
IoT platform and used in various applications, such as optimization of production
resource usage, and foolproof management and authentication of personnel.
In addition, we use technologies such as big data, cloud computing, and AI. These
technologies and the IoT are related to each other. Take the human body as an example.
The IoT is mainly responsible for data collection. It functions like sensory organs of the
human body, such as the eyes, ears, and nose. We obtain data using big data technology.
We store the data in the cloud, which uses cloud technology. At the same time, AI
technology, which similar to the brain, is responsible for decision-making and control.
The relationship between big data, cloud computing, IoT, and AI is as inseparable as
different parts of the human body.
Among the four technologies above, AI and IoT are closely related. The combination of AI
and IoT is called AIoT. The data collected by the IoT can be used by AI, and a massive
volume of data is what AI needs most. The two complement each other and can provide
us with more intelligent services. Currently, the implementation process of most IoT
projects integrates AI. We are in increasing need of AI-based decision-making. AIoT
technology is no longer optional. In the future, IoT solutions that do not integrate AI
capabilities will become increasingly less competitive.
In addition to the new technologies mentioned above, other new technologies, such as
quantum computing, can be combined with the IoT. Although quantum computing
cannot replace traditional computing in the short term, its prospects are bright. It is the
future of computing, solving many problems that traditional computing cannot, such as
database search, large sample simulation, and machine learning. As an analogy,
traditional computing is a car, and quantum computing is a rocket. Although the rocket is
very fast, it cannot be widely used in our daily lives. Only when our living standards reach
a certain level can rockets be used as a means of transportation. The same is true with
quantum computing. It can only become widely used when we have developed other
technologies to a level similar to that of quantum computing.
There is also digital twin technology, which will be described in subsequent chapters.
Simply put, it is a simulation process of obtaining data using sensors and physical models.
It completes mapping in a virtual space to reflect the full lifecycle management of the
corresponding entity. We can use data to present our products in the virtual world. For
example, currently, O&M personnel cannot monitor the status of a high-speed train after
it leaves the station. Digital twin technology can construct a model on a computer based
on the train data, so that O&M personnel can view the running status of the train.
Digital twin technology can also be used in applications such as industrial IoT and smart
city to build models for better O&M management.
Trainee Guide for IoT Engineers Page 28
Security has always been the basis of technological development. Only by ensuring the
security of a technology can we develop it well. This is especially true for the IoT field,
because all things are connected in the IoT world. IoT development will be restricted if
we cannot resolve security issues.
This chapter describes problems faced by the IoT, Huawei's solutions to IoT security
problems, and typical applications of these solutions.
DDoS, short for Distributed Denial of Service, is a common type of network attack.
Hackers control a large number of devices to attack a server, causing it to break down.
As a result, users cannot use the server. The DDoS attack in the US was launched using a
botnet composed of IoT devices.
In this DDoS attack incident, hackers controlled some IoT devices like network cameras,
video recorders, and routers. This incident paralyzed the Internet and caused network
outages in several cities in the US.
In the IoT field, security is a common issue that deserves our attention. Examining these
three events, we can see that IoT security issues often occur on the device and network
sides. Actually, they also occur on the platform and application sides. IoT security issues
are classified into four types based on the IoT architecture. In terms of industry
categories, security threats mainly include LPWA security threats and IoV security threats.
IoT security threats form a negative triangle model, and most of threats are on the device
side, where we lack effective measures to defend against security issues. IoT devices are
vulnerable to physical damage, for example, being forcibly dismantled. Because of power
supply restrictions, it is not possible to run an advanced encryption system on IoT devices.
Due to these two reasons, IoT security threats often target devices.
Moreover, as network technologies become increasingly advanced, more network attack
technologies are emerging, and the requirements for the capabilities of network attackers
are becoming lower. In the past, attackers needed to master a lot of knowledge to launch
network attacks. Nowadays, attackers can launch attacks with limited communications
technologies.
IoT security events increase alongside the development of the IoT. This requires us to
resolve IoT security issues while developing the IoT.
Figure 3-1 IoT security solution architecture (see the Appendix for a
reference image)
Figure 3-1 illustrates the framework of the Huawei IoT security solution, which can be
summarized as 3T+1M. In the 3T+1M framework, T stands for technology, and M stands
for maintenance. The 3T indicates the different security technologies at the sensing layer,
network layer, and platform layer in the IoT architecture, and 1M means unified security
O&M at each layer. Through this framework, we can summarize Huawei's solutions in
the IoT security field.
The Huawei IoT security solution is focused on LPWA and IoV, since most IoT security
issues arise from these two fields. Of course, Huawei also supports other fields.
Huawei provides security applications for the three layers of the IoT architecture, from
the sensing layer and network layer to the platform layer. Huawei also provides
compliance at the bottom. Huawei has different security measures at different layers. It
adheres to the concepts of device authentication, pipe monitoring, and cloud analysis. It
uses device trustworthiness and identity authentication, pipe monitoring awareness, and
security policy orchestration and collaboration in the cloud to build a service-oriented IoT
security solution for customers. Huawei also uses unified security O&M and management
across all layers to ensure normal collaboration between layers.
The following describes the security measures used at each layer. FOTA, short for
firmware over-the-air, allows remote device upgrades. At the sensing layer, FOTA digital
signatures ensure the validity and integrity of firmware upgrades. The integrity of
upgrade packages is checked to ensure that the firmware version in use is secure and
reliable.
At the network layer, the transmission network may be intruded and data may be
tampered with. To protect the network and data, network transmission channels such as
L2PT and IPsec are used. In addition, the platform detects upstream data for abnormal
behavior and events in a timely manner.
At the platform layer, authentication is used to ensure that each device connected to the
platform and all uploaded data are secure. E2E authentication and transmission security
are carried out on the platform side. As shown in Figure 3-1, different devices or
personnel, such as gateways or devices at the sensing layer, development or O&M
personnel, and applications, must all be authenticated and authorized through different
networks and portals when they access the cloud platform. This eventually ensures secure
E2E data transmission of the IoT. The IoT platform may suffer from DDoS attacks.
Therefore, methods must be used to defend against DDoS attacks. The method is to
classify messages from devices by different priorities. If a DDoS attack occurs, the server
can then determine how to process messages from different devices according to the
congestion level. For example, when a server is in a low congestion state, it allows low-
priority devices to access the network later or discards low-priority packets. This ensures
that high-priority data can be sent to the server for normal communication.
Trainee Guide for IoT Engineers Page 31
Figure 4-1 RS-232 port diagram (see the Appendix for a reference image)
Anyone who has done embedded development before is likely familiar with RS-232. This
port is found on the rear of legacy desktop computers. RS-232 supports one-to-one
communications over short distances (less than 20 meters). RS-485 is an upgraded
version. RS-485 supports one-to-many transmission. Such a bus supports a maximum of
128 transceivers. The transmission rate and communication distance are also greatly
improved.
Table 4-1 lists the differences between RS-232 and RS-485. The first difference lies in the
transmission mode. RS-232 uses unbalanced transmission, which is single-ended
communications. RS-485 uses balanced transmission, which is differential transmission.
The second difference lies in the transmission distance. RS-232 is suitable for
communications between local devices, and the transmission distance is less than 20 m in
general. The transmission distance of RS-485 ranges from tens of meters to thousands of
Trainee Guide for IoT Engineers Page 34
meters. Third, RS-232 allows only one-to-one communication, whereas RS-485 allows up
to 128 transceivers on the bus.
USB is also widely used in the IoT. There are four common types of USB ports: Type-A,
Type-B, Micro-B, and Type-C, as shown in Figure 4-2.
4.1.4 M-Bus
M-Bus is short for Meter Bus. It is designed for remote metering and often used by
electricity, water, and gas meters. This technology is not common in China, but it is
widely used in Europe. M-Bus can power devices remotely without installing power
cables. Meters using M-Bus will not be affected in the case of a power outage at home.
4.1.5 PLC
PLC is short for power line communication. PLC transmits data on an electrical power
cable. How does it work? First, high-frequency signals that carry data are loaded onto the
current and transmitted through the wire. At the receiver end, an adapter separates the
high-frequency signals from the current and sends the signals to a computer.
PLC can be used only in near-end scenarios where the voltage does not change, since
high-frequency signals loaded onto the wire will disappear when the voltage on the wire
changes. In metering scenarios, data is loaded on the cable and uploaded to the
management terminals, which connect to base stations and upload the data to the
database through switches and servers. This technology is applied to data transmission
Trainee Guide for IoT Engineers Page 35
Table 4-2 lists the comparison of wired communications technologies. Most of the wired
communications technologies are used in industrial sectors and public utilities. In the IoT
field, moveable devices account for a large proportion. Therefore, there are relatively few
application scenarios for wired communications. More data is transmitted wirelessly.
The latest Bluetooth, 5.0, supports a transmission rate of up to 3 Mbit/s and can transmit
over about 300 meters. This technology can be divided into Bluetooth Basic
Rate/Enhanced Data Rate (BR/EDR) and Bluetooth low energy (BLE). The BR/EDR type
supports only point-to-point communications, whereas BLE supports point-to-point,
broadcast, mesh, and other modes of communications. The BLE type is mainly used in IoT
scenarios for data transmission among multiple devices.
4.2.1.2 Wi-Fi
Wi-Fi is widely used for daily Internet access at home or in the office. Wi-Fi usually uses
the 2.4 GHz and 5 GHz frequency bands to provide different services for different devices.
Wi-Fi has a longer range than earlier versions of Bluetooth. It also supports one-to-many
connections and fast transmission. However, it has poor security and stability. You likely
have experience with this in your daily life, for example, video freezing when watching a
video, and long delay when playing games. The delay may be 20 ms to 30 ms, or even
100 ms to 200 ms. Wi-Fi also uses a lot of power.
Similar to Bluetooth, there is a next generation Wi-Fi standard, Wi-Fi 6. This version
supports a transmission rate of 9.6 Gbit/s and the latency is kept down to 20 ms.
4.2.1.3 ZigBee
ZigBee features low consumption. Figure 4-5 shows the ZigBee working mode. As shown
in Figure 4-4, Wi-Fi devices can only be connected to access points (APs) or master
concentrators. However, ZigBee is different. ZigBee allows for direct data transmission
between devices.
ZigBee networking is easy. If the AP in a Wi-Fi network is faulty, the entire network
breaks down. This will not happen in a ZigBee network, because each device on a ZigBee
network functions as a relay. If a device fails, the network adjusts on the fly to find
another device that can take its place. The name ZigBee is derived from the waggle
dance that honey bees perform through movements such as zigzagging to communicate
the location of pollen. In other words, the waggle dance can be thought of as their
communications network. This is similar to easy networking of ZigBee.
The cost of a ZigBee module is as low as US$2. The transmission rate is 20 to 250 kbit/s,
which is very low when compared with Wi-Fi. However, ZigBee lacks robust compatibility
and is difficult to maintain.
4.2.1.4 Z-Wave
Z-Wave is similar to ZigBee, but Z-Wave is more reliable. In addition, Z-Wave is not open-
source. Z-Wave chips can be obtained only from Sigma Designs. In the initial design, the
Z-Wave technology was intended for wireless control of smart home appliances. Data
was transmitted in a small data format and the transmission rate of 40 kbit/s was
adequate. When the technology was first utilized, a rate of 9.6 kbit/s was used.
Compared with other radio technologies of the same type, Z-Wave uses a lower
transmission frequency, can transmit over longer distances, and is priced competitively.
Trainee Guide for IoT Engineers Page 38
868.42 MHz
Frequency 2.4 GHz 868 MHz/915 (Europe)
2.4 GHz
band 5 GHz MHz, 2.4 GHz 908.42 MHz
(USA)
802.11b: 11
Mbit/s
802.11g: 54
1–3 Mbit/s Mbit/s
868 MHz: 20 kbit/s
Transmission (24 Mbit/s 802.11n: 600 9.6 kbit/s or 40
915 MHz: 40 kbit/s
rate over 802.11 Mbit/s kbit/s
links) 2.4 GHz: 250 kbit/s
802.11ac: 1
Gbit/s
802.11ax: 9.6
Gbit/s
Data
exchange
between
WLAN, high-
nearby nodes
speed Internet Home automation, Smart home
such as a
Typical access at building appliance,
mouse,
application home and automation, and monitoring and
wireless
other indoor remote control control
headset,
areas
mobile
device, and
computer
4.2.2.2 3G
A 3G network provides a higher data transmission rate, which can reach hundreds of
kbit/s. Over a 3G network, users can make video calls and watch TV programs using
mobile phones. In China, three major operators use different standards for 3G networks
separately: CDMA2000, WCDMA, and TD-SCDMA. HSPA+, the latest WCDMA technology
from China Unicom, supports a maximum transmission rate of 42 Mbit/s. So far, HSPA+
is still used in most video data transmission fields.
4.2.2.3 4G
HSPA+ in 3G can be used to transmit video data, but 4G is required to transmit HD video.
Although 5G is now popular, most of our mobile phones still use 4G. Over a 4G network,
users can use phones to stream video and listen to music.
In the 4G network, LTE-Cat is a different level of 4G. Cat stands for category. Each
different category refers to a different transmission rate level supported by the device
when accessing a 4G network. Each level specifies the maximum transmission rate that
the device can reach. In the early days of 4G, devices were category 4, but now most of
the 4G devices are category 6. Module chips for devices at different levels have different
prices too.
1 10 1 5
2 50 2 25
3 100 2 50
4 150 2 50
5 300 4 75
6 300 2 or 4 50
7 300 2 or 4 150
8 1200 8 600
9 450 2 or 4 50
Trainee Guide for IoT Engineers Page 40
Downlink Rate
Level DL-MIMO Uplink Rate (Mbit/s)
(Mbit/s)
10 450 2 or 4 100
In the IoT field, category 1 UEs are widely used because some devices demand high
network rates, although most devices use LPWA. UE category 4 or later provides a higher
rate, but its modules are too expensive for IoT devices. It is more cost-effective to use UE
category 1.
UE category 1 supports a downlink rate of up to 10 Mbit/s, enabling IoT devices with
lower power consumption and costs to connect to LTE networks. LTE operators around
the world deploy LTE networks based on 3GPP Release 8 or later. As such, operators can
simply reconfigure parameters to permit the access of UE category 1 without needing to
upgrade the networks.
4.2.2.4 5G
5G is the fifth-generation mobile communications network. 5G's theoretical maximum
transmission rate can reach 10 Gbit/s. Three 5G application scenarios are defined: eMBB,
which is defined by a rate of up to 10 Gbit/s; mMTC, which refers to support for up to 1
million connections per square kilometer; uRLLC, for when latency has to be kept down
to 1 ms. Among the three scenarios, eMBB is closely related to users because it can
provide high-bandwidth Internet access rates. The other two scenarios are closely related
to the IoT. Massive connections and ultra-low latency can help improve the service
capability of the IoT in many applications.
2G 3G 4G 5G
Authorized Authorized
Authorized Authorized
frequency frequency band:
Frequency frequency band frequency band
band
band (mainly 900 MHz (1800–2600 C-band
(mainly 900
and 1800 MHz) MHz) mmWave
MHz)
10 Gbit/s
TD-SCDMA: 2.8 (Balong 5000
Downlink chips
GSM: 9.6 Mbit/s
kbit/s Category 6/7: support a
Transmission CDMA2000: 3.1
300 Mbit/s downlink rate
rate GPRS: 56-114 Mbit/s
kbit/s Category 9/10: of 4.6 Gbit/s
WCDMA: 14.4
450 Mbit/s and an uplink
Mbit/s
rate of 2.5
Gbit/s)
Trainee Guide for IoT Engineers Page 41
2G 3G 4G 5G
Table 4-5 lists the comparison of the cellular mobile communications technologies.
Technology continues to evolve, and the evolution from 2G networks to 5G networks
means higher frequency band (from 900 MHz to millimeter wave) and transmission rate.
Different technologies have different applications. We should choose the most
appropriate network, not necessarily the best one. For example, there is no need to use
more advanced networks for POS terminals or vending machines, since 2G and 3G can
fully support their functions. 5G is relatively expensive, so it is not necessarily the best
match for all solutions.
4.2.3.2 LoRa
LoRa is short for long range. Different from Sigfox, LoRa is maintained and managed by
the LoRa Alliance. The LoRa technology was developed by Semtech. With joint efforts of
the LoRa Alliance, Semtech developed LoRaWAN, which is applied to the LPWA field.
LoRaWAN is an ultra-long-range wireless transmissions solution based on spread
spectrum technology. LoRaWAN mainly runs on unlicensed frequency bands. The
application of LoRa includes automatic meter reading, smart home appliance, building
automation, wireless warning and security systems, industrial monitoring and control,
and remote irrigation systems.
4.2.3.3 NB-IoT
NB-IoT was first proposed by Huawei and Vodafone. Later, companies such as Ericsson
and Qualcomm joined its development. NB-IoT takes advantages of existing cellular
networks. It only needs about 180 kHz of bandwidth and can be directly deployed in the
existing cellular networks, greatly reducing the cost for operators.
4.2.3.4 eMTC
eMTC was proposed by Ericsson based on 4G networks. It is mainly used in IoT scenarios
that require deep coverage and a considerable number of connections. Compared with
NB-IoT, eMTC has a higher rate, but provides less coverage and requires more power. It
Trainee Guide for IoT Engineers Page 42
Sub-GHz Sub-GHz
Sub-GHz Mainly sub-GHz
Frequency unlicensed licensed
unlicensed licensed
band frequency frequency
frequency band frequency band
band band
Transmission
100 bit/s 0.3–5 kbit/s < 250 kbit/s < 1 Mbit/s
rate
Typical
1–50 km 1–20 km 1–20 km 2 km
distance
Smart home
Smart Water meters, Shared
appliances, smart
agriculture, parking, pet bicycles, pet
electricity meters,
Typical intelligent tracking, garbage collars, POS
mobile healthcare,
application building, and disposal, smoke terminals, and
remote
logistics alarm, and retail smart
monitoring, and
tracking devices elevators
retail
Table 4-6 lists the comparison of LPWA technologies. Sigfox and LoRa run on the sub-
GHz unlicensed frequency band. Sub-GHz means that the frequency is below 1 GHz,
which mainly refers to the frequency band from 27 MHz to 960 MHz. Sub-GHz is an ideal
choice for long-range, low-power-consumption communications. Why? Given the same
power, higher frequencies are less able to pass through physical obstacles. Devices in
LPWA scenarios, such as electric meters or water meters, are often placed deep
underground, so penetration is important. They need to run on lower frequency bands.
As listed in Table 4-6, NB-IoT mainly runs on Sub-GHz licensed frequency bands, but
some NB-IoT networks run on frequency bands higher than 1 GHz. The specific reasons
will be explained in the following sections.
The differences between LoRa and NB-IoT are as follows:
Different lineups
LoRa is developed by Semtech (an American company), and NB-IoT is a standard
formulated by 3GPP. The upstream and downstream industry chains of LoRa are
basically controlled by Semtech. However, the entire communications industry is
engaged in the NB-IoT upstream and downstream industry chains. For example,
Huawei, Qualcomm, Samsung, and MediaTek are all working on NB-IoT chip
modules.
Different frequency bands
Trainee Guide for IoT Engineers Page 43
NB-IoT uses licensed frequency bands, whereas LoRa uses unlicensed frequency
bands.
In China, licensed frequency bands are authorized by the Ministry of Industry and
Information Technology (MIIT). Only authorized operators can use these frequency
bands.
Unlicensed frequency bands can be used by anybody. If individuals or enterprises use
the LoRa working frequency band for other purposes, severe interference will be
caused to LoRa devices in that region, even making the entire LoRa network
unavailable.
NB-IoT networks can provide better quality over LoRa networks.
Enterprises need to build their own LoRa networks, whereas NB-IoT networks are
built by operators and ready for use.
Operators do not operate LoRa networks. If enterprises want to use LoRa networks,
they need to purchase a full set of network operations software and hardware, such
as base stations, network devices, and servers, and build and operate networks by
themselves.
Currently, the three major operators in China have deployed base stations and NB-
IoT networks. Enterprises only need to purchase NB-IoT SIM cards from operators
and insert them into devices equipped with NB-IoT modules.
What are the advantages of LoRa?
LoRa does not show any advantage for 90% of enterprises. However, if enterprises
want to use the IoT in rural areas, remote mountainous areas, and independent
factories (such as smart farms and smart factories), where there are no NB-IoT
networks, they need to build LoRa networks by themselves.
In addition, large enterprises or governments who are very sensitive to data security
might prefer to build their own LoRa networks and maintain them by themselves.
These are the major differences between NB-IoT and LoRa.
All these three types of wireless communications technologies can be applied to the IoT.
How do we select the right technology for a given application?
Figure 4-6 illustrates which technology works best for different scenarios.
The two axes in Figure 4-6 are the transmission rate and transmission distance, which
correspond to major requirements for different IoT scenarios. There are three types of
data rates: high, medium, and low. For example, Internet of Vehicles (IoV) requires a high
data rate; smart logistics and vehicle management require a medium data rate; metering
requires very little data transmission. These scenarios can be further divided based on the
transmission distances that must be supported to get six types of networks. As mentioned
above, the most appropriate technology should be selected for a specific application. In
addition to the transmission distance and transmission rate, costs must be considered, in
order to maximize the return on investment.
Trainee Guide for IoT Engineers Page 45
This chapter describes the key technologies and features of NB-IoT, as well as some NB-
IoT solutions. IoT scenarios are different from the traditional Internet used by mobile
phones and computers. What are the characteristics of IoT in wireless communications
scenarios? First, IoT devices at the sensing layer send and receive data packets that are
small and transmitted infrequently. Some of them may send less than 10 bits of data in
an entire day. Second, these devices need to conserve power, even during
communications, in order to prolong their service life.
To sum up, small packets are occasionally transmitted through passive devices. The
communications network needs to run on very little power and cover a wide area, which
is why we call this an "LPWA" or "low power wide area" scenario.
In LPWA scenarios, the most popular technology is NB-IoT. NB-IoT is widely used in
public utilities and city management. It is important to learn NB-IoT technical details and
solutions.
This chapter describes the development, key technologies, and solutions of NB-IoT.
As shown in Figure 5-1, during the selection of LPWA technologies, most operators
choose to deploy NB-IoT networks first and then add an eMTC network later. This is
because they would rather deploy a network that provides entirely new functions. Before
the emergence of NB-IoT, there were no LPWA networks, and there were no networks
specially designed for IoT devices.
The operator networks we are using today are designed for human beings. To facilitate
communications between human beings, these networks provide voice communications
and are always being optimized for higher and higher transmission rates. In contrast, NB-
IoT networks provide very slow transmission rates. User experience would be poor if we
tried to use NB-IoT networks for our mobile phones. However, NB-IoT networks are
suitable for devices, since these devices are typically widely separated, need to run on
limited power, and do not need to transmit much data. As for the eMTC network, it has a
higher rate than NB-IoT and supports voice communications. It is similar to a 2G network
that way. eMTC can be used to replace an old 2G network, but it is not as urgent as NB-
IoT. This is why most operators choose to deploy NB-IoT first.
A lower frequency band means stronger penetration. As shown in Figure 5-2, most
operators deploy networks on the sub-GHz frequency band, on frequencies ranging from
700 MHz to 900 MHz. A few operators like China Unicom deploy their networks on the
1800 MHz band. NB-IoT networks are mainly deployed on the sub-GHz frequency band,
but not all of them.
NB-IoT networks are based on 4G LTE networks. Operators can upgrade some 4G base
stations to function as NB-IoT base stations. The case is different for China Unicom,
because China Unicom's 4G base stations were upgraded from 3G base stations. They can
directly upgrade their 3G 1800 MHz base stations to support NB-IoT, saving a lot of
money. This is why China Unicom choose to deploy NB-IoT networks on the 1800 MHz
frequency band.
Figure 5-3 shows the application of NB-IoT technologies. NB-IoT involves many fields like
water meters, gas meters, street lamps, and smart parking. The following sections
describe some NB-IoT solutions.
The following sections describe the four key features of NB-IoT and the technologies
involved in these features.
The second is guard band deployment. NB-IoT can be deployed on the guard band of the
existing 4G frequency band, taking advantage of existing idle resources.
The third is in-band deployment, where NB-IoT is directly deployed in the 4G frequency
band. In a 4G network, the frequency and time domains are divided into small resource
blocks. NB-IoT is designed to be fully compatible with 4G. The bandwidth of each small
resource block in 4G is 180 kHz. That is why the system bandwidth of NB-IoT was
designed to be 180 kHz. Regardless of what deployment mode is used, NB-IoT does not
depend on signal resources of any system.
Trainee Guide for IoT Engineers Page 50
This is one of the reasons for the ultra-low costs. Due to technical limitations, NB-IoT
cannot be deployed in the in-band or guard band of the LTE system. Therefore,
standalone deployment is more popular recently.
However, this waiting uses a lot of power. DRX addresses this issue. The blue pulse shown
in Figure 5-7 indicates that the mobile phone is being paged. After each paging message
is received, the mobile phone enters the IDLE state and disables the receiver, like a
student taking brief a nap in class. In DRX mode, the interval between each paging is
called a DRX period, which can be 1.28s, 2.56s, 5.12s, or 10.24s.
Trainee Guide for IoT Engineers Page 51
DRX still uses too much power for IoT devices. Even if you only make calls or send SMS
messages on a mobile phone, you still need to charge once every day in most cases, or at
least every couple of days. IoT devices need to last several years or even more than a
decade on a single charge. That why we developed eDRX based on DRX.
As shown in Figure 5-8, eDRX introduced a paging time window (PTW). Within each
PTW, an IoT device makes three paging attempts, at the same interval as the DRX period.
After these three paging attempts, the device enters sleep mode for a long time. This
period is called an eDRX cycle. An eDRX cycle can be up to 2.92 hours long. Operators
can set the eDRX cycle based on the actual situation of IoT devices and required data.
However, even eDRX does not save enough power for some IoT devices, which is why
PSM was introduced. With PSM, the sleep period can be up to 310 hours, or about 13
days, as illustrated in Figure 5-9. With PSM, if the service platform at the application
layer delivers commands to a device, the device will not receive these commands
immediately. These commands are temporarily stored on the IoT platform and will be
issued after the device wakes up from sleep mode.
These three modes correspond to different IoT scenario requirements. For example, DRX
is good for shared bicycles, because users do not want to wait for as long as 5 minutes
before a bicycle automatically unlocks. A 5-minute waiting duration is required if eDRX is
used. But eDRX is fine for scenarios such as logistics monitoring, because goods do not
need to be monitored in real time during transport. You only need to check their location
at certain intervals. PSM is good for water or electricity meters, since you only need to
check the data on these devices about twice a month. NB-IoT low power consumption
modes are closely related to scenarios. Developers need to select the power saving modes
for different application scenarios.
does NB-IoT expand its coverage? In the downlink, NB-IoT enhances reliability through
repeated transmission for more gain.
In the uplink, NB-IoT also increases the gain through repeated transmission, just like it
does in the downlink. In addition, NB-IoT uses a single subcarrier for transmission, a 15
kHz subcarrier. This is different from that of 4G. In 4G, 180 kHz is required at least for
every transmission. So for any given amount of transmission power, you get better gain
with narrowband, as shown in Figure 5-10. This is one of the reasons why NB-IoT can
provide such wide coverage.
Figure 5-11 NB-IoT solution architecture (see the Appendix for a reference
image)
Trainee Guide for IoT Engineers Page 53
The following section describes some NB-IoT applications from the perspective of the
overall architecture of this solution.
Figure 5-12 Smart parking (see the Appendix for a reference image)
The first case is smart parking, which is mentioned in the previous section too. Broadly
speaking, there are two main types of parking: roadside parking and indoor parking.
Roadside or indoor, there are all sorts of issues. For example, it is difficult to locate
parking spots due to poor signal. The price of vehicle detectors is driven up by the
expensive communications modules they require, and they require a lot of electricity to
keep running.
NB-IoT eliminates the need for these expensive communications modules. These NB-IoT
modules and base stations can also be used for a range of other applications as well.
With NB-IoT, all of the devices in the entire city can be connected to the same network
for easier maintenance and management. Thanks to the low power consumption of NB-
IoT, the device batteries last a long time.
Trainee Guide for IoT Engineers Page 54
Figure 5-13 Shared bikes (see the Appendix for a reference image)
The next use case is shared bikes. Before NB-IoT locks were introduced, bike sharing
relied on mechanical locks and GPRS electronic locks. These two types of locks are not
easy to use. Mechanical locks rely on static passwords are used. A bicycle can be used by
anyone who knows the password. This is also true for GPRS electronic locks, which are
expensive and difficult to bill for use, resulting in poor user experience.
To achieve low power consumption and reduce costs, Huawei uses NB-IoT for
communications.
Figure 5-14 Smart street lamps (see the Appendix for a reference image)
NB-IoT applications are also popular in smart street lamps and smart meter reading.
Similar to the previous two cases, NB-IoT reduces the cost of solutions, improves use
efficiency, and unifies management for enterprises or companies.
Figure 5-15 Smart meter reading (see the Appendix for a reference image)
Trainee Guide for IoT Engineers Page 55
5G standards were first introduced in Release 15, which was released in 2017, covering
the wireless technical framework, physical layer coding, multi-antenna system, and uplink
and downlink network architecture. The following version, Release 16, introduced further
enhancements to 5G standards, marking the complete version of 5G.
The evolution of 5G technology can be broken into two parts. The first part is evolution
from LTE, specifically from LTE-Advanced to LTE-Advanced Pro, which in simple terms
describes evolution from 4.5G to 5G. The second part is new 5G technology, which is we
believe that 5G standards start from Release 15. These standards cover two aspects: the
first being LTE Advanced Pro evolution and EPC evolution, and the second being 5G new
radio and 5G core network.
Another advantage of 5G is that there is one unified global standard. In the 3G era, the
top three standards commonly used in China are different. China Telecom uses
CDMA2000, China Unicom uses WCDMA, and China Mobile uses TD-SCDMA. So, how
does that affect us? Well, when you buy a new mobile phone, you need to be aware of
whether the phone is SIM locked to a certain operator, otherwise other network SIM
cards may be incompatible with the phone.
SIM-locked phones are typically cheaper than unlocked phones, so you need to be aware
of this when buying a new phone.
The 4G era saw only two standards: LTE TDD and LTE FDD. And now in the 5G era we
only have one, making mobile communications even more open and convenient.
Trainee Guide for IoT Engineers Page 57
Figure 6-2 National strategies for 5G (see the Appendix for a reference
image)
Next, let us see how important 5G technologies are at the national level. As shown in
Figure 6-2, many countries are aware of the benefits that 5G can bring to their countries,
with many countries labeling 5G and AI as core strategies for achieving digitalization.
Statistics indicate that the most effective way to stimulate GDP growth is to invest more
in ICT. According to research conducted by Huawei, 20% of ICT investment will bring 1%
of GDP growth, highlighting the remarkable power of ICT investment. A large number of
countries have realized the importance of 5G and AI, and regard them as key national
development strategies. 5G construction is valuable for both operators and national
infrastructure.
During the first half of 2018 there were only five 5G networks in the world, but this
number increased to 30 in the second half of the same year, proving the rapid growth
rate of 5G networks. By the end of 2019, China had 130,000 domestic 5G base stations,
delivering 5G coverage across cities such as Beijing, Shanghai, and Guangzhou. This
shows that countries and even the world attach great importance to 5G development.
Although rolling out 5G networks is a major step, it is meaningless without compatible
products to go with it. In February 2018, Huawei released the world's first 5G commercial
chip, Balong 5G 01, and corresponding UE, Huawei 5G CPE, which has an actual downlink
rate of 2 Gbit/s. The Balong chip was then used in Huawei's maiden 5G foldable mobile
phone, the Huawei Mate X. Following this, Huawei integrated 5G modules into the
system-on-a-chip and launched Kirin 980, Kirin 990, and other chips, as well as releasing
its latest 5G mobile phone, Huawei Mate 40.
million connections per square kilometer. The slicing-based network architecture is also a
5G capability, which will be detailed in a subsequent sub-section.
Figure 6-3 5G networking mode (see the Appendix for a reference image)
tasked with transmitting the signaling messages and the user plane is tasked with
transmitting the service data actually used by users. With the two planes separated,
software management and upgrade are greatly simplified for operators as they can easily
locate problems on the control or user plane. The second technical feature is mobile edge
computing (MEC). MEC enables cloud computing capabilities at the edge of a cellular
network and is implemented by a cloud server running specific tasks. That is, MEC
transfers some services of the core network onto the cloud server at the edge of the
cellular network. This mechanism effectively reduces the bidirectional transmission time
on the network, minimizing latency and saving bandwidth.
The third is network function reconstruction. Cloud computing is enabled across the
entire 5G network, and the network architecture and functions of each part are
replanned. In this sense, function reconstruction is a feature of the 5G network. The
fourth and final feature is network slicing. As mentioned above, a network slice is an E2E
network that can be flexibly customized to meet specific requirements.
6.3.2 mMTC
By leveraging Massive Machine-Type Communications (mMTC), which is a dimension of
IoT for massive connections, 5G can achieve 1 million connections per square kilometer.
Meanwhile, the standardization of NB-IoT has seen 5G branch out from merely carrying
high-speed and low-latency services as before. Though further development is not much
for massive connection technologies, the recognition of NB-IoT is an important step to
incorporating massive connections into 5G.
6.3.3 URLLC
Ultra-reliable low-latency communication (URLLC) underpins ultra-low latency services,
as previously discussed, such as autonomous driving and remote surgery. Why is low
latency important for these services? A high latency in autonomous driving, even if it is
only dozens of milliseconds, can result in a long braking distance and even catastrophes.
Trainee Guide for IoT Engineers Page 62
Here are some examples in practice. If a car drives at 80 km/h, the braking distance is
about 333 cm under a 3G network latency of 100 ms. Likewise, the braking distance is
about 167 cm under a 4G network latency of 50 ms, but with a 5G network latency of 1
ms the braking distance is dramatically cut to merely 3.33 cm.
Therefore, low latency is crucial for applications that require high security. In a remote
surgery setting, the surgeon must obtain and monitor vital data of the patient
immediately.
Figure 6-5 Time required for hitting 500 million B2C subscribers
In the B2C market, 5G has a considerable number of potential subscribers. Within this
field, high-quality networks are in high demand among consumers and are key to a
carrier's success. Two networking options are available: non-standalone (NSA) and
standalone (SA). As SA networking is able to deliver a superior 5G experience, carriers are
able to both appeal to and fulfill consumer demands for high-quality networks.
On top of this, 5G is well equipped to carry a large number of new services, including
new types of videos, live broadcast, and online gaming. These services open up new
experiences for consumers, satisfying the demand for abundant content.
Apart from the large quantity of subscribers and new services, the final key is flexible
tailored tariff plans. Consumers are most concerned with charging standards and tariffs,
so by offering tailored tariff plans (for example, carriers can charge live broadcast
subscribers for high uplink bandwidth and gaming subscribers for low latency and high
downlink bandwidth) to consumers, carriers can ensure consumers are getting the service
that they want.
Huawei provides its own VR and AR services. You can use VR glasses to connect to a VR
cloud platform over a high-speed 5G network. This technology enables carriers to provide
their own VR services, including VR music, VR gaming, and VR live broadcast, that are
centrally managed by a cloud platform. This solution aims to help carriers develop fully
converged video services and build core competitiveness to swing with the video era.
Industry CPE for remote control in the wireless private line scenario provides connection
stability in complex environments. Moreover, backed by 5G's low latency, the CPE can
remotely control high-precision instruments. In the live broadcast scenario, Huawei
launched the video codec with built-in 5G modules, making 5G backpacks lighter and
battery life longer. This improves the convenience of shooting HD videos outdoors for
journalists.
Figure 6-8 FWA solution (see the Appendix for a reference image)
Trainee Guide for IoT Engineers Page 66
This chapter describes the technical details of gateways for fixed network scenarios in the
industrial field. The industrial field has always been critical for the IoT sector as it is
closely related to production with many "things" involved in the process — for example,
machines and robotic arms. In addition, the environments are harsher than in other IoT
scenarios and require the use of a wide range of complex and demanding devices. As
such, diverse interfaces need to be adapted to the industrial field. With the development
of global industrial automation, industrial IoT devices that meet the preceding
requirements play an increasingly pivotal role.
The industrial IoT gateway provides a protocol conversion function. There are many
protocols in the industrial field — covering all sectors — so conversion on the IoT
gateway is needed before data is transmitted.
Data
Data
In the past, data is processed as shown in Figure 7-2 where data is generated on devices
and uploaded to gateways. However, the gateways did not have any computing
capabilities and could only function as a transmission device to upload data to the cloud
for processing. Now, as gateways themselves have computing capabilities, they can
locally process some data with low requirements, instead of transmitting it to the central
node. After the data is processed, the gateway still needs to notify the central node that
the data has been processed.
Edge computing is an open platform that integrates connection, computing, storage,
control, and application functions. Compared to the architecture of IoT, the architecture
of edge computing can be divided into four domains: device, network, data, and
application. Although edge computing is located between the sensing layer and network
layer, the edge computing architecture can be divided into four layers to provide
capabilities similar to the four-layer architecture of IoT.
Trainee Guide for IoT Engineers Page 69
Cloud
application
Application domain
Data domain
Data analysis and presentation
Data
Data aggregation and interoperability security
Network domain
Massive connections and automatic O&M Cyber
Real-time connection security
Device domain
Device
Operating system
security
The two layers between the device and gateway in the IoT architecture are further
divided into four layers. In the hierarchical edge computing architecture, the device
domain is equivalent to the sensing layer; the network domain refers to the network
between devices and gateways; the data domain refers to gateways, which process data
in a similar way to an IoT platform; and the application domain refers to the diverse
applications in edge computing.
Basic features:
Easy implementation with heavy installation and maintenance workloads and high
costs: Typically, twisted pairs or coaxial cables are used for transmission. Each site
needs to be directly connected to a central network device, which requires a large
number of cables, resulting in heavy workloads for installation and maintenance.
Easy node expansion and movement: To add a node, you only need to connect the
node to the hub or switch using a cable. To move a node, you only need to move the
node to the new position as needed.
Easy fault diagnosis and isolation: If one node is faulty, connections of the other
nodes are not affected, and the faulty node can be removed as needed.
Potential bottleneck on the central node and low distributed processing capability of
each site: The load of the central node is heavy, which may cause a bottleneck. When
the central node fails, the entire network is affected.
Advantages:
Simple network structure streamlines management, maintenance, and
commissioning.
Easy control enables the quick addition or removal of sites.
Centralized management simplifies service provisioning and network reconfiguration.
Direct connection of each node to the central node facilitates fault diagnosis and
isolation.
Disadvantages:
Low line utilization: A line is used only by the central node and the node on the line.
Trainee Guide for IoT Engineers Page 71
Heavy workload of the central node: When the central node is faulty, the entire
network fails, imposing stringent requirements on the reliability and redundancy of
the central node.
High installation and maintenance costs: A large number of cables are needed.
The ring topology is widely used on LANs. On a ring network, packets of data travel from
one device to the next until they reach the destination. This structure eliminates the
dependency on a central node for communication between end users.
The ring topology has the following characteristics:
Information flows towards a fixed direction on a network with only one path
between two nodes, simplifying path selection.
The control software is simple and easy to use.
Information is transmitted over the nodes on the ring network sequentially. If there
are a large number of intermediate nodes, the information transmission rate will be
lowered, increasing the network response time.
The ring network is closed, making expansions difficult.
A faulty node will cause the entire network to break down, resulting in low reliability.
Faults on branch nodes are hard to locate.
WLAN
WLAN
WLAN
Optical fiber
WLAN WLAN
WLAN
Optical fiber
Optical fiber
This chapter builds on the previous chapter and describes the application of home IoT
gateways in home scenarios. Although many smart home appliances exist on the market,
a smart device is needed to control all these devices, and this is known as a smart home
gateway. A smart home gateway is the heart of a smart home and is also the unified
egress of smart devices, which highlights its importance in the home.
Figure 8-1 Basic broadband service and diverse home service (see the
Appendix for a reference image)
In the future, a smart home gateway, or ONT (as shown in Figure 8-2) will act as the
home terminal, whereby almost all home devices will connect to the Internet through the
smart ONT, creating a complete smart home system. This in turn will form a mesh
network. It lacks a control center, so all devices can be intelligently connected to other
devices to exchange data. All future networks are expected to evolve towards this kind of
structure.
Figure 8-2 Smart home service (see the Appendix for a reference image)
The smartphone revolution in 2006 not only boosted the development of wireless
communications technologies, but also kick started the development of home networks.
As phones became smarter and tablets were introduced to consumers, a home terminal
was needed to connect them all to the Internet. On top of this, fixed broadband
gradually evolved to fiber access, meaning smart ONTs not only provide high-speed
Internet, but also lay the foundation for the development of other home services.
In many existing home networks, many rooms require a router to be installed inside each
room to achieve strong Wi-Fi coverage. Even then, the coverage distance is limited and
unlikely to be picked up by a room on a different floor. To overcome this problem,
Huawei proposes these 3 solutions, as shown in Figure 8-3.
The first and simplest solution is to install the primary router in a large room, such as the
living room, to ensure strong signal coverage. Another solution is to install PLC modems
in the bedrooms to extend Wi-Fi coverage through the power lines, while a third solution
is to install a wireless repeater on the staircase.
The smart ONT also offers intelligent interconnection. Future homes are shifting more
towards smart automation in an effort to cut energy consumption and bring greater
convenience to our lives. A smart ONT is needed to connect all of these appliances and
devices, regardless of their transmission standards, and provide a platform to control
them in one place. On top of this, we also need a cloud platform that will allow us to
control the devices through a smartphone, even when we outside the home.
And last but not least is intelligent O&M. Through the cloud platform, we can control,
run, and maintain home devices at a click.
The smart ONT (the core) provides two open capabilities - open home and open elastic
pipe - that comprise the advanced structure of this technology, helping make smart
homes a reality. Open home capabilities include smart Wi-Fi coverage and ZigBee & Z-
Wave, enabling ubiquitous connectivity, while open pipe capabilities that extend flexible
pipes from operators to homes, integrating applications and building a platform.
Trainee Guide for IoT Engineers Page 77
Figure 8-4 Smart home solution (see the Appendix for a reference image)
This section describes Huawei's smart home solution, which can be summarized as
openness. This solution provides a collaborative platform for all partners across various
industries to build a new industry environment.
In terms of hardware, Huawei cooperates with smart device vendors and chip module
vendors to research home devices, and ensures home devices are connected to smart
gateways. Regarding the IoT platform, Huawei opens up capabilities and works with
cloud service providers to build an intelligent cloud platform. As for service applications,
Huawei works with app developers and service providers to build a joint app framework
for smart homes. At the upper layer, Huawei offers global operators a smart home
solution that delivers network assurance for cloud, pipes, and devices.
Figure 8-4 illustrates the Huawei smart home solution architecture. Using the open mode
of the smart gateway is similar to using a PC. A PC usually has standard physical PCI
slots. To begin with, install an operating system and hardware to the PC, and install drive
to the PC to control the hardware. Then install applications if required.
The operating system of the PC acts as the brain, interacting with different software,
hardware, and applications. Huawei uses this same structure to develop the smart home
system, where physical PCI slots are replaced with wireless protocols such as ZigBee and
Wi-Fi. The smart gateway acts as the brain, interacting with different software, hardware,
and applications.
A smart gateway has three types of plug-ins (drivers, agents, and applications).
A driver is a program that must be installed to enable communication between
installed hardware and the operating system. Huawei uses OSGi (open-source
specifications defined by the ITU) instead of drivers, and this functions as a Java
virtual machine. By simply writing a driver specifically for a device in Java to the
OSGi, a third party can operate their own device, achieving all-round device
integration.
Trainee Guide for IoT Engineers Page 78
Agents are another type of plug-in that drive the cloud. An agent offers an
environment for operators and third parties to share capabilities (for example, facial
recognition) that can be used by partners to develop applications.
The final type of plug-ins is applications.
Operators can set up a store for gateway apps, providing a one-stop place for consumers
to download the required drivers, agents, and apps to get services operational. With the
necessary drivers and devices, agents can invoke cloud-based capabilities, while apps
implement home services.
In short, Huawei OpenLife solution imports and integrates hardware vendors and
service/application content for operators.
to different brands, it is difficult to use one app or platform to control all of these
devices. Huawei HiLink Access offers a solution to this issue.
As shown in Figure 8-6, three different connection methods are available for the HiLink
ecosystem. For electrical appliances that lack communication capabilities, HiLink modules
can be embedded into the appliances to connect to the platform. Similarly, vendors who
have their own platforms may have their own modules. So, if they want to connect to the
Huawei ecosystem, they can burn HiLink SDK to their devices to connect to the platform.
If a consumer purchases products from different companies but wants to connect to the
Huawei ecosystem, they can use HiLink routers to control smart devices and connect
them to the HiLink platform.
The Huawei HiLink platform provides two access modes. One is to connect through
hardware interconnection, so that devices can connect to the Huawei platform through
the HiLink SDK or Huawei LiteOS-based hardware modules. The other option is to
connect through cloud interconnection. We can log in to the HiLink cloud using a
personal account, and connect devices to the HiLink cloud, delivering cloud capabilities to
Huawei compatible devices.
To connect a device to the Huawei HiLink platform, the device must have the Huawei
HiLink Device SDK integrated. The Huawei HiLink Device SDK applies to devices that run
a supported operating system as well as devices that do not have microprocessors but
are directly developed in modules.
The HiLink platform is an open platform, meaning that Huawei provides developers and
consumers with multiple access modes. Developers can leverage these modes for
application and service development, and consumers can access the platform through
multiple methods. This platform offers consumers an environment to connect and control
products belonging to different brands on just one platform.
Trainee Guide for IoT Engineers Page 80
9 IoT Platform
9.1.2 Ecosystem
An ecosystem is a type of business collaboration network developed on the platform
model. It is spontaneous and self-consistent, and has an internal value chain. In an
ecosystem, enterprises use modern information technologies to implement network-like
loose coupling. Similar to the platform model, enterprises in the ecosystem can
collaborate with each other. An ecosystem can reduce transaction costs and share
business opportunities. It also promotes the transfer of the internal value chain between
its members and enables them to contact as many potential partners as possible.
Transaction costs are reduced and more business opportunities emerge as the number of
internal transactions and data flows in the ecosystem increase. To sum up, the value that
an ecosystem brings to every participant is often determined by the total scale of its
system.
The platform model is centered on enterprise-dominated operations, and the ecosystem
is an overall view of network-like collaboration based on the platform model. A platform-
based ecosystem is the product of the platform model as the platform model develops. It
is also the overall view of the value chain formed by multiple platforms that serve
different objects.
The IoT is used in diverse industries. How to integrate the value chain, attract developers,
enrich applications, and expand user groups is the key to realizing the value of the IoT.
Trainee Guide for IoT Engineers Page 81
Figure 9-1 IoT is ushering in industry innovation and transformation (see the
Appendix for a reference image)
The device layer provides IoT Agents that are adaptable to OSs and smart devices
provided by different manufacturers. It is pre-integrated with valuable industry-specific
applications. Table 9-1 describes these devices.
Peripheral/Device Description
generates a signal that can be measured or interpreted, to meet
requirements for data transmission, processing, storage,
recording, and control.
The access layer supports both wireless and wired access. A large number of devices can
be connected. Table 9-2 describes the access layer.
MBB (P-
Wireless wide area network (WWAN)
GW/GGSN)
The device connectivity layer provides unified device access, asset and device
management, and SIM card connectivity management. Table 9-3 describes the device
connectivity layer.
Device Carriers can manage all sensor nodes at the bottom layer, obtain
management information about each node, and implement remote control.
Function Description
Data communications
Device-initiated subscription
User-initiated subscription
Transmission
protocol The IoT platform supports HTTP, MQTT, and CoAP.
adaptation
Lightweight The IoT platform simplifies the authentication process for devices
authentication and applications.
The service enablement layer provides functions such as open API gateways, data
management, and a rule engine. Table 9-4 describes the service enabler layer.
The IoT platform supports multiple types of open APIs and pre-integration of multiple
industry-specific applications, including smart home, IoV, smart metering, and third-party
applications. Table 9-5 describes the application scenarios.
Application Function
The IoT platform connects and manages a large number of devices. It works with other
HUAWEI CLOUD services to quickly build IoT applications. A complete IoT solution
consists of the IoT platform, devices, and applications. Figure 9-5 shows the architecture
of the HUAWEI CLOUD IoT platform.
The IoT platform is located between applications and devices. It hides differences
between device interfaces to enable quick device access. It provides robust capabilities to
help developers quickly construct diverse IoT applications.
Devices can access the platform via FBB, 2G/3G/4G/5G, NB-IoT, and Wi-Fi networks. They
can report service data to the platform using MQTT or LwM2M over CoAP. Devices can
also receive commands from the platform.
Applications call platform APIs for device management, data reporting, command
delivery, and other service scenarios.
Table 9-6 describes the services provided by HUAWEI CLOUD IoT.
Trainee Guide for IoT Engineers Page 88
Application Applications can access the IoT platform and call APIs
integration provided by the platform.
IoT Edge
Other related The IoT platform can work with other IoT services to
services Global SIM build a solution.
Link
Figure 9-6 IoT system based on the HUAWEI CLOUD IoT platform (see the
Appendix for a reference image)
Note: SYN stands for synchronization, Seq stands for sequence, ACK stands for
acknowledgment, and ack stands for acknowledgment sequence.
First handshake:
A client sends a connection request packet to set up a connection with the server. As
stipulated in TCP, a packet segment with SYN=1 cannot carry data and needs to consume
a sequence number. The client generates a random initial sequence number (X), and
includes both SNY=1 and Seq=X in the packet. The client enters the SYN-SENT state.
Second handshake:
The server sends an ACK packet to accept the connection request. The server generates a
random initial sequence number (Y), and includes SYN=1, ACK=1, ack=X+1, and Seq=Y in
the packet. The server enters the SYN_RCVD state.
Third handshake:
The client sends an ACK packet to the server to acknowledge the receipt of the ACK
packet from the server. In this ACK packet, ACK is 1 and ack is Y+1. The TCP connection is
established, and the client enters the ESTABLISHED state.
Necessity of the three-way handshake:
After the client sends the first connection request packet, the server may fail to receive
the packet on time due to network congestion. When it finally receives the packet, which
is invalid, the server still sends an ACK packet to the client and waits for subsequent
requests from the client. If a two-way handshake is used, the client ignores the ACK
packet sent by the server, but the server continues to wait for requests from the client.
This wastes resources. When a three-way handshake is used, the server disconnects from
the client when it cannot receive the ACK packet from the client.
MQTT
Trainee Guide for IoT Engineers Page 91
One responsibility of the broker is to keep the session data of all clients that have
persistent sessions, including subscribed and missed messages.
Another responsibility is client authentication and authorization.
CoAP
Constrained Application Protocol (CoAP) is designed for resource-limited devices (such as
sensor nodes) and networks (such as NB-IoT and LoRa). CoAP is based on HTTP. CoAP
uses a request/response model, in which the client initiates a request and the server
responds to the request. CoAP optimizes the packet length and offers reliable
communications to address the issues that may occur on HTTP in restricted conditions.
In immediate delivery mode, all commands are directly delivered to devices. In delayed
delivery mode, commands are delivered to devices in serial mode after the devices go
online or report data to the IoT platform. Cached commands are delivered to devices one
by one based on the time they are cached. Figure 9-11 shows the status transition of a
device command over the entire lifecycle.
For an NB-IoT device in delayed delivery mode, if the platform does not
EXPIRED deliver a command to the device within a specific time, the command
status is EXPIRED. The expiration time is subject to the value of
expireTime carried in the command request. If expireTime is not carried,
Trainee Guide for IoT Engineers Page 96
Status Description
the default value (48 hours) is used.
This status does not exist for an NB-IoT device in immediate delivery
mode.
This status does not exist for an MQTT device.
If the platform does not receive a response within 180 seconds after
delivering a command to an NB-IoT device, the command status is
TIMEOUT TIMEOUT.
This status does not exist for an MQTT device.
You can use command delivery to remotely control devices. Command delivery is
applicable when you need to perform an operation on a large number of devices or on a
device that is located in a remote place.
Figure 9-12 shows the triggers and actions of device linkage rules.
Tag management Used by applications to manage tags. Only device tags are
APIs supported.
Device CA
certificate Used by applications to manage device CA certificates, which are
management used for device access authentication.
APIs
Group
Used by applications to manage groups and group members.
management
Groups are used to manage devices by group.
APIs
Product
Used by applications to manage products. Products created using
management
APIs do not include codecs.
APIs
Device property
Used by applications to query and modify device properties.
APIs
9.3.5.3 Subscribe/Push
An application can send a subscription request to the IoT platform through an API to
notify the platform of the types of notifications to receive, for example, a change in
device service details, device data, or device registration.
When device details are updated on the IoT platform, the IoT platform pushes messages
to the application over HTTP/HTTPS.
In any given push message, the IoT platform functions as a client and the application
functions as the server. The IoT platform calls the API of the application and pushes
messages to the application.
In this case, if the subscription callback URL is an HTTPS address, you need to upload the
CA certificate to the IoT platform. The CA certificate is provided by the application.
Trainee Guide for IoT Engineers Page 101
Figure 9-17 Why data analysis is required (see the Appendix for a reference
image)
Trainee Guide for IoT Engineers Page 102
Figure 9-18 IoT data characteristics (see the Appendix for a reference
image)
Asset model
Building an asset model is the basis for understanding IoT data. Building an asset
model is to establish relationships between things, between things and space, and
between things and people, so that data can be understood in context. An asset
model is the mapping of assets in the physical world to the digital world. Data on
both sides is synchronized in quasi-real time to implement digital twins. IoT Analytics
abstracts data reported by different devices based on the asset model and converts
the data into a format that can be understood by services. See Figure 9-19.
Figure 9-19 Asset model (see the Appendix for a reference image)
Unlike the solution of forwarding device data to the general data analysis service, IoT
Analytics is designed for IoT scenarios.
IoT Analytics integrates, archives, and analyzes data from IoT Device Access and
third-party services. The analysis engine understands data based on asset models
and supports real-time, time series, and offline analysis. In addition to data analysis,
IoT Analytics provides industry analysis suites for industries like smart logistics and
new-energy vehicles. The analyzed data can be used by the AI platform or provided
to third-party applications or other HUAWEI CLOUD services. Figure 9-22 shows the
architecture of IoT Analytics.
Trainee Guide for IoT Engineers Page 104
Figure 9-22 IoT Analytics structure (see the Appendix for a reference image)
Offline analysis
IoT data developers can quickly build an IoT data lake. They can use standard SQL
jobs to develop IoT data analytics tasks and easily process TBs or even EBs of IoT
data.
The data lake supports cost-effective, massive data storage. It can seamlessly
connect to IoT Device Access for instant access to a wealth of IoT data sources. It can
also preprocess IoT data based on the IoT asset models to prepare for data analysis.
With the highly available and horizontally expandable framework of big data, big
data analytics uses the in-memory computing model, directed acyclic graph (DAG)
scheduling framework, and efficient optimizer to deliver a comprehensive
performance 100 times higher than that of the traditional MapReduce model.
Developers can complete batch analysis on IoT data with ease.
Standard SQL APIs are provided. IoT data developers do not need to worry about the
deployment and O&M of the SQL processing engine. They only need to focus on IoT
services, develop analysis jobs, and configure job scheduling policies. See Figure 9-23.
Trainee Guide for IoT Engineers Page 105
Real-time analysis
Real-time analysis on IoT data is provided based on the big data stream computing
engine. To reduce skill requirements for stream analysis job development, IoT
Analytics provides graphical stream orchestration so you can quickly develop and roll
out services by dragging and dropping components.
Graphical stream orchestration: Visual stream orchestration IDE allows you to define
IoT stream analysis jobs through drag-and-drop operations without writing SQL
statements.
IoT stream orchestration operators: Based on typical IoT application scenarios,
common operators are encapsulated, such as data access, data filtering, and data
conversion. See Figure 9-24.
Trainee Guide for IoT Engineers Page 106
Figure 9-24 Real-time analysis (see the Appendix for a reference image)
You can use IoT time series data processing functions, for example, time series data
storage with high compression ratio, efficient time series query, and massive
timeline.
Massive access: hundreds of millions of timelines
Time series storage: columnar storage and dedicated compression algorithms with a
high compression ratio
Efficient query: Time-based multi-dimensional aggregation, and near-real-time
analysis and query
Data visualization: Time series insight tools provided for IoT data analysts to explore
time series data
obtain self-driving instructions. Unstable network signals on the road are a big problem.
Due to poor signals, it may take several seconds for a vehicle to report data to the cloud
and receive an instruction from the cloud. This latency may result in death or injury.
The preceding problems are the pain points of direct cloud-device interconnection. They
can be solved by edge computing.
What can edge computing do in the IoT?
Open ecosystem
Edge computing is a concept. When discussing what it can do, we need to assign it
an entity. In this section, we will use the IoT Edge service provided by the Huawei IoT
platform as the entity. IoT Edge is deployed at the edge close to devices or data
sources to provide real-time services. It integrates network, compute, storage, and
application capabilities to make applications intelligent and data secure. The core
capabilities of IoT Edge can be described from three aspects.
An edge node is a server with independent access and compute functions. It is like
the "cerebellum" of the IoT. IoT Edge does not require a specific physical object. As
long as the hardware meets the requirements, the IoT Edge software package can be
deployed in Docker container mode to support device access, device linkage, and
low-latency local management.
IoT Edge allows users to develop third-party access protocol drivers and deliver them
to edge nodes through the cloud so that devices using these protocols can access the
platform. IoT Edge also allows users to develop and deploy third-party edge
container applications to expand the function of edge nodes. With open hardware,
protocols, and applications, IoT Edge can meet custom requirements in different IoT
scenarios.
Edge-cloud synergy
Although edge nodes have independent computing functions, the value of the
"cerebellum" can be brought into full play only through cooperation with the
"cerebrum". Edge-cloud synergy is the trump card of IoT Edge. IoT Edge provides a
graphical operation interface on the cloud. On this interface, you can manage edge
nodes, and perform unified application deployment, node O&M, and service
management.
Trainee Guide for IoT Engineers Page 110
Figure 9-28 Edge computing features (see the Appendix for a reference
image)
After an edge node is managed, it can work with the cloud to implement layered
service processing. For example, in IoV scenarios, for services that need to be
processed in a timely manner, such as automated driving and V2X, the edge nodes
directly calculate data and return the result. For services that are insensitive to
latency and involve a large amount of data, such as large-screen monitoring and big
data analytics, data is transferred to the cloud for processing. Another example is
campus scenarios where private user data is collected, processed, and stored on the
local node. After being cleaned and summarized, non-private data is uploaded to the
cloud for machine learning and training, so local intelligent algorithms can be
continuously optimized. Layer-based service processing maximizes the value of the
IoT and powers IoE.
The edge and cloud are connected through the network. If the network is faulty, the
edge is disconnected from the cloud. How do we ensure edge services in this case?
IoT Edge provides local autonomy for edge nodes. If the network is abnormal, the
rules and AI models delivered by the cloud can still run properly at the edge to
ensure service continuity. After the network is recovered, the data is synchronized to
the cloud. In addition, the edge node provides a local console, which can be logged
in to without connecting to the network, allowing for management autonomy.
Edge intelligence
The edge can clean data. Specifically, the edge filters, deduplicates, and aggregates
data reported by devices and then reports the data to the cloud. Data cleaning is
applicable to scenarios where data needs to be selectively reported to the cloud to
reduce the bandwidth, storage, and computing resources used.
Filter criteria are used for data filtering. For example, for a filter criterion with
property A greater than 10, all data that meets this criterion is filtered. You can
specify multiple criteria, with the relationship between them set to AND or OR. If the
relationship is AND, the data that meets all the criteria is filtered. If the relationship
is OR, the data that meets any criterion is filtered. If a device continuously reports
messages with duplicate property values, the edge node reports only the first
message to the cloud. This is deduplication. Aggregation means that the edge node
aggregates data reported by each device in a time window (for example, one hour)
into one piece of data. The user can specify the aggregation method for each
property in the data, for example, obtaining the maximum/minimum value, the sum,
and the average. The priorities of the three types of data cleaning rules are as
follows: filtering > deduplication > aggregation. If you set all the three types of rules,
data is filtered, deduplicated, and then aggregated before being reported.
Difficult deployment: IoT devices are installed in different locations, such as on the
top of a building or in a passageway. Cabling and ditch digging are not allowed in
these locations, and wireless connection is required.
Difficulty obtaining cost-effective data plans in foreign countries: If an enterprise
produces IoT devices in country A and sells them in country B, they need to use data
plans of carriers in country B. The negotiation process is time-consuming.
Difficulty changing SIM cards: IoT devices may be deployed in locations covered by
signals from multiple carrier networks. They are expected to use a network with a
better signal without changing SIM cards.
Difficult card management: Enterprises need to connect to multiple carriers around
the world in SIM card management. This poses great challenges to integration.
Solution:
Global SIM Link provides 2G/3G/4G and NB-IoT connections for IoT devices and IoT SIM
card data plans in and outside of China (covering more than 100 countries and regions).
Remote eSIM/vSIM provisioning enables on-demand selection of networks operated by
more than 80 carriers around the world.
9.3.9.2 Reliable
System reliability
The IoT platform is installed and deployed based on HUAWEI CLOUD. The system
reliability includes system cluster and VM reliability, as described in Table 9-10.
Each node in a cluster is equivalent and runs the whole system. Based
on different networking, nodes in a cluster can be expanded as
hardware is expanded.
Full system
cluster The front-end load balancer in the cluster can evenly send user requests
to the IoT platform. Specifically, the load balancer distributes and
schedules user requests based on the corresponding algorithm to
achieve load balancing in a cluster.
Item Description
N+M: used to deploy a group of load-sharing services in multiple VMs.
Network reliability
Table 9-11 describes the network reliability policies of the IoT platform.
1+1 mutual Half of the capacity of each site is reserved for taking over services
backup from the other site.
The number of sites is N. Each site has 1/N idle capacity to take
Pool mode
over services from a faulty site.
Service reliability
Number Phone numbers are shielded when users query user data or export
shielding user lists on the web portal.
Module reliability
Item Description
9.3.9.3 Secure
The IoT platform has its own security strategies, including device, networking, service,
access, data storage, and access security strategies.
The IoT platform provides open security capabilities, including ID authentication,
authorization, and security associations. The security strategies are designed based on
security specifications defined by standards organizations and best practices in the
industry. These specifications include ITU X.805 hierarchy and threat analysis,
oneM2M/ETSI security solutions and risks, 3GPP access security, IETF TLS/DTLS, OWASP
security standards, and STRIDE security threat identification methods. The security
strategies are also designed using the minimum authorization and multi-level protection
principles. See Figure 9-29.
9.3.9.4 Scalable
The IoT platform uses a cloud-based architecture and can be easily deployed on the
cloud platform to provide a variety of services.
Flexible platform deployment: The IoT platform can be flexibly deployed on servers or the
cloud.
Aggregated vertical capabilities: The IoT platform can serve one or more industries.
Compatibility: The IoT platform is compatible with smart devices from different
manufacturers.
Trainee Guide for IoT Engineers Page 114
Modularized services and flexible combination: A single service or multiple services can be
deployed.
9.3.9.5 Open
The IoT platform provides a variety of open APIs, including communication capability,
network capability, and user data APIs. The IoT platform also provides open device
management capabilities and an entrance for end users to access the platform and
perform operations. It provides SDKs so that developers only need to drag and drop SDKs
to implement service logic.
Open APIs: The IoT platform provides a variety of open APIs for third-party application
integration, eliminating repeated development.
Diverse IoT Agents: Agents are provided to adapt to different OSs and hardware.
Pre-integration with high-value industries: The IoT platform provides partners with pre-
integrated high-value industry services, including smart home, IoV, and smart metering.
Open device management: Service providers use a web-service interface to access and
remotely operate devices.
Trainee Guide for IoT Engineers Page 115
Product Manage products, develop product models and codecs, and perform
development online debugging on the IoT Device Access (IoTDA) console.
Development
Carry out development for interconnection between applications and
on the
the platform, including calling APIs, obtaining service data, and
application
managing HTTPS certificates.
side
Development Integrate and interconnect devices with the IoT platform, including
on the connecting devices to the IoT platform, reporting service data to the
device side platform, and processing commands delivered by the platform.
The process of using IoTDA, including product, application, device, and routine
management.
Product development: You can perform development operations on the IoTDA console.
For example, you can create a product or device, develop a product model or codec
online, perform online debugging, carry out self-service testing, and release products.
Trainee Guide for IoT Engineers Page 116
Development on the device side: You can connect devices to the platform by
integrating SDKs or modules, or using native protocols.
Figure 10-1 IoT solution development process based on the IoT platform
(see the Appendix for a reference image)
Figure 10-3 Product model (see the Appendix for a reference image)
On the IoT platform, the product model is the key to device access. It contains the
capabilities and services of a device and the data formats of upstream and downstream
device messages. For example, when a device reports data to the IoT platform, the IoT
platform matches the product model based on keywords of the reported data and verifies
Trainee Guide for IoT Engineers Page 118
the data format. Only data that is matched is saved on the IoT platform. If the reported
data is not matched with the configuration in the product model, the data is considered
invalid and dropped.
Product details:
Product details describe basic information about a device, including the manufacturer ID,
manufacturer name, device type, and protocol. For example, the manufacturer name of a
water meter could be HZYB, the manufacturer ID TestUtf8ManuId, the device type
WaterMeter, and the protocol CoAP.
Service capabilities:
Service capabilities are divided into several services. The properties, commands, and
command parameters of each service are defined in the product model. Take a water
meter as an example. It has multiple capabilities, such as reporting data about the water
flow, alarms, power, and connections, and receiving commands from a server. When
describing the capabilities of a water meter, the profile includes five services, each of
which has its own properties or commands.
Transmission rule Used to define transmission rules for the water meter.
(DeliverySchedule) Commands need to be defined if necessary.
Figure 10-4 Product model example (see the Appendix for a reference
image)
The IoT platform provides multiple methods for developing product models. You can
select one that suits to your needs.
Importing models (preset product models on the platform)
Uploading a profile (offline development)
Importing models in an Excel file
Customizing functions (online development)
10.2.2 Codec
10.2.2.1 Overview
What Is a Codec?
The codec decodes binary data reported by devices into JSON data that can be read by
applications. It also encodes commands in JSON format delivered by applications into
binary data that can be executed by devices.
Why Is a Codec Used?
NB-IoT devices use data in binary or TLV format.
CoAP is used for communications between NB-IoT devices and the IoT platform. The
payload of CoAP messages carries data at the application layer, at which the data type is
defined by the devices. Because NB-IoT devices have high requirements on power
consumption, their application layer data is generally not in JSON format.
Applications do not understand data in binary or TLV format.
How Do We Develop a Codec?
The IoT platform provides three methods for developing codecs. Offline codec
development is complex and time-consuming. Graphical codec development is
recommended.
Graphical development: The codec of a product can be quickly developed in a visualized
manner on the IoTDA console.
Trainee Guide for IoT Engineers Page 120
Figure 10-6 Data reporting process (see the Appendix for a reference image)
After being registered with the IoT platform and powered on, a device can collect and
report data based on the service logic. Data collection and reporting can be triggered by
a schedule or by specific events. Data can be sent to the platform through the following
APIs:
Reporting device messages: A device reports custom data to the platform through
message reporting APIs. The platform does not parse or store the messages reported.
Instead, it forwards the messages to other HUAWEI CLOUD services for storage and
processing based on data forwarding rules. Then, the data is further processed through
the consoles or APIs of the other services.
Raw device data (binary) reporting: A device reports raw code streams through binary
reporting APIs. The platform uses codecs to parse the raw data into data in JSON format
defined by the product model and reports the parsed data to IoTDA for service
processing.
Device property reporting: A device reports property data defined in the product model
through property reporting APIs. The platform parses the data and reports the data to
IoTDA for service processing.
Batch property reporting: A gateway reports data of a batch of devices to the platform at
a time. The platform parses the data and reports the data to IoTDA for service
processing.
In the data reporting process, the codec is used in the following scenarios:
1. Decoding binary data reported by a device into JSON data and sending the data to an
application.
2. Encoding the JSON data returned by an application into binary data and sending the
data to a device.
Trainee Guide for IoT Engineers Page 122
An application delivers a command to the IoT platform. The IoT platform finds the
corresponding codec based on the product information, encodes the command request,
and delivers the command to the device. At the same time, the IoT platform sends a
command status to the application. When the device responds to the command, the IoT
platform changes the command status to Successful or Failed.
Codec is not required and device commands are transparently transmitted. An application
delivers a command to the IoT platform. The IoT platform delivers the command to the
device and returns the execution result.
Figure 10-10 Delayed delivery of MQTT device commands (see the Appendix
for a reference image)
Trainee Guide for IoT Engineers Page 124
An application delivers a command, and the IoT platform writes data to the cache queue
and updates the message status when the device is offline. When the device goes online
and subscribes to messages delivered by a topic, the platform delivers the message and
updates the message status.
Codec example
Figure 10-11 Codec example (see the Appendix for a reference image)
Applications must be authenticated by the IAM service and obtain tokens to integrate
functions such as product and device management.
Trainee Guide for IoT Engineers Page 125
https://iotda.cn-north-4.myhuaweicloud.com/v5/iot/{project_id}/products/{product_id}
Request Methods
The HTTP protocol defines the following request methods that can be used to send a
request to the server:
GET: requests the server to return specific resources.
PUT: requests the server to update specific resources.
POST: requests the server to add resources or perform special operations.
DELETE: requests the server to delete specific resources, for example, objects.
HEAD: same as GET except that the server must return only the response header.
PATCH: requests the server to update partial content of a specific resource. If the
resource does not exist, the PATCH method creates a resource.
For example, in the URI of the API for Querying a Product, the request method is GET.
The request is as follows:
Trainee Guide for IoT Engineers Page 126
GET https://iotda.cn-north-4.myhuaweicloud.com/v5/iot/{project_id}/products/{product_id}
GET https://iotda.cn-north-4.myhuaweicloud.com/v5/iot/{project_id}/products/{product_id}
Content-Type: application/json
X-Auth-Token: ******
POST https://iotda.cn-north-4.myhuaweicloud.com/v5/iot/abab***cdcd/products
Content-Type: application/json
X-Auth-Token: ********
{
"name" : "Thermometer",
"device_type" : "Thermometer",
Trainee Guide for IoT Engineers Page 127
"protocol_type" : "MQTT",
"data_format" : "binary",
"manufacturer_name" : "ABC",
"industry" : "smartCity",
"description" : "this is a thermometer produced by Huawei",
"service_capabilities" : [ {
"service_type" : "temperature",
"service_id" : "temperature",
"description" : "temperature",
"properties" : [ {
"unit" : "centigrade",
"min" : "1",
"method" : "R",
"max" : "100",
"data_type" : "decimal",
"description" : "force",
"step" : 0.1,
"enum_list" : [ "string" ],
"required" : true,
"property_name" : "temperature",
"max_length" : 100
} ],
"commands" : [ {
"command_name" : "reboot",
"responses" : [ {
"response_name" : "ACK",
"paras" : [ {
"unit" : "km/h",
"min" : "1",
"max" : "100",
"para_name" : "force",
"data_type" : "string",
"description" : "force",
"step" : 0.1,
"enum_list" : [ "string" ],
"required" : false,
"max_length" : 100
}]
} ],
"paras" : [ {
"unit" : "km/h",
"min" : "1",
"max" : "100",
"para_name" : "force",
"data_type" : "string",
"description" : "force",
"step" : 0.1,
"enum_list" : [ "string" ],
"required" : false,
"max_length" : 100
}]
} ],
"option" : "Mandatory"
} ],
"app_id" : "jeQDJQZltU8iKgFFoW060F5SGZka"
Trainee Guide for IoT Engineers Page 128
10.3.1.2 Authentication
Requests for calling an API can be authenticated in either of the following methods:
Using tokens: General requests are authenticated using tokens.
Using Access Key/Secret Access Key (AK/SK): Requests are authenticated by encrypting
the request body using an AK/SK.
Token authentication
A token is a character string generated by the server and is used for a client to send a
request. After the first login, the server generates a token and returns the token to the
client. In subsequent requests, the client needs to carry the token, but not the username
and password. The validity period of a token is 24 hours, which starts from the time
when the client obtains the token. If the same token needs to be used for authentication,
it is recommended that the token be cached to avoid frequent calling. Before the token
expires, you must obtain a new token. Otherwise, the authentication on the server will
fail after the token expires.
If you obtain the token for multiple times, the latest token is used. The previous token
will be overwritten and become invalid.
A token specifies temporary permissions in a computer system. During API authentication
using a token, the token is added to requests to get permissions for calling the API.
To obtain a token, call the API for Obtaining a User Token Through Password
Authentication. The following is an example:
POST https://iam.cn-north-4.myhuaweicloud.com/v3/auth/tokens
Content-Type: application/json
{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"name": "username",
"password": "********",
"domain": {
"name": "domainname"
}
}
}
},
"scope": {
"project": {
"name": "xxxxxxxx"
}
}
Trainee Guide for IoT Engineers Page 129
}
}
Note: username indicates the IAM user name, password indicates the password for
logging in to HUAWEI CLOUD, domainname indicates the account name, and
projectname indicates the project name.
Figure 10-13 API credential (see the Appendix for a reference image)
In the response to the API used to obtain a token, X-Subject-Token is the token
obtained.
The X-Auth-Token header field must be included to carry the token when calling other
APIs. For example, if the token is ABCDEFJ...., X-Auth-Token: ABCDEFJ.... can be added
to a request as follows:
GET https://iotda.cn-north-4.myhuaweicloud.com/v5/iot/{project_id}/products/{product_id}
Content-Type: application/json
X-Auth-Token: ABCDEFJ....
AK/SK-based Authentication
Authentication using AK/SK supports API requests with a body not larger than 12 MB. For
API requests with a larger body, authentication using tokens is recommended.
AK/SK is used to sign requests and the signature is then added to the request headers for
authentication.
AK: access key ID, the unique ID associated with a secret access key. The AppKey and
AppSecret are used together to obtain an encrypted signature for a request.
SK: secret access key used together with an AK to sign requests cryptographically. It
identifies a request sender and prevents the request from being tampered with.
In AK/SK-based authentication, you can use AK/SK to sign requests based on the
signature algorithm or use a dedicated signature SDK to sign requests.
Unlike the SDKs provided by services, the signature SDK supports only signature.
Trainee Guide for IoT Engineers Page 130
{
"product_id" : "5ba24f5ebbe8f56f5a14f605",
"name" : "Thermometer",
"device_type" : "Thermometer",
"protocol_type" : "LWM2M",
"data_format" : "binary",
"manufacturer_name" : "ABC",
"industry" : "smartCity",
"description" : "this is a thermometer produced by Huawei",
......
}
If an error occurs during API calling, an error code and error description will be displayed.
The following shows an error response body:
{
"error_msg": "The format of message is error",
"error_code": "IOTDA.013005"
}
In the preceding information, error_code is an error code, and error_msg describes the
error.
Trainee Guide for IoT Engineers Page 131
10.3.2 API
10.3.2.1 Creating a Device
This API is used by an application to create a device on the IoT platform. The device can
access the IoT platform only after being created.
This API can use the gateway_id parameter to create a child device under a parent
device. Currently, a maximum of two levels of child devices are supported.
This API also supports initial device configuration. The API reads the product details
provided in the product_id parameter in the device creation request. If the default value
of a product property is defined, the default value is written to the device shadow.
You can also use the shadow field in the device creation request to specify the initial
configuration for the device. After the initial configuration is specified, the system
compares the property values set based on service_id and desired with the default
values of the corresponding properties in the product. If the property values are different,
the property values set in the shadow field are written to the device shadow.
Figure 10-14 API for creating a device (see the Appendix for a reference
image)
Trainee Guide for IoT Engineers Page 132
Figure 10-15 API for querying a device (see the Appendix for a reference
image)
Figure 10-16 API for modifying device information (see the Appendix for a
reference image)
Trainee Guide for IoT Engineers Page 133
Figure 10-17 API for querying device messages (see the Appendix for a
reference image)
Figure 10-18 API for deleting a device (see the Appendix for a reference
image)
To view more APIs, scan the QR code in Figure 10-19 to view the API list.
scenario where there are few MCU resources. Devices are connected to the platform
directly, without using gateways.
LiteOS development
Devices run LiteOS that manages MCU resources. In addition, LiteOS has a built-in
IoT Device SDK Tiny that can call functions to connect to the platform. This
development mode shortens the device development duration and reduces the
development difficulty. It applies to directly connected devices that do not have OSs
and do not need to manage child devices.
Common development
The IoT Device SDK Tiny is integrated into the MCU and calls the SDK functions to
connect to the platform. This type of call is more convenient than API access. This
development mode is applicable to the scenario where there is sufficient time for
devices to put into commercial use, and the flash and RAM resources of the MCU
meet the conditions for integrating the IoT Device SDK Tiny.
OpenCPU module development
The MCU capability in the common module is used, and device applications are
compiled and run on the OpenCPU. This development mode is applicable to devices
that have high security requirements, are small in size, and need to be quickly put
into commercial use.
Gateway development
The IoT Device SDK is pre-integrated into the CPU or MPU and can call functions to
connect to the platform. This development mode is applicable to gateways that
manage child devices.
Trainee Guide for IoT Engineers Page 136
The MCU does not need to integrate the MQTT protocol stack or IoT Device SDK Tiny,
greatly reducing MCU resource consumption.
Huawei releases certified modules on HUAWEI CLOUD Marketplace so that device
manufacturers and service providers can purchase these certified modules to quickly
connect to HUAWEI CLOUD IoT.
Figure 10-22 shows how a certified module is used to connect a device to the platform.
Device authentication
The platform authenticates a device when the device attempts to access the platform.
The authentication process depends on the access method.
Figure 10-23 Authentication for devices using LwM2M over CoAP (see the
Appendix for a reference image)
1. An application calls the API Creating a Device to register a device. Alternatively, a user
uses the IoTDA console to register a device.
2-3. The platform allocates a globally unique PSK to the device and returns timeout.
4. The user hardcodes PSK into the device hardware, software, or firmware.
5. The user powers on the device. The device sends a connection request carrying the
node ID (for example, IMEI) and PSK.
6-7. If the authentication is successful, the platform returns a success message, and the
device is connected to the platform.
Authentication for devices using native MQTT or MQTTS
Trainee Guide for IoT Engineers Page 139
Figure 10-24 Authentication for devices using native MQTT or MQTTS (see
the Appendix for a reference image)
11 IoT OS
From this chapter, you will start to acquire knowledge about the sensing layer. In this
chapter, readers will understand what an operating system (OS) is, the OS development
process, and the challenges faced by the IoT OS. In addition, this chapter describes the
basic concepts and solutions of Huawei's IoT OS, known as LiteOS.
The difference between an OS and a normal application is not just their positions.
Another major difference is that the OS is larger, more complex, and longer-lived. The
source code of the Linux or Windows system has 5 million lines or more. This makes it
difficult to write code for the OS, which is why the OS has a long service life. Once the
code of the OS is written, the owner of the OS certainly does not want to start again
from scratch. Instead, the OS continuously evolves over a long period of time.
11.1.2 History
OSs have been around for decades. This section will briefly introduce the history of the
OS.
The first generation of OSs began in the 1940s, when engineers from the same group
designed, built, transformed, operated, and maintained one machine. At that time, all
programming was written in pure machine language, with thousands of cables needing
to be connected to the plug-in board to control the basic functions of the machine. There
was no programming language, not even assembly language, and no one had ever heard
of an OS, because all operations were performed by humans. In general, a programmer
used a machine by booking a time on the machine's timetable on the wall, before going
to the computer room and connecting the plug-in board to the computer. For the next
few hours, the programmer has nothing to do but hope that the more than 20,000
vacuum tubes in operation will not burn out. At that time, all calculations were actually
simple mathematical operations, such as making sines, cosines, and logarithmic tables, or
calculating cannonball trajectories.
By the early 1950s, significant improvements had been made. For example, punched
cards had emerged, allowing programs to be written on the cards and then read by the
computer without the plug-in board. But the rest of the process remained the same. In
the late 1950s, the invention of transistors dramatically changed the landscape.
Manufacturers could then mass produce and sell computers to users, who expected them
to run for long periods of time and do all kinds of useful work.
The second-generation OS, also known as the batch-processing OS, was very expensive at
the time, making it vital to find ways to reduce the waste of machine time. To this end,
the programmer collected the jobs in the input room, read them on a tape using a
relatively inexpensive computer, and then did the real calculations with a more expensive
computer. After the bulk of jobs were collected, the program in the card was written onto
the tape and mounted to the tape drive. The OS then read the first job from the tape and
ran it, and its output was written onto the second tape without printing. At the end of
each job, the OS automatically read the next job from the tape and ran it. After a batch
of jobs were completed, the operator took out the input and output tapes, replaced the
input tapes with the next batch of jobs, and then took the output tapes to a relatively
cheap computer for printing.
Then, the multi-channel batch processing OS introduced by the use of integrated circuits
worked on the principle of multi-channel program design. The principle was to allow
multiple programs to be entered and run in the memory at the same time to reduce the
CPU idle time. For programmers, however, they missed using the first-generation OS
because, at that time, they could exclusively occupy a machine for several hours, allowing
them to get real-time feedback on program debugging. However, the second- and third-
Trainee Guide for IoT Engineers Page 142
generation OSs required them to wait for a long time. This situation led to the
emergence of time-sharing systems.
A time-sharing system was actually a variant of multiple programs. Each user had an
online terminal, which divided the running time of the processor into short time slices
and allocated the processor to each online job in the order based on the time slices. If a
job could not complete its calculation within the allocated time slice, the job was
suspended and the processor was taken over by other jobs. The job would then continue
to be run after the next round. Because of the high-speed computing and job rotation, it
seemed to each user that they had exclusive use of a computer.
Although the multi-channel batch processing system and the time-sharing system can
obtain satisfactory resource utilization and system response time, they cannot meet the
requirements for real-time control and information processing. To this end, a real-time
system was generated. That is, the system can quickly respond to random external events
and process the events within a strict time frame. This means certain urgent tasks can be
completed within a certain time limit without waiting in a time slice queue. There are
two types of time limits. If an action must occur at a specified time (or within a specified
time range), it is called a hard real-time system. An example of this is automatic flight
control systems for aircraft, which must provide absolute assurance that a particular
action will be completed within a specified time frame. The other type is known as soft
real-time systems, such as flight booking systems and bank management systems, which
can tolerate occasional time violations that do not cause any permanent damage.
Another key development that began in the mid-1980s was the growth of personal
computer networks running network OSs and distributed OSs. On a network OS, a user is
aware of the existence of multiple computers, and can log in to a remote machine and
copy files from one machine to another. Each computer runs its own local OS and has its
own local user.
In essence, there is no difference between a network OS and a single-processor OS. Of
course, they need a network interface controller and some underlying software to drive it,
as well as programs for remote login and remote file access, but these add-ons do not
change the essential structure of the OS.
In contrast, a distributed OS is presented to users as a traditional single-processor OS,
despite being made up of multiple processors. Users are not aware of where their
programs are running or where their files are stored. These should be handled effectively
by the OS itself.
A real distributed OS is more than just the addition of a small piece of code to a
standalone OS, as it is essentially different from a centralized system. For example, a
distributed system usually allows an application to run on multiple processors at the
same time, requiring a more complex processor scheduling algorithm to obtain maximum
parallelism optimization.
The communication delay in the network often results in the need for the distributed
algorithm to adapt to the environment of incomplete, outdated, and even incorrect
information. This is fundamentally different from a standalone system, in which the OS
has all the information about the entire system.
Trainee Guide for IoT Engineers Page 143
11.1.3 Development
With the emergence of new technologies, computers have developed from transistors to
integrated circuits, large-scale integrated circuits, and micro-computers. In addition,
modern society has evolved from the Internet era where computers are used, to the
mobile Internet era where mobile computers (mobile phones) are used, and then to the
Internet of Things (IoT) era. In the IoT era, IoT devices are extremely diverse, and their
architectures and protocols are sophisticated. In this era, building an operating system
with unified management is difficult but essential.
So why is it essential to build an IoT operating system? The reason is that in every
generation of electronic devices, OSs compete fiercely for prominence. For example,
Windows has long been, and still is, the leading OS for personal computers. For mobile
devices, Android and iOS take center stage.
It is no different in the IoT era. Currently, all enterprises may be in the development
phase. However, there is only room for one or two OSs to lead the entire IoT industry.
Although the IoT OS was built for IoT, its applications will extend beyond IoT. But unlike
a computer and a mobile phone, an IoT is more like a network that connects all
electronic devices together, and can be said to have only an auxiliary role.
So what should we be focusing on in the development of IoT? In fact, we should focus on
developing AR and VR. Mark Zuckerberg, the founder of Facebook, once said that "VR is
going to be the most social platform". So, we can expect the use of VR and AR devices to
increase hugely in the future. But what is this prediction based on? With the emergence
of 5G, the network transmission rate is set to greatly increase. This increased rate will
make it easier to communicate with our colleagues when we work from home. And with
the continuous development of AR and VR technologies, we can communicate face to
face across long distances through VR or AR devices. This will revolutionize the way we
work and interact with people.
For example, British Airways has developed a service that provides users with an
immersive experience of traveling to their destinations before they even board their
flights. Another possible application is to help us perform services such as telemedicine.
Therefore, AR and VR devices could very well become the new tools for users to interact
with computers.
Our goal is to develop new ways for users to interact with machines, such as using AR
and VR, in addition to OSs for the IoT. Therefore, it is very important to build such an OS
for AR and VR devices.
to quickly open up the IoT market and enable a large number of developers to
participate in the construction of such an IoT ecosystem.
wait for user operations, while on the other, Huawei LiteOS ensures more reliable and
smooth connections and reduces frame freezing during user operations.
In the LPWA field, Huawei LiteOS can be used in solutions such as smart water meters
and smart parking. In the smart water metering solution, Huawei LiteOS can be directly
used on NB-IoT chips to control sensors. Unlike other OSs which control the MCU, use
the MCU to control the bottom-layer sensors, and use AT commands to connect NB-IoT
chips, Huawei LiteOS can directly control the communication module and control the
sensors to directly communicate with the base station.
In the smart parking field, Huawei LiteOS is used in the geomagnetic vehicle detector and
runs on the NB-IoT chip. The lightweight kernel and other components in the OS work
with Huawei NB-IoT chips to integrate sensing and interconnection. One chip supports
both data transmission through NB-IoT and application sensing algorithms. Based on its
open APIs, Huawei LiteOS enables parking sensing algorithms and applications to be
seamlessly migrated to NB-IoT chips for deployment. In addition, the Huawei LiteOS
sensing framework optimizes application algorithms and improves efficiency, eliminating
unnecessary MCU, memory, and storage costs. By default, the Huawei LiteOS
interconnection protocol stack supports interconnection with the HUAWEI CLOUD IoT
platform. In addition to making devices plug-and-play, the Huawei LiteOS
interconnection protocol stack collaborates with the HUAWEI CLOUD IoT platform to
upgrade firmware, algorithms, and applications, reducing the operation costs of the
parking system. Huawei LiteOS uses the lightweight platform architecture, dynamic and
distributed loading technology, and "Run-Stop" mechanism to drive the entire software
stack to implement ultra-low power consumption in standby state, allowing parking
devices to operate with extremely low power consumption.
Trainee Guide for IoT Engineers Page 147
This chapter describes the knowledge required for the IoT sensing layer from the
perspective of development.
Figure 12-1 shows all the parts required for end-to-end integrated IoT development,
which is divided into two sections: development on the terminal side and development on
the application (platform) side, which have been described in chapter 10. The
development on the terminal side can be divided into two parts. The first is hardware
development, which includes the PCB design. As the experiment in this course does not
involve hardware development, this chapter only describes some basic knowledge
regarding single-chip microcomputers and sensors.
For the second part, software development, we must become familiar with the
development of terminal software and module interconnection. This part will introduce
the basic architecture of the Huawei LiteOS system to help you complete the software
development on the terminal side.
This chapter will be divided into two parts: hardware development at the sensing layer
and software development at the sensing layer.
Trainee Guide for IoT Engineers Page 148
The most important function of a computer is its ability to compute. As such, during
hardware development, we will develop and design hardware circuits to implement the
computing function. This requires knowledge of digital and analog circuits, which is too
complex to expand on here.
As shown in Figure 12-2, for example, if developers want a computer to be able to add
two numbers, they can design circuits to achieve this function. However, if they want to
implement additional functions, such as the subtraction of two numbers, they must
Trainee Guide for IoT Engineers Page 149
design additional circuits that are totally independent of the previous one. This is
problematic and often a waste of space and manufacturing costs. Therefore, if we want
to implement multiple functions in the circuits, a multiplexer shown in Figure 12-3 must
be added to properly select each one.
But while we may have multiple functions, the most important memory function of the
computer has not yet been realized. A circuit with no memory means that it can run only
once, and it can be very complicated to repeat this step from scratch after the result is
obtained. In this case, the registers shown in Figure 12-4 need to be added to store the
previous data or the commands that you want to run. After the circuit contains each of
these elements, it can be regarded as a complete computer. All modern computers are
designed on the basis of this principle, and only vary based on the complexity of the
circuit.
After we understand how a computer works, it becomes clear that implementing
different functions is equivalent to executing the content in a program. A program
actually runs through a series of simple commands to process computer data step by
step. Here comes another important concept in the single-chip microcomputer, that is,
the instruction set.
However, machines that have different structures and instruction formats should have
matching instruction systems. Therefore, when designing the instruction system, we
should pay attention to the instruction format, type, and operation function. The
software is a program of various systems and users written for computers to use. The
program consists of a sequence of computer instructions. From this point of view,
instructions are a unit of computer language used to design programs.
For example, a programmer wants to design a program that converts degrees Celsius
into degrees Fahrenheit, which involves a number of different steps: first reading this
Celsius degree data, subtracting 273 from it, multiplying the result by 1.8, and adding
32. Finally, the result is output. In this program, each step represents a data operation
instructed by the computer. For this reason, the instruction set of a CPU is very
important. That is, whether the instruction set is advanced or not affects the performance
of the CPU, which means that it is an important indicator of the CPU performance.
Indeed, the instruction set is one of the most effective tools to improve the efficiency of
microprocessors.
In terms of a current mainstream architecture, an instruction set may be divided into two
parts: a complex instruction set computer (CISC) and a reduced instruction set computer
(RISC). Typical examples of CISC include Intel and AMD x86 CPUs, while RISC is typified
by ARM and IBM Power. Most IoT devices use the ARM architecture, with its CPU using
the RISC.
The RISC is designed to reduce the complexity of the CISC CPU by selecting some
instructions that can be executed in a single CPU cycle. For example, a multiplication
instruction provided by CISC can be invoked to multiply two numbers in memory a and
memory b, and save the result in memory a. It may take multiple CPU cycles to complete
the multiplication. The RISC does not provide one-stop multiplication instructions. Rather,
it needs to invoke four single-CPU cycle instructions to multiply two numbers: memory a
is loaded to one register, memory b is loaded to another register, and the numbers in the
two registers are multiplied together. The register result is saved to memory a. According
to this, the number of instructions in the RISC designed in the early stage is less than that
in the CISC. Later on, however, the number of instructions in the RISC exceeds that in the
CISC. Therefore, it is the complexity, not the quantity, of instructions that is referenced to
distinguish the two types of instruction sets.
Of course, the CISC also needs to complete complex instructions by operating a memory,
a register, and an arithmetic unit. During the implementation, complex instructions are
converted into a microprogram, which is stored in the microservice memory when the
CPU is manufactured. A microprogram contains several microinstructions (also called
microcodes). When a complex instruction is executed, it is actually a microprogram that
is executed. This also brings about a difference between the two instruction sets. The
execution of a microprogram cannot be interrupted, while RISC instructions can be
interrupted. Theoretically, RISC can respond to interrupts more quickly.
Therefore, the advantage of RISC is that the RISC system runs 2 to 4 times faster than the
CISC system with the same chip running at the same clock speed. Because the RISC
processor's instruction set is compact, its memory tubes and floating point units can be
designed on the same chip. RISC processors are easier to design than CISC processors,
and require shorter time. RISC processors can use more advanced technologies than CISC
processors and develop next-generation processors faster.
Trainee Guide for IoT Engineers Page 151
(a) (b)
Figure 12-5 (a) Microprocessor (b) Microcontroller
memory, or ROM, and is used to store programs that need to be executed by a single-
chip microcomputer. Data stored in ROM will not disappear after a power failure, and
will always remain available.
The difference between the ROM and RAM is that the latter is similar to the memory of a
computer and does not store data. However, the RAM occupies the space for caching
data during daily use. ROM, on the other hand, is the computer's hard drive, which is
used to store large amounts of data that will not disappear after the computer is shut
down.
The subsequent input and output interfaces are used to connect to external devices, such
as digital I/O and analog I/O. You can use devices such as data cables to connect them.
Finally, the system bus acts like a wire in a circuit, connecting all parts together for data
communication. Generally, buses can be classified into three types: data bus, address bus,
and control bus. As the name implies, the data bus is used to transmit data between the
CPU, memory, and external devices. The address bus is used by the selection processor to
read or write to a specific memory location, and is characterized by its unidirectional data
flow from the CPU to address bus, and then memory.
The last control bus is used to transmit control or signaling data.
smell is a gas sensor, taste is a chemical sensor, and the sense of touch is a pressure
sensor or a temperature sensor.
As the precision of a sensor determines the accuracy of the data collected by the IoT,
sensor technology is of vital importance.
Next, let's take a look at some common sensors.
The kernel is the most important element of the OS, and serves as the core. While the
LiteOS system can have no other middleware, it must possess this kernel. There are many
components in the kernel, including task management, memory management, and time
management components. The functions of the entire operating system are based on
tasks, which are the smallest units processed by the OS. Tasks are processed by
managing time and hardware.
LiteOS is most often applicable to the IoT field, which is characterized by low power
consumption. Most devices in the IoT field can be used for several years without a battery
change, requiring us to meet strict requirements for low power consumption. In addition
to network technology and chip design, the operating system must also meet these
requirements. As such, the tickless low-power mechanism is supported, enabling the OS
to cooperate with the hardware in order to enter a low power consumption mode.
12.3.2.2 Task
Among all the modules in the kernel, let's focus on the task module first. Tasks are the
smallest running units of an OS. That is, if we want to use an OS to perform a series of
operations, these operations are completed by smaller tasks. A task can use system
resources such as CPU and memory, and each task is independent. What does this mean?
If we divide a problem into several small tasks and require each to calculate different
parts of the problem, these tasks can be processed without following a specific sequence.
For example, when calculating 1+1+1+1, we can arrive at the correct result regardless of
which step of the calculation is performed first.
In addition, it is important to note that the task scheduling mechanism is based on
priorities. That is, tasks are marked with different priorities. When tasks have the same
Trainee Guide for IoT Engineers Page 157
priority, time slice rotation scheduling is called on to divide the time segment. The CPU
processes one task for a period of time before then processing the next, thereby
alternating time segments.
For example, three people (A, B, and C) want to play the same game console. If we use
the time slice rotation scheduling mode to handle this problem, we can let A play for 10
minutes first, then B play for 10 minutes, and finally C play for 10 minutes. The cycle will
then repeat again and again. This is the easiest and fairest way to deal with the problem.
In LiteOS, there are a total of 32 priorities for tasks, the highest of which is 0. A high-
priority task can interrupt a low-priority task at any time, and a low-priority task can only
be calculated after the high-priority process ends.
As described in Table 12-1, many different interfaces are used when we perform different
operations with tasks. For example, when we execute the creation and deletion tasks, the
LOS_TaskCreate and LOS_TaskDelete interfaces are used. Many other interfaces are also
invoked during various operations.
To help readers better understand task management, this document provides the
following programming example code for references:
#include "math.h"
#include "time.h"
#include "los_task.h"
#include "los_api_task.h"
#include "los_inspect_entry.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
#define TSK_PRIOR_HI 4
#define TSK_PRIOR_LO 5
/* task resumed */
dprintf("TaskHi LOS_TaskDelay Done.\r\n");
/* suspend self */
uwRet = LOS_TaskSuspend(g_uwTskHiID);
if (uwRet != LOS_OK)
{
dprintf("Suspend TaskHi Failed.\r\n");
uwRet = LOS_InspectStatusSetByID(LOS_INSPECT_TASK, LOS_INSPECT_STU_ERROR);
if (LOS_OK != uwRet)
{
dprintf("Set Inspect Status Err.\r\n");
}
return LOS_NOK;
}
/* delete self */
if(LOS_OK != LOS_TaskDelete(g_uwTskHiID))
{
dprintf("TaskHi delete failed .\r\n");
return LOS_NOK;
}
return LOS_OK;
}
/* delete self */
if(LOS_OK != LOS_TaskDelete(g_uwTskLoID))
{
dprintf("TaskLo delete failed .\r\n");
return LOS_NOK;
}
return LOS_OK;
}
UINT32 Example_TskCaseEntry(VOID)
{
UINT32 uwRet;
TSK_INIT_PARAM_S stInitParam;
dprintf("LOS_TaskLock() Success!\r\n");
stInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Example_TaskHi;
stInitParam.usTaskPrio = TSK_PRIOR_HI;
stInitParam.pcName = "HIGH_NAME";
stInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
/* create high prio task */
uwRet = LOS_TaskCreate(&g_uwTskHiID, &stInitParam);
if (uwRet != LOS_OK)
{
LOS_TaskUnlock();
Trainee Guide for IoT Engineers Page 160
stInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Example_TaskLo;
stInitParam.usTaskPrio = TSK_PRIOR_LO;
stInitParam.pcName = "LOW_NAME";
stInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
/* create low prio task */
uwRet = LOS_TaskCreate(&g_uwTskLoID, &stInitParam);
if (uwRet != LOS_OK)
{
/* delete high prio task */
if (LOS_OK != LOS_TaskDelete(g_uwTskHiID))
{
dprintf("TaskHi delete failed .\r\n");
}
LOS_TaskUnlock();
return LOS_NOK;
}
return uwRet;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cpluscplus */
#endif /* __cpluscplus */
This program simulates how the OS operates in the case of high and low priorities. Two
tasks are defined at the beginning of the program. One is named High, and the other is
Low. In addition, two priorities, 4 and 5, are assigned to the two tasks. As mentioned
above, a smaller value indicates a higher priority in LiteOS, making 4 the higher priority.
At the beginning, the program uses the UINT32 Example_TskCaseEntry (VOID) function
to create the two tasks. First of all, because the activity of creating a task is itself a task,
you need to lock the task to prevent other high-priority tasks from interrupting it. Then,
the program displays a message indicating that the task is locked successfully.
Next, the program creates the two tasks. After the tasks are created successfully, the
program displays a message indicating that the TaskHi and TaskLo tasks are created
Trainee Guide for IoT Engineers Page 161
successfully. After that, the program unlocks the locked task. Because no command is
printed in this step, the unlock operation is not displayed in the compilation result.
After the two tasks are created, you need to execute them. The first task is static UINT32
Example_TaskHi(VOID), which has a high priority. At the beginning of the function, the
system displays "Enter TaskHi Handler.\r\n". The program comments indicate that the
program will suspend the task after five ticks. Similarly, the first step of the low-priority
static UINT32 Example_TaskLo(VOID) function is to display the information of entering
the task. While different from the high-priority task, the low-priority task is suspended
after 10 ticks. Technically, a task with a higher priority is suspended earlier than a task
with a lower priority. The high-priority task function continues after the delay. As it is
displayed, after the TaskHi delay ends, the task suspends itself.
Because the task with a higher priority is suspended, the OS automatically starts to
execute the task with a lower priority. Therefore, the program enters the TaskLo task
with a lower priority. After the TaskLo task is delayed, the TaskHi task is suspended, and
the program displays a message indicating that the high-priority task has been
successfully suspended. After that, the program executes the low-priority task to delete
itself. Once this step is complete, because the low-priority task has been completed and
deleted, the OS jumps to handle the suspended high-priority task. The system switches to
the high-priority task and displays a message stating that the TaskHi task continues. The
task with a higher priority is executed successfully and is deleted. Figure 12-11 shows the
compilation result of the entire process.
12.3.2.3 Memory
Next, let's look at how memory is managed in the kernel module. Memory is an
important part of a computer system, and is responsible for data storage and invoking.
Data is generated as the CPU operates, and this data cannot be stored or invoked
without memory. As a result, memory management is very important, and memory
usage must be carefully planned. For example, when allocating memory, we need to
consider the optimal usage of both large and small blocks. Otherwise, improper
allocation may lead to a waste of memory resources.
The memory management module is responsible for initializing, allocating, and releasing
memory. LiteOS memory management is classified into static and dynamic memory
management, and Huawei LiteOS provides two types of memory management
algorithms: membox for static memory allocation; and bestfit, bestfit_little, and two-level
segregated fit (tlsf) for dynamic memory allocation.
Trainee Guide for IoT Engineers Page 162
Now we'll take a closer look at dynamic memory management. Dynamic memory refers
to allocating memory blocks of a specified size in the dynamic memory pool, which is a
large memory resource configured in the system. Dynamic memory enables memory
resources to be allocated based on user requirements, which is more cost-effective for
users who require large memory resources. The main disadvantage of this approach is
that resources are allocated on demand, requiring both a large block of memory and a
small block of memory. When the small block is allocated, the identifier at the beginning
of the block is used to store information about the size of the small block of resources.
This leads to a waste of resources, as a large proportion of small block resources
becomes occupied. In addition, the allocation of resources on demand results in a high
probability that fragments are generated, as smaller parts of the large block of resources
cannot be allocated.
Static memory management uses a different technique, instead allocating memory
resources in the resource pool to users in a fixed size. The advantage of this approach is
that higher levels of performance and efficiency can be achieved compared with dynamic
memory. In addition, as the size of each resource is fixed, the allocated memory has no
management structure, leading to higher resource usage than with dynamic memory,
and eliminating the fragmentation problem in the process. The main disadvantage,
however, is that the size is fixed and cannot be allocated on demand, and is therefore not
suitable for users with high memory resource requirements.
This document also provides programming examples about memory management. The
example code is as follows:
#include <stdlib.h>
#include "los_config.h"
#include "los_memory.h"
#include "los_api_dynamic_mem.h"
#include "los_inspect_entry.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
UINT32 Example_Dyn_Mem(VOID)
{
UINT32 *p_num = NULL;
UINT32 uwRet;
uwRet = LOS_MemInit(pDynMem, MEM_DYN_SIZE);
if (LOS_OK == uwRet)
{
dprintf("mempool init ok! \r\n");
}
else
{
dprintf("mempool init failed! \r\n");
Trainee Guide for IoT Engineers Page 163
return LOS_NOK;
}
/* mem alloc */
p_num = (UINT32 *)LOS_MemAlloc(pDynMem, 4);
if (NULL == p_num)
{
dprintf("mem alloc failed! \r\n");
return LOS_NOK;
}
dprintf("mem alloc ok \r\n");
/* assignment */
*p_num = 828;
dprintf("*p_num = %d \r\n", *p_num);
/* mem free */
uwRet = LOS_MemFree(pDynMem, p_num);
if (LOS_OK == uwRet)
{
dprintf("mem free ok!\r\n");
uwRet = LOS_InspectStatusSetByID(LOS_INSPECT_DMEM, LOS_INSPECT_STU_SUCCESS);
if (LOS_OK != uwRet)
{
dprintf("Set Inspect Status Err \r\n");
}
}
else
{
dprintf("mem free failed! \r\n");
uwRet = LOS_InspectStatusSetByID(LOS_INSPECT_DMEM, LOS_INSPECT_STU_ERROR);
if (LOS_OK != uwRet)
{
dprintf("Set Inspect Status Err \r\n");
}
return LOS_NOK;
}
return LOS_OK;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cpluscplus */
#endif /* __cpluscplus */
This document takes the allocation of dynamic memory as an example and provides code
to explain the process of memory allocation. This program consists of five steps. The first
step is to initialize a dynamic memory pool. After the initialization is successful, the
program displays a message indicating that the memory is successfully initialized. The
second step is to apply for a memory block in the dynamic memory pool, which equates
to allocating the memory in the program. After that, the program displays a message
Trainee Guide for IoT Engineers Page 164
indicating that the memory is successfully allocated. In the third step, the program
assigns a value to the memory block, and the OS stores the data in the memory block. In
the fourth step, the program displays a message indicating that the memory is
successfully allocated and displays the values in the resource block. Finally, after the
program accomplishes tasks with the memory resource, the program releases the
memory resource and displays a message indicating that the memory is successfully
released. The compilation result is also displayed according to this process.
12.3.2.4 Interrupt
The concept of an interrupt is very important with regard to computers. For example, we
have already mentioned that a high-priority task can interrupt a low-priority task in
2.2.1.1, and interrupt technology is used in many specific operations. The best way to
understand this concept is with examples from the real world. For instance, if the phone
rings when we are working on a computer, we will stop using the computer and answer
the phone instead. Once we have ended the call, we will continue with our work.
This example shows how we often interrupt one task in order to deal with another. The
interrupt handling method is very similar to our example. The phone's ring tone is
equivalent to an interrupt request, and answering the call is equivalent to an interrupt
response. An interrupt refers to the process in which the CPU stops to execute a new
program when necessary. As such, an interrupt is not an instant trigger, but an entire
process which ensures the working efficiency of the CPU. As the CPU only needs to
respond to other tasks when an interrupt is generated, it does not need to wait and
query the peripheral status.
In addition, it is important to note that interrupts also have priorities, as multiple
interrupts may occur at the same time in the actual system. In such cases, it is necessary
to differentiate the priorities of these interrupts based on urgency.
12.3.2.5 Queue
Now that we are familiar with task management, memory management, and interrupt
management, let's learn about the communication between tasks. As we have already
seen, task management mainly describes tasks with different priorities. However, the
coordination of multiple tasks is also a problem that needs to be considered by the
operating system. The inter-task communication of the LiteOS system can be
implemented in the queue, event, semaphore, and mutex modes, which are used to
implement the synchronization, mutex, and communication of multiple tasks in the OS.
The following describes each mechanism in detail.
Trainee Guide for IoT Engineers Page 165
The queue is essentially a data structure that can receive messages from tasks or
interrupts, and can choose to deliver or store them. Such a structure is very much like the
box containing table tennis balls or badminton shuttlecocks, with the message
represented by one of the small balls. After we receive the message, we can choose to
save it, similar to placing a ball in the box. At the same time, the message queue can also
function as a buffer, storing messages but not processing them until it is idle. A task can
read messages in the message queue, and the task processing mechanism is suspended
when there are no messages in the queue. When a new message is received, the task is
woken up to process it.
12.3.2.6 Event
Events are used to synchronize tasks, and it is important to note that data transmission
does not occur between them. Instead, they are used only for synchronization between
tasks. Compared with the aforementioned queue, an event is more like a condition for
triggering a task. This mechanism can be triggered by one event or by multiple events at
the same time. LiteOS uses a 32-bit variable to indicate an event (each bit indicates one
event). The value 0 indicates that the event does not occur, and the value 1 indicates that
the event has occurred. A total of 31 time types can be set (because bit 25 is reserved). In
addition, an event can be sent to a task multiple times, which is equivalent to sending
the event only once, and the operating system allows multiple tasks to read and write
the same event.
The following figure shows the event operation mechanism.
As shown in Figure 12-13, task A is triggered by event 2 and event 3. The logic is OR,
indicating that task A will be woken up when either event 2 or event 3 occurs. In
addition, task B is interested in event 2 and event 5, and the logic is AND, which indicates
that task B is woken up only when event 2 and event 5 occur at the same time.
Therefore, when only event 2 occurs, task A is triggered, while task B is still in the waiting
state. When event 5 and event 2 occur together, task A is still in the wakeup state, and
task B is also woken up.
Trainee Guide for IoT Engineers Page 166
12.3.2.7 Semaphore
Semaphores are mainly used to implement synchronization between tasks or exclusive
access to critical resources. The first semaphore we'll look at is the synchronization
semaphore. As the name implies, the synchronization semaphore is used to synchronize
tasks, and the specific implementation procedure is as follows:
As shown in Figure 12-14, different threads represent different people, and then our
public resources are like a small room that can hold up to four people. When all four
enter the room, it is automatically locked so that no one else can enter. In this way, all
four individuals in the room are synchronized, just like our four thread characters are
synchronized.
12.3.2.8 Mutex
The mutex is a special type of semaphore, also known as a binary semaphore, and is used
to exclusively occupy shared resources. The mutex has only two states, unlocked or
locked.
Trainee Guide for IoT Engineers Page 167
We can use the following example to explain this: imagine a restroom where only one
person can enter at a time. The door is locked whenever someone enters, and those
outside know that they cannot go in. Only when the first person opens the door and
leaves can the next person go inside. This is the principle of the mutex. When the mutex
of a task is locked, other tasks cannot use the mutex. When the task is released, the
mutex is unlocked and the task loses ownership of the mutex, allowing other tasks to use
it instead.
12.3.2.10 Timer
OSs also possess timers, which are primarily used to generate interrupts within a fixed
time in order to trigger another step execution. The timer can be classified as either a
hardware timer or a software timer, with the number of hardware timers limited by the
hardware. As such, the OS also provides a software timer to ensure that user
requirements are met.
This approach is similar to virtualization technology on the cloud, where software is also
used to reallocate otherwise limited hardware resources. In our case, we use software to
simulate the timer, which is then implemented based on the system clock interrupt. For
example, the system clock generates an interrupt to achieve the timing effect after
counting the number of ticks. In this way, the number of timers is increased, and
additional timer-related services can be created.
Trainee Guide for IoT Engineers Page 168
Figure 12-16 Huawei LiteOS framework (see the Appendix for a reference
image)
Figure 12-16 shows the LiteOS framework, that is, the capabilities provided by different
middleware. The framework, which is included in the LiteOS SDK, is the overall
architecture of the LiteOS operating system. The aforementioned kernel is at the bottom
of the architecture diagram, with the SDK in the middle, and user applications at the top.
The SDK contains many components, which can be divided into two parts. The first part is
the interconnection component, which is responsible for interworking with the cloud. A
key function of IoT is to implement interconnection and interworking between IoT
terminals and networks. However, some current IoT terminal systems are still unable to
connect to the Internet due to poorly developed interconnection components.
The second part is enhancement components, which are mainly developed for various
industry partners. Different capabilities are customized for them based on their
requirements. Next, this section will give a brief description of some important
components.
First of all, it is about the device-cloud interworking component. One of the advantages
of this component is that it can be integrated into various communication modules to
enable IoT terminals with limited resources in order to communicate with the cloud. The
communication modules include NB-IoT, eMTC, and Wi-Fi modules. In addition, the
device-cloud interworking component provides device-cloud collaboration, and integrates
a full set of IoT interconnection protocol stacks. As a result, users only need to focus on
their own applications, and the implementation of other parts will be completed in our
operating system. This allows users to reduce development cycles, focus on the
implementation of their own applications, and quickly build products.
In addition to the interconnection framework, we also provide users with complete
protocol stacks of IP, TCP/UDP, and CoAP, which include mesh networking capabilities.
The mesh network connects applications through the CoAP protocol, whereby an
interconnection framework can implement interconnection and interworking between
terminals that use different protocols.
Trainee Guide for IoT Engineers Page 169
While the interconnection framework is mainly used to interconnect sensors that use
different protocols, the sensing framework is used to manage different sensors, which
also use different data transmission protocols. For example, temperature and humidity
sensors may use the SPI, and light sensors may use the IIC. This requires users to compile
code by themselves. However, the sensing framework helps users manage data through
the use of unified driver interfaces, interaction management, and sensing algorithms. This
approach transforms the raw data into various application data, such as that used for
step counting, heart rate detection, and environmental monitoring.
Finally, it comes to the security framework. The security framework can be divided into
three categories based on things, connections, and networks. IoT terminal security is
related to things, and is similar to the security management of mobile phones, including
key management and secure storage. This is equivalent to the storage of fingerprints and
passwords. Transmission security refers to the security of connections between things and
the network layer. And lastly, the IoT networks relate to device-cloud security during
connection to the cloud, including authentication and authorization on the cloud as well
as device authentication.
13 AT Commands of the
Communication Module
Execution command
AT+<x> AT+NRB
(without parameters)
There are four types of AT commands: Set, Test, Read, and Execution. These commands
are easy to understand. For example, the AT+CMEE command is used in the NB-IoT
module to report errors. This command has two parameters: 0 and 1. The parameter 1
indicates that the module returns a specific error message when an error occurs, and 0
indicates that the module returns ERROR when an error occurs. So if you want to use it
as a Test command, use AT+CMEE=? If you want to use it as a Read command, use
AT+CMEE? When you run a command with a parameter, it is a Set command. For
example, AT+CMEE=0 is used to set the module to report ERROR (with no detailed error
information) upon an error.
There are commands without parameters, for example, AT+NRB. This command is used
in the NB-IoT module to restart the entire module. The Set command is similar to the
Execution command. The difference is that one has parameters and the other does not.
Purpose AT Command
name (APN)
Connecting to an AP AT+CWJAP
Trainee Guide for IoT Engineers Page 173
Purpose AT Command
Querying connection
AT+CIPSTATUS
information
Starting transparent
AT+CIPMODE
transmission
Table 13-3 lists the common AT commands for Wi-Fi modules. Different modules have
different AT commands, because networks have different usage and functions. Therefore,
some commands are the same, and others are different. For example, GPRS and NB-IoT
are cellular network technologies defined in 3GPP specifications, and their AT commands
have many similarities. However, Wi-Fi is not a communications technology defined in
3GPP specifications, and its AT commands are quite different from those of NB-IoT. Most
commands are used to interact with the gateway and access the network through the
gateway. The Wi-Fi module does not involve data such as SIM card and core network
data. Therefore, its AT commands are different.
Purpose AT Command
In addition to the AT commands for NB-IoT and Wi-Fi modules, some Huawei-certified
modules have AT commands. These modules have passed compatibility certification. The
AT commands and format specifications are basically the same as Huawei's general
requirements.
14 Conclusions
Now you have finished the HCIA-IoT course. Congratulations! This course provides a brief
introduction to the basics of the IoT. There are many other IoT technologies and
knowledge that are not covered in this course. For example, in addition to the basic
knowledge about the four-layer IoT architecture described in this book, there is also
knowledge related to development at the sensing, network, and platform layers, such as
basic experiments of single-chip microcomputers at the sensing layer, development
experiments at the platform layer, and development of communication chips at the
network layer. All these will be introduced in HCIP-IoT V2.5. The HCIP-IoT course will also
introduce other HUAWEI CLOUD services, such as big data and AI. You are welcome to
learn HCIP-IoT.
The following resources are listed, hoping you can learn more from them:
Huawei Certification: https://e.huawei.com/en/talent/#/cert?navType=authNavKey
Though we strive for accuracy, information in this Guide may contain inadvertent
inaccuracies or even errors. Contact us if you have any questions or suggestions.
Trainee Guide for IoT Engineers Page 178
15 References
Andrew S. Tanenbaum and Herbert Bos. Modern Operating Systems (4th Edition). China
Machine Press, 2017.
Huang Yan and Yang Lin. Huawei Cloud IoT Platform Technology and Practice. Posts &
Telecom Press Co., Ltd., 2020.
Ding Fei, Zhang Dengyin, and Cheng Chunmao. Introduction to Internet of Things. Posts
& Telecom Press Co., Ltd., 2020.
Kong Linghe, Li Xuefeng, and Chai Fangming. IoT Operating System Principle (LiteOS).
Posts & Telecom Press Co., Ltd., 2020.
Trainee Guide for IoT Engineers Page 179
16 Appendix
5 Signal Ground
Trainee Guide for IoT Engineers Page 181
Figure 16-25 IoT solution development process based on the IoT platform
Trainee Guide for IoT Engineers Page 204