The DIY Guide for keyboard and Bluetooth module based on the Neptune development board version 0.3 realizes “touch” connection and supports the compilation and burning of HUAWEI DevEco Device Tool in Linux. Mobile phone typing reply, always because the case switch is too “secret” and continue to press the wrong? Login to a certain answer, mobile phone typing is difficult, computer login is difficult? Operating multiple devices at once, switching back and forth between multiple keyboards and losing your head? At such times, developers may need an enhanced peripheral keyboard that not only makes it easy to connect to the phone, but also allows multiple devices to connect simultaneously.

1. Introduction

In a previous tweet, we gave developers a DIY guide for the Keyboard Bluetooth module based on runhe And Neptune development Board (below referred to as Neptune Development Board) version 0.1, which transformed the wired keyboard into a Bluetooth keyboard, enabling one keyboard to be used by multiple operating systems/terminals. After several months of updates, this time we bring you the DIY guide v0.3 for keyboard and Bluetooth module based on Neptune development board. We bring you several important updates:

1. Touch-and-touch connectivity for Phones running HarmonyOS

2. Support HUAWEI DevEco Device Tool one-stop compilation and burning

3. Initial support for ios in addition to the existing support for the four oss (HarmonyOS, Windows, Linux, and Android)

4. The maximum number of devices supported has been increased from 2 to 5

More details of the project updates can be found at the link below:

Gitee.com/openharmony…

In previous releases, we have learned about hardware environment building and USB serial port (CH340) acquisition. This time, let’s focus on the “touch” implementation and the HUAWEI DevEco Device Tool one-stop compilation and burning process. Let’s find out

2. The realization of “touch.

2.1 Interpretation of the realization of “touch” from the perspective of experience

The schematic diagram of the user using “touch” to realize bluetooth keyboard connection is as follows:

  1. The user pulls up the FA app by touching the NFC label

  2. Obtain MAC information of Bluetooth device (development board);

  3. At the same time, the Bluetooth scan in the mobile phone compares the Obtained Bluetooth list with the MAC information of the development board;

  4. When matching the MAC information of the same development board, it will feedback the connection result of Bluetooth and connect the Bluetooth device.

  5. If the connection is successful, the FA application is pulled up and the user is notified that the connection is successful. The effect can be seen in the video:

2.2 Interpret the realization of “touch” from the perspective of principle

In this process ** the key point that touching the NFC label can pull up the FA application and get the MAC address of the development board is that the FA application information and the MAC address of the development board have been written into the NFC label ** The user opens the NFC switch on the mobile phone. When the mobile phone is in the NFC tag, it can read the relevant information, pull up the FA application and obtain the MAC address of the development board for matching.

However, what is actually written into the NFC label is the Product ID of the FA application (you need to apply for it in the Official Application Commissioning Assistant APP of Huawei). After the application is completed, create and publish the FA service on huawei Fast Service And Wisdom Platform (HAG in the following and the figure), and associate the Product ID with the NAME of the APP package of the FA application. The developer writes the Product ID to the NFC tag. When the user touches the NFC tag, the HAG end will query the corresponding package name through the Product ID and pull it up.

On the other hand, a Bluetooth device uses a tool to obtain the MAC address code of the device and writes the MAC address code into the NFC label. When the user touches the NFC label, the MAC address code will be obtained, which matches the current Bluetooth list of the mobile phone and connects to bluetooth devices with the same MAC address.

Let’s break down the process in detail. Since we have the Product ID and the service is published, we will focus on how to implement the FA application information and the development board MAC address into the NFC label.

2.3 Learn to realize “touch” from the hands-on process

Next, let’s take a detailed look at the FA application information and development board MAC address writing NFC label process.

2.3.1. Understand the data sample structure written to the NFC

We will provide you with a sample data structure for writing to NFC. You only need to make a few changes to write directly to the NFC tag

The sample data structure strings are as follows:

D20C1A6170702F68776F6E65686F702001004800393935330081060005200685919106286DCD824FEF

