HarmonyOS Connect (HarmonyOS Connect) is a HarmonyOS Connect device development platform that is currently being developed by HarmonyOS Connect. Chip, module, development board silly confused? How do I use code to control the development board? In this issue, we’ll explain them all.

1. Chip adaptation scheme

A chip is a miniaturized form of centralized manufacturing of circuits on the surface of a semiconductor wafer, which can be controlled by system commands on the port device. If the system is the soul of A device, then the chip is the heart of the device. Chipmakers offer different chip adaptation solutions for HarmonyOS Connect based on the OpenHarmony Linux kernel, LitEOS-A kernel, and LitEOS-M kernel, as shown in Figure 1:

Figure 1 chip adaptation scheme

Using HarmonyOS Connect certified chips and modules can help shorten the development and certification cycle for HarmonyOS Connect devices, as shown in Figure 2, listing some of the chips that have been certified on the HarmonyOS Connect website:

Figure 2. Certified chip

Different types of chips are suitable for products in different fields. Therefore, it can be concluded that, before carrying out device development, we should make clear the type of device to be developed and select suitable chips.

Second, chip, module, development board

In the process of equipment development, we are in contact with the most is chip, module, development board, what are the differences and connections between them, how should we choose? Below will answer for you.

1 chip

Figure 3 shows a highly integrated Hi3861V100 chip with 2.4GHz SoC Wi-Fi. In a space the size of a fingernail, IEEE 802.11b/ G/N baseband, power amplifier PA, low noise amplifier LNA, RF BALun, antenna switch and power management modules are integrated.

Figure 3 Hi3861V100 chip

Due to the small size of the chip, the pins are not directly led out, so antennas, capacitors, inductors and MCU need to be arranged by external circuits. If developers want to use the chip to achieve Wi-Fi functions, they need to design the antenna part of the chip circuit and add Flash chips to store data, which is expensive to develop. At this point, you have the following module.

2 module

Many module manufacturers design a variety of modules for all types of chips. As shown in Figure 4, Hi3861RNIV100 module. Compared with Hi3861V100 chip, this module also integrates power circuit, Flash chip, antenna circuit, etc., making developers directly ignore the wi-fi function realization of the chip in the previous section, greatly reducing the difficulty of Wi-Fi development. At the same time, the module can also meet the needs of users for secondary chip development.

Figure 4 Hi3861RNIV100 module Modules are product-oriented and can be embedded directly into the product after testing and verification. In addition, a chip can develop multiple modules, the same chip, by controlling the Flash size of the module, the material of the antenna, the size of the module to adapt to all kinds of intelligent products. So how do you quickly test and verify the functionality of a module? This leads to the development board below.

3 development board

As shown in Figure 5, the development board equipped with Hi3861RNIV100 module (hereinafter referred to as Hi3861 development board) provides more abundant peripheral resources, including standard E53 interface, NFC label, USB Type-C, reset button, user button, RADIO frequency antenna, serial port conversion circuit, etc. It is convenient for users to test and verify the functions of Hi3861RNIV100 module quickly.

The development board is oriented towards “test learning”. It provides tests to verify the performance of the module and helps beginners to quickly learn about the module. Therefore, the development board can be regarded as an “intermediate temporary variable” from the module to the product, as shown in Figure 6:

Figure 6 The differences between chips, modules and development boards can be summarized as follows: one chip can be made into multiple modules, and one module can be embedded into different development boards. This is why we often see development boards based on Hi3861.

4 How to select a development board

From the introduction above, WE believe that we have understood the relationship between chip, module and development board, let’s look at how to choose development board.

(1) Select an appropriate chip according to the type of the device

As mentioned in chapter 1, before selecting the development board, we should determine the type of equipment to be developed and select the appropriate chip.

(2) Select an appropriate module according to the functional requirements of the equipment

When selecting modules, we should determine the functions of the equipment to be developed, and fully consider the functions, cost, size and other factors. The more features a module has, the more pins it leads to, the larger the module may be, and the higher the cost. For example, if the device to be developed requires only the Wi-Fi function, select the Wi-Fi mode. If the device to be developed requires the Wi-Fi+ Bluetooth function, select the Combo mode.

(3) Select the corresponding development board according to different application scenarios

How do we select the development board after the module is confirmed? Different development boards provide different expansion boards based on different application scenarios. As shown in Figure 7, several typical expansion boards are given, which can be extended through the E53 interface to enable the development of intelligent humidifier, intelligent lamp, intelligent security, intelligent smoke sensor and other cases, making case development more flexible and convenient.

