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.
- Implement the server and its capabilities.
- 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.
- The server processes the received request and returns the result to the proxy via the driver.
- 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