Among them:

39393533 represents the Ascill code of 9953. 9953 is the Product Id we have applied for for this FA application.

286DCD824FEF is used to represent the BLE device hardware code (MAC address), which we will replace by obtaining the TARGET BLE device MAC address;

2.3.2. Obtain the BLE MAC address

In Huawei Application Market, install the BLE Debugator (the BLE debugator is used to obtain the MAC address of the target BLE device), open the BLE debugator, find the Bluetooth keyboard, and obtain the MAC address of the Bluetooth keyboard: 286DCD7C0E67

2.3.3**** Replace the MAC address of the target device

Replace the MAC address 286DCD7C0E67 obtained by BLE debugger in 2.3.2 with the MAC address 286DCD824FEF obtained by BLE debugger in 2.3.2.

D20C1A6170702F68776F6E65686F702001004800393935330081060005200685919106286DCD7C0E67

2.3.4 Writing to the NFC using the HW AirLink tool

1) Install the HW AirLink tool

We will download the NFC writing tool HW AirLink. The download link is as follows:

Developer.huawei.com/consumer/cn…

Download, decompress, and use the CMD tool on the Windows device (ensure that the ADB tool is installed on the Windows device) to install the adb tool. Run the following command to complete the installation:

The adb – r – d hilinkcert – tool – 1.0.0.3. Apk

As shown in figure:

After installation, as shown in figure:

2) Enter the invitation code

Open the tool, click “Add”, you will be asked to enter an invitation code, enter “B4ZD8BZ3” :

**3) ** Place in cache

Click NFC and select NFC WRITE to enter the NFC data input area. At this time, the state is “Cache to be written” :

Select “Byte Code” and obtain the assembled string obtained in step 3

D20C1A6170702F68776F6E65686F702001004800393935330081060005200685919106286DCD7C0E67

Enter it and click “Place in cache”. The status is “written to cache”.

4) Write NFC stickers

Install the developed FA application on the mobile phone, open the NFC function of the mobile phone, and use the back of the mobile phone (NFC sensor) to close to the specified NFC label to complete writing.

Please note that the mobile network should be turned off when writing, and try to use a blank NFC label for writing.

After the writing is complete, the write Success dialog box is displayed at the bottom of the HW AirLink.

At this point, we’ve clearly seen how touch NFC pulls up the FA app and pairs the Bluetooth keyboard. Let’s move on to the second key update — how to use HUAWEI DevEco Device Tool (hereinafter called DevEco Device Tool) on Linux platform to complete one-stop compilation and burning.

3. Realization of one-stop compilation and burning

This time, we will use Huawei DevEco Device Tool (V2.2.0 Beta1 version) to compile and burn the W800 development board corresponding to bluetooth keyboard module in Linux environment.

3.1 build

3.1.1. Building HPM environment

Harmony Package Manager (HPM) is a component package manager launched by Huawei Harmony. You can easily obtain required components from the official website and download only the components used by the current project as required, simplifying project files.

We will build and compile the environment in Linux, select the installation tool in Ubuntu, and download and configure each software according to the preparation of the development environment. The following links for preparing the Ubuntu development environment will not be covered here.

· Ubuntu development environment preparation

Device.harmonyos.com/cn/docs/ide…

Note: If some steps fail, restart Ubuntu and try again.

3.1.2 HPM pull source

After the HPM development environment is set up, enter:

hpm init -t dist 
Copy the code

Implement directory initialization, as shown in the figure:

Input:

hpm i @hihope/neptune_bluetoothkeyboard
Copy the code

Download the corresponding components and dependency packages, as shown in the figure:

After execution, “Installed” is displayed, indicating that the download is successful, as shown in the figure below:

Finally, the compile command is executed

hpm dist
Copy the code

As shown in figure:

After the command is executed, “Build Success!” is displayed. , indicating successful compilation, as shown in the figure:

The generated img file is located in the out directory, as shown here:

