当前位置:网站首页>openEuler Embedded SIG | 分布式软总线
openEuler Embedded SIG | 分布式软总线
2022-07-28 19:49:00 【InfoQ】
特性介绍
背景
架构

- 即插即用:快速便捷发现周边设备。
- 自由流转:各设备间自组网,任意建立业务连接,实现自由通信。
- 高效传输:通过WIFI、蓝牙设备下软硬件协同最大化发挥硬件传输性能。
应用指南
部署示意

服务端启动
softbus_server_mainopeneuler ~ # softbus_server_main >log.file &客户端API
/usr/include/dsoftbus/- discovery_service.h:发现模块头文件,支持应用主动探测和发布的API如下:

g\_capabilityMap- softbus_bus_center.h:组网模块头文件,支持获取组网内设备信息API如下:

- session.h:连接/传输模块头文件,支持创建session和数据传输API如下:

应用示例
- 编写客户端程序
- 安装SDK
sh openeuler-glibc-x86_64-openeuler-image-aarch64-qemu-aarch64-toolchain-22.03.sh/opt/openeuler/<openeuler version>/sh ./openeuler-glibc-x86_64-openeuler-image-armv7a-qemu-arm-toolchain-22.03.sh``
openEuler embedded(openEuler Embedded Reference Distro) SDK installer version 22.03
================================================================
Enter target directory for SDK (default: /opt/openeuler/22.03): sdk
You are about to install the SDK to "/usr1/openeuler/sdk". Proceed [Y/n]? y
Extracting SDK...............................................done
Setting it up...SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
. /usr1/openeuler/sdk/environment-setup-armv7a-openeuler-linux-gnueabi- 设置SDK环境变量
. /usr1/openeuler/myfiles/sdk/environment-setup-armv7a-openeuler-linux-gnueabi- 查看是否安装成功
arm-openeuler-linux-gnueabi-gcc -vmain.c#include "dsoftbus/softbus_bus_center.h"
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int32_t infoNum = 10;
NodeBasicInfo **testInfo = malloc(sizeof(NodeBasicInfo *) * infoNum);
int ret = GetAllNodeDeviceInfo("testClient", testInfo, &infoNum);
if (ret != 0) {
printf("Get node device info fail.\n");
return 0;
}
printf("Get node num: %d\n", infoNum);
for (int i = 0; i < infoNum; i++) {
printf("\t networkId: %s, deviceName: %s, deviceTypeId: %d\n",
testInfo[i]->networkId,
testInfo[i]->deviceName,
testInfo[i]->deviceTypeId);
}
for (int i = 0; i < infoNum; i++) {
FreeNodeInfo(testInfo[i]);
}
free(testInfo);
testInfo = NULL;
return 0;
}CMakeLists.txtproject(dsoftbus_hello C)
add_executable(dsoftbus_hello main.c)
target_link_libraries(dsoftbus_hello dsoftbus_bus_center_service_sdk.z)mkdir build
cd build
cmake ..
makedsoftbus_hello- 构建QEMU组网环境
brctl addbr br0qemu-system-aarch64 -M virt-4.0 -m 1G -cpu cortex-a57 -nographic -kernel zImage -initrd <openeuler-image-qemu-xxx.cpio.gz> -device virtio-net-device,netdev=tap0,mac=52:54:00:12:34:56 -netdev bridge,id=tap0failed to parse default acl file `/usr/local/libexec/../etc/qemu/bridge.conf'
qemu-system-aarch64: bridge helper failedecho "allow br0" > /usr/local/libexec/../etc/qemu/bridge.confqemu-system-aarch64 -M virt-4.0 -m 1G -cpu cortex-a57 -nographic -kernel zImage -initrd openeuler-image-qemu-aarch64-20220331025547.rootfs.cpio.gz -device virtio-net-device,netdev=tap1,mac=52:54:00:12:34:78 -netdev bridge,id=tap1ifconfig br0 192.168.10.1 upifconfig eth0 192.168.10.2ifconfig eth0 192.168.10.3- 启动分布式软总线
softbus_server_main >log.file &scp dsoftbus_hello [email protected]:/
scp dsoftbus_hello [email protected]:/[LNN]NodeStateCbCount is 10
[LNN]BusCenterClientInit init OK!
[DISC]Init success
[TRAN]init tcp direct channel success.
[TRAN]init succ
[COMM]softbus server register service success!
[COMM]softbus sdk frame init success.
Get node num: 1
networkId: 714373d691265f9a736442c01459ba39236642c743a71750bb63eb73cde24f5f, deviceName: UNKNOWN, deviceTypeId: 0
[LNN]NodeStateCbCount is 10
[LNN]BusCenterClientInit init OK!
[DISC]Init success
[TRAN]init tcp direct channel success.
[TRAN]init succ
[COMM]softbus server register service success!
[COMM]softbus sdk frame init success.
Get node num: 1
networkId: eaf591f64bab3c20304ed3d3ff4fe1d878a0fd60bf8c85c96e8a8430d81e4076,deviceName: UNKNOWN, deviceTypeId: 0
编译指导
- 下载脚本所在仓库(例如下载到
src/yocto-meta-openeuler目录下)
git clone https://gitee.com/openeuler/yocto-meta-openeuler.git -b openEuler-22.03-LTS -v src/yocto-meta-openeuler- 执行下载脚本
sh src/yocto-meta-openeuler/scripts/download_code.sh dsoftbusyocto-meta-openeulerdsoftbus/_standardyocto-embedded-toolssh src/yocto-meta-openeuler/scripts/compile.sh dsoftbusdsoftbus/_builddsoftbus/_outputyocto-meta-openeuler限制约束
关注我们
边栏推荐
- [Topic] add two numbers
- SSM use @async and create threadpooltaskexecutor thread pool
- 30.学习Highcharts 标签旋转柱形图
- How to measure software architecture
- 到底为什么不建议使用SELECT * ?
- uniapp的进度条自定义
- 工业通讯领域的总线、协议、规范、接口、数据采集与控制系统
- Attribute based encryption simulation and code implementation (cp-abe) paper: ciphertext policy attribute based encryption
- 证券企业基于容器化 PaaS 平台的 DevOps 规划建设 29 个典型问题总结
- Applet container technology improves mobile R & D efficiency by 500%
猜你喜欢

ICML2022 | 时序自监督视频transformer

LeetCode·581.最短无序连续子数组·双指针

Uniapp progress bar customization

Reading and writing basic data types in protobuf
![[tidb] importing TXT documents into the database is really efficient](/img/2a/d33849987a75c4a0d52d8f0ab767ca.png)
[tidb] importing TXT documents into the database is really efficient
![[cloud native] what is ci/cd| Ci/cd to smooth delivery obstacles](/img/4f/e7806d75cd719e181d8455e4fdc1e7.jpg)
[cloud native] what is ci/cd| Ci/cd to smooth delivery obstacles

How NPM switches Taobao source images

C语言入门【详细】

Eureka registers with each other, only showing each other or only showing problems in one

工业通讯领域的总线、协议、规范、接口、数据采集与控制系统
随机推荐
Sharkteam completes the safety audit of flow ecological NFT market matrixmarket
Bus, protocol, specification, interface, data acquisition and control system in industrial communication field
Leetcode linked list problem -- 142. circular linked list II (learn the linked list by one question and one article)
Link with bracket sequence I (state based multidimensional DP)
关于一些小需求,用案例方式记录
C # detailed steps for connecting to MySQL database
证券企业基于容器化 PaaS 平台的 DevOps 规划建设 29 个典型问题总结
Coding with these 16 naming rules can save you more than half of your comments!
Uncaught Error:Invalid geoJson format Cannot read property ‘length‘ of undefind
PyQt5快速开发与实战 5.4 网页交互
Source insight uses shortcut keys
属性基加密仿真及代码实现(CP-ABE)论文:Ciphertext-Policy Attribute-Based Encryption
(PMIC)全、半桥驱动器CSD95481RWJ PDF 规格
NTP server time (view server time)
苹果M1处理器详解:性能及能效成倍提升,Intel酷睿i9也不是对手!
Attribute based encryption simulation and code implementation (cp-abe) paper: ciphertext policy attribute based encryption
多线程顺序运行的 4 种方法,面试随便问
Capture video by buffering
Library borrowing system "suggested collection"
Explain C language 12 in detail (C language series)