harmony 鸿蒙DSoftBus

  • 2022-08-09
  • 浏览 (761)

DSoftBus

Introduction

The DSoftBus subsystem provides communication capabilities for OpenHarmony, including WLAN, Bluetooth, DSoftBus, and remote procedure call (RPC).

WLAN: basic WLAN functions, peer-to-peer (P2P) connection, and WLAN notification, enabling your application to communicate with other devices through a WLAN

Bluetooth: classic Bluetooth and Bluetooth Low Energy (BLE)

DSoftBus: distributed communications between near-field devices, and device discovery, connection setup, networking, and data transmission capabilities regardless of communication modes

RPC: communications between processes on a device or across devices

Architecture

Figure 1 DSoftBus subsystem architecture

Directory Structure

The main code directory structure of the DSoftBus subsystem is as follows:

/foundation/communication
├── bluetooth       # Bluetooth code
├── dsoftbus        # DSoftBus code
├── ipc             # IPC code
└── wifi            # WLAN code

Constraints

  • Networking: Devices must be in the same LAN.

Usage Guidelines

RPC

In RPC, the requesting process (client) can obtain the proxy of the process that provides the service (server). Through the proxy, the two processes can communicate with each other.

  1. Implement the server and its capabilities.
  2. To be more specific, the client obtains a proxy of the server. This proxy provides the same capabilities as the server. Then the client can call a method of the server by accessing the corresponding method of the proxy. The proxy forwards the request to the server.
  3. The server processes the received request and returns the result to the proxy via the driver.
  4. The proxy returns the result to the client.

DSoftBus

  • Networking

  • After the service is started, obtain the list of online devices.

  • Register a listener for device status changes.

  • Obtain the device ID, name, and type.

  • Obtain extended information about the device, such as the device type, networking type, and device capability.

  • Delete the registered listener.

  • Transmission

  • Create a session server and register a callback.

  • After a device goes online, open a session with the device.

  • Send data through the session.

  • Close the session if you no longer need it.

  • Remove the created session server if you no longer want to use distributed transmission (such as exiting the process).

Repositories Involved

DSoftBus subsystem

communication_bluetooth

communication_dsoftbus

communication_ipc

communication_wifi

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkCompiler Runtime

harmony 鸿蒙DeviceProfile

harmony 鸿蒙System Ability Manager

harmony 鸿蒙Security

harmony 鸿蒙Ability Framework

harmony 鸿蒙Account

harmony 鸿蒙AI

harmony 鸿蒙ArkUI

harmony 鸿蒙Bundle Management

harmony 鸿蒙Common Event and Notification

0  赞