当前位置:网站首页>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限制约束
关注我们
边栏推荐
- Confession of a graduate student: why am I addicted to opengauss community?
- 如何度量软件架构
- LeetCode链表问题——面试题02.07.链表相交(一题一文学会链表)
- (turn) bubble sorting and optimization details
- 关键路径的分析
- 承载银行关键应用的容器云平台如何选型及建设?
- Meta opens the project aria pilot dataset and will develop real-time 3D maps in the future
- Study - Summary of geometric calculations
- 工业通讯领域的总线、协议、规范、接口、数据采集与控制系统
- LeetCode链表问题——142.环形链表II(一题一文学会链表)
猜你喜欢

What is ci/cd| Achieve faster and better software delivery

DELTA热金属检测器维修V5G-JC-R1激光测量传感器/检测仪原理分析

SSM-使用@Async和创建ThreadPoolTaskExecutor线程池

35 道 MySQL 面试必问题图解,这样也太好理解了吧

云安全核心技术

怎么理解数据网格(Data Mesh)

PyQt5快速开发与实战 5.4 网页交互

Quii Cordova plugin telerik imagepicker plug-in multi image upload out of sequence

How to build a foreign environment for the self-supporting number of express evaluation? How much does it cost?

探讨:想要落地DevOps的话,只考虑好的PaaS容器平台就够了么?
随机推荐
技术选型Rust——事后分析
瑞典法院取消对华为和中兴的5G频谱拍卖禁令
Kubedm builds kubernetes cluster
Invalid prompt object name in SQL Server
[tidb] importing TXT documents into the database is really efficient
Adventures of little mouse: behind the scenes gags of moss 2
MySQL 是如何归档数据的呢?
工业通讯领域的总线、协议、规范、接口、数据采集与控制系统
百度搜索为什么只抓取,却不展现页面?
国产芯片厂商助力,2020年白牌TWS耳机出货已达6亿部
编码用这16个命名规则能让你少写一半以上的注释!
作价11.5亿元,1206件设备注入合资公司!SK海力士抢食大陆晶圆代工市场!
Query Oracle view creation statement and how to insert data into the view [easy to understand]
基于Xilinx的时序分析与约束
ABB电磁流量计维修信号变送器维修41F/E4技术参数
There have been two safety accidents in a month after listing. Is L9 ideal?
[英雄星球七月集训LeetCode解题日报] 第28日 动态规划
Study - 几何计算总结
The ref value ‘xxx‘ will likely have changed by the time this effect function runs.If this ref......
蚂蚁集团境外站点 Seata 实践与探索