当前位置:网站首页>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限制约束
关注我们
边栏推荐
- ABB电磁流量计维修信号变送器维修41F/E4技术参数
- 将字符串指针赋值给数组[通俗易懂]
- Confession of a graduate student: why am I addicted to opengauss community?
- 编码用这16个命名规则能让你少写一半以上的注释!
- Buuctf questions upload labs record pass-11~pass-20
- Maxwell 一款简单易上手的实时抓取Mysql数据的软件
- 瑞典法院取消对华为和中兴的5G频谱拍卖禁令
- 针对下一代Chromebook,联发科推出新款芯片组MT8192和MT8195
- 到底为什么不建议使用SELECT * ?
- Invalid prompt object name in SQL Server
猜你喜欢

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

IJCAI2022教程 | 对话推荐系统

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

Uncaught Error:Invalid geoJson format Cannot read property ‘length‘ of undefind

How to measure software architecture

Ijcai2022 tutorial | dialogue recommendation system

Redis cache avalanche, cache penetration, cache breakdown

There have been two safety accidents in a month after listing. Is L9 ideal?

顶级“Redis 笔记”, 缓存雪崩 + 击穿 + 穿透 + 集群 + 分布式锁,NB 了

技术选型Rust——事后分析
随机推荐
针对下一代Chromebook,联发科推出新款芯片组MT8192和MT8195
作价11.5亿元,1206件设备注入合资公司!SK海力士抢食大陆晶圆代工市场!
牛客打开摄像头几秒后画面消失 | 相机打开画面一闪一闪
提前布局6G赛道!紫光展锐发布《6G无界 有AI》白皮书
Four methods of multi-threaded sequential operation. Ask casually during the interview
Buuctf questions upload labs record pass-11~pass-20
Several skills of API interface optimization
证券企业基于容器化 PaaS 平台的 DevOps 规划建设 29 个典型问题总结
DELTA热金属检测器维修V5G-JC-R1激光测量传感器/检测仪原理分析
如何度量软件架构
Cloud security core technology
Leetcode linked list problem -- 142. circular linked list II (learn the linked list by one question and one article)
Uncaught Error:Invalid geoJson format Cannot read property ‘length‘ of undefind
30. Learn highcharts label rotation histogram
[cloud native] what is ci/cd| Ci/cd to smooth delivery obstacles
酷派主动终止针对小米公司的专利侵权诉讼
传微软已获得向华为供货许可!华为将迎来全面解禁?
详细讲解C语言12(C语言系列)
Adventures of little mouse: behind the scenes gags of moss 2
在子组件中使用el-date-picker报错