Figure 7 Typical expansion boards Therefore, when selecting development boards, first determine the application scenarios of the equipment to be developed, and then select the most appropriate development boards according to the expansion boards provided by various development boards.

How to control the development board

Now that you’ve chosen a development board that works for you, let’s look at how to control it through code. As shown in Figure 8, it is the E53 standard interface mounted on the Hi3861 development board. The E53 interface is controlled by the rich peripherals operation capability provided by OpenHarmony, so as to realize device development.

Figure 8 E53 ports installed

This article describes how to write a program to create a Wi-Fi hotspot on Hi3861 development board by calling OpenHarmony’s NDK interface.

1 key API

The following apis are used to create a Wi-Fi hotspot.

2 Implementation Steps

To create a Wi-Fi hotspot, perform the following steps: 1.

(1) Register hotspot status change events, STA site joining events and STA site exiting events to the system through RegisterWifiEvent interface. Related callback functions are as follows:

The code is as follows:

/ / register wifi event callback function g_wifiEventHandler. OnHotspotStaJoin = OnHotspotStaJoinHandler; g_wifiEventHandler.OnHotspotStaLeave = OnHotspotStaLeaveHandler; g_wifiEventHandler.OnHotspotStateChanged = OnHotspotStateChangedHandler; error = RegisterWifiEvent(&g_wifiEventHandler); if (error ! = WIFI_SUCCESS) { printf("RegisterWifiEvent failed, error = %d.\r\n",error); return -1; } printf("RegisterWifiEvent succeed! \r\n");Copy the code

(2) Call the SetHotspotConfig interface to set the specified hotspot configuration. The code is as follows:

HotspotConfig = {0}; HotspotConfig = {0}; strcpy(config.ssid, AP_SSID); strcpy(config.preSharedKey, AP_PSK); config.securityType = WIFI_SEC_TYPE_PSK; config.band = HOTSPOT_BAND_TYPE_2G; config.channelNum = 7; error = SetHotspotConfig(&config); if (error ! = WIFI_SUCCESS) { printf("SetHotspotConfig failed, error = %d.\r\n", error); return -1; } printf("SetHotspotConfig succeed! \r\n");Copy the code

(3) Invoke the EnableHotspot interface to enable the Wi-Fi AP mode. The code is as follows:

Error = EnableHotspot(); if (error ! = WIFI_SUCCESS) { printf("EnableHotspot failed, error = %d.\r\n", error); return -1; } printf("EnableHotspot succeed! \r\n");Copy the code

(4) Call IsHotspotActive interface to check whether AP hotspot mode is enabled. The code is as follows

// Check whether hotspot mode is enabled if (IsHotspotActive() == WIFI_HOTSPOT_NOT_ACTIVE) {printf("Wifi station is not actived.\r\n"); return -1; }printf("Wifi station is actived! \r\n");Copy the code

(5) Call netifapi_netif_set_ADDR to set the network adapter information and call netifapi_DHcps_start to start the DHCP service. The code is as follows:

G_lwip_netif = netifAPI_netif_find ("ap0"); if (g_lwip_netif) { ip4_addr_t bp_gw; ip4_addr_t bp_ipaddr; ip4_addr_t bp_netmask; IP4_ADDR(&bp_gw, 192, 168, 1, 1); /* Input your gateway for example: 192.168.1.1 */ IP4_ADDR(&bp_ipaddr, 192, 168, 1, 1); /* input your IP for example: 192.168.1.1 */ IP4_ADDR(&bp_netmask, 255, 255, 255, 0); /* input your netmask for example: 255.255.255.0 */ err_t ret = netifAPI_netif_set_addr (g_lwip_netif, &bp_ipaddr, &bp_netmask, &bp_gw); if(ret ! = ERR_OK) { printf("netifapi_netif_set_addr failed, error = %d.\r\n", ret); return -1; } printf("netifapi_netif_set_addr succeed! \r\n"); ret = netifapi_dhcps_start(g_lwip_netif, 0, 0); if(ret ! = ERR_OK) { printf("netifapi_dhcp_start failed, error = %d.\r\n", ret); return -1; } printf("netifapi_dhcps_start succeed! \r\n");Copy the code

That’s all for this issue. Through the introduction of this article, have you solved the doubts in your heart? If so, congratulations, you’ve just been introduced to HarmonyOS Connect device development and we look forward to having you join us.