Open the “out/ Neptune /wifiiot_neptune/” folder and you can find the” W800. img “file, which is the generated firmware, as shown in the figure:

3.2 burn

3.2.1. Obtain the compiled firmware

Again, we will do this burning in a Linux environment. We will be burning the firmware of the “W800. img” file in the “out/ Neptune /wifiiot_neptune/” folder. At the same time, we also provide developers with the compiled firmware, which is available at the following link:

Gitee.com/openharmony…

3.2.2**** Burning firmware

The detailed procedure for burning firmware in Linux is as follows:

1) Connect the Neptune development board to the VIRTUAL machine through the serial port

Connect the Neptune development board to the USB port of the computer through the serial port. As shown in figure:

In the “new USB device detected” window that pops up, select Connect to the VIRTUAL machine, select Ubuntu 64-bit for the virtual machine name, and click OK.

Open VMware, and click vm > Mobile Devices >QinHeng USB Serial > Display in the status bar to check whether it is displayed, as shown in the figure:

At this time, the Neptune development board has successfully connected to the VM through the serial port.

2) Create the Device Tool project

DevEco Device Tool is deployed in Visual Studio Code as a plug-in, so we need to open “Extentions” in Visual Studio Code, find and open DevEco Device Tool, Click “New DevEco Project” to create a New Project and enter the information about the Project:

Project Name: Name (custom)

Development Board model: Board (select W800), currently we are using the W800 development Board

Bundle(select @hihope/neptune_iot), as shown below:

3) Set the location of burning firmware

Click Partiton Configuration(Step 1) and click the folder icon (Step 2), as shown in the figure:

Find the folder where the firmware is located (the path can be customized, please copy the target firmware to this location in advance), as shown in the figure:

Select the target firmware “OpenHarmony_hid_v0.3. img” (Step 1) and click the button “Open” OpenHarmony_hid_V0.3. img “(Step 2) as shown in the figure:

Click Save to Save.

After completing the board selection and setting up the burning firmware location, we need to configure the port and the burning protocol.

4) Set the port and the burning protocol

Click “W800”, as shown in the picture:

Set the burning port to upload_port and select the default value /dev/ttyusb0. If no, enter /dev/ttyusb0.

Enter the burning protocol upload_protocol and select Xmodem, that is, select a file transfer protocol for serial communication.

Set upload_Partitions, select partition: W800_app, and select which file to burn. The selection results are as follows:

After the configuration is complete, click Save.

5) View the projects that have been opened

Click Open to Open the project. Click on the Explorer icon in the upper left corner of Visual Studio Code to view the projects that have been opened:

Remove irrelevant items to prevent compilation exceptions, as shown here:

6) Burning firmware

Click DevEco and select Upload in the Pop-up PROJECT TASKS, as shown in the figure below:

According to the message “Please reset the board”, click the RST button of the development board, as shown in the figure:

At this time, the burning will be displayed. When the progress bar reaches 100% and “SUCCESS” appears below, the burning is successful, as shown in the figure:

4. At the end

Experienced multiple versions of updates, this keyboard bluetooth module based on Neptune development board version 0.3 will bring developers to touch up FA, through bluetooth mobile phone connected to the keyboard, so as to make the keyboard phone peripherals, control the mobile input, and realize the version of the program has been burning among them, NFC tags writing has to realize, You can download the detailed “Operation document” on Gitee, and developers can use the DevEco Device Tool to compile and burn the development board (W800) on Linux. Interested developers should try this new version

The HarmonyOS development Journey

Play development board open source community links: : :

Gitee.com/openharmony…

Sign up for a Huawei account and start your HarmonyOS development tour to get the latest learning resources. ▼ ▼ ▼

Download DevEco Studio for PC

Experience the fun of full-scene distributed development: :

Device.harmonyos.com/cn/ide#down…

We welcome friends and developers to join HarmonyOS

Each developer is the spark we need to build

Together we can create the possibilities of the Internet of everything

The original link: developer.huawei.com/consumer/cn…

Originally by HarmonyOS Device