How to Develop an Application connected with BLE 5 Devices on Dusun’s Gateways

2023-11-29 Dusun Blogs

As the Dusun Gateway is running based on the Linux system, how to implement an application over the Bluez stack to ‘talk’ with BLE 5 devices on Dusun BLE gateways 1 will be presented here.


The Linux OpenWrt system is used by Dusun’s gateways. Figure 1 shows how Linux can run the Bluez stack and support the Bluetooth Low Energy protocol. The fundamental Bluetooth protocols and levels are supported by BlueZ. It employs a modular design and is versatile and effective. All essential Bluetooth layers and protocols are now supported by the BlueZ stack. Users can write BLE applications using Bluez APIs to manipulate BLE 5 devices.


Figure 1. Dusun Gateway system architecture

System Configuration

The Dusun gateways are configured through a web service which means the gateways should be connected with a computer first. The Dusun gateway can be connected through wired connection and a WIFI connection.


Gateway connection

Wired connection
The two RJ45 ports gateway includes a WLAN port and LAN ports. The wired connection of this type of gateway is shown below figure 2-A. Users can use the gateway default LAN IP address: 192.168.66.1 to connect it.


Figure 2-A Direct connection


After the above physical connection is completed, please open a web browser on PC, Input Gateway IP Address;Enter the username and Password(default Username: root Password: root),login to the gateway.


Figure 2-B Connection via a router


After the above physical connection is completed, please open a web browser on your PC, Input the Gateway IP Address, Enter the username and Password(default Username: root Password: root), login into the gateway.



WIFI connection
The Dusun gateway supports a WIFI connection to login it, but WIFI is not enabled by default. The WIFI should be enabled first if the user wants to use WIFI to connect a gateway. Users should log in to the gateway through the above-wired connection to enable the WIFI module. After the connection is established, please follow the below steps to enable WIFI:

1. Login to the gateway (see above figure);

2. Select Dusun > Wifi Manage.

3. Enable Device Radio0 and configure Wifi Interface Wlan0(Wifi Mode:ap, Wifi SSID: Input your own; WIFI Encryption: PSK2 or others; WIFI key: your password)

4. Click the Save & Apply button, and wait for the changes to be applied.

5. Then we can connect the WIFI (for this case: Dusun123) and connect the gateway through WIFI.


Gateway Configuration

After the connection between the gateway and the computer is established, the gateway can be configured following these steps:

1. Open a web browser on your PC, input the gateway IP address, enter the username and Password (default username: root password: root), login to the gateway;

2. Make system configuration at the system menu, the timezone, password, and others can be revised here.

3. Configure the network at the network sub-menu.

4. Configure other settings according to users’ needs.


When the configuration is completed please reboot the gateway. Then users can log in to the gateway by inputting the following ssh commands in a terminal, and then input their password. IP_addr is the IP address that which user configured above. The default IP is 192.168.66.1. The below figure shows the login scene.


API for BLE5 software development

Dusun BLE gateway implemented the EFR32BG21 BLE5 chip from the silicon lab. In order to simplify the programming procedures, we provide a detailed API document seen from the attached file for all kinds of implementation, some core function is listed below,


A sample program: read data from an oximeter BLE sensor

We have provided a sample application to get the BLE oximeter sensor data. To be more specific, the function of scan, connect, and read data is called in app.c file. The main function in the main. c is shown below.


The current event is received by the variant evt, according to the different events the function appHandleEvents function would call the corresponding command. The function appHandleEvents is the main framework to schedule different functions, the main part of this function in file app. c is listed below,



With different events reported to this function, it would invoke different functions. For example, if the program gets an event with event id gecko_evt_le_gap_scan_response_id, it would call the SCAN_Process_scan_response function and start the scanning process.

For the complete code, you can be in the attached file named BLE5_oximeter.

If you would prefer the code with uploading data to the mqtt broker function, you can view the code BLE5withpaho.


Run the oximeter sensor sample on the gateway

1) Get the Openwork toolchain and copy it to a Linux PC.

Get the cross-compile OpenWrt-Toolchain from Dusun, whose name is openwrt-sdk-ramips-mt7620_gcc-4.8-linaro_uClibc-0.9.33.2. Linux-x86_64.tar.bz2. Decompress the downloaded OpenWrt Toolchain to a local folder (E.g.: home/bc/ OpenWrt-SDKCHAOSCALMER).

2) Compiled the attached code files.

Copy the above code file to the Linux PC and decompress it to a folder (E.g.: home/bc/BLE5). Open the ./BLE5 folder, and edit the makefile file to revise the CROSSTOOLDIR to the OpenWrt toolchain directory you created above. This is depicted in Figure 3.


Figure 3 changes the CROSSTOODIR path


Then open a terminal on the Linux PC, and type the following commands:

cd BLE5_oximeter ;

make

Finally, the test bin file which can be run in the gateway has been compiled. (Figure 4).

Figure 4. The test application compilation


Copy the compiled test bin file into the gateway and run it.

There are several ways to do it, one of them is introduced below. Under Linux PC, you can use the SCP command (scp local_file remote_username @remote_ip:remote_folder) to do it. Make sure the gateway is connected to the same router as PC, then run the following commands:

scp test root@192.168.0.115:/root


Then remote login to the gateway using SSH commands or SSH client (windows: putty or SecureCrt) and run the copied bin file. The login password can be revised following the configuration steps in the above sections. Finally, we power up the oximeter device and run the test file, we can see the data the oximeter notified to the program as figure 5 shows. The data can be analyzed according to its manual. Figure 6/7 shows the sensor and gateway for testing respectively.

Figure 5

Figure 6 The oximeter device for testing


Figure 7 The Dusun Gateway for testing

授权代理商:世强先进(深圳)科技股份有限公司
技术资料,数据手册,3D模型库,原理图,PCB封装文件,选型指南来源平台:世强硬创平台www.sekorm.com
现货商城,价格查询,交期查询,订货,现货采购,在线购买,样品申请渠道:世强硬创平台电子商城www.sekorm.com/supply/
概念,方案,设计,选型,BOM优化,FAE技术支持,样品,加工定制,测试,量产供应服务提供:世强硬创平台www.sekorm.com
集成电路,电子元件,电子材料,电气自动化,电机,仪器全品类供应:世强硬创平台www.sekorm.com
  • +1 赞 0
  • 收藏
  • 评论 0

本文由PlusLee转载自Dusun Blogs,原文标题为:How to Develop an Application connected with BLE 5 Devices on Dusun’s Gateways,本站所有转载文章系出于传递更多信息之目的,且明确注明来源,不希望被转载的媒体或个人可与我们联系,我们将立即进行删除处理。

评论

   |   

提交评论

全部评论(0

暂无评论

相关推荐

【经验】EFR32BG21系列蓝牙BootLoader生成与烧录的操作流程和注意细节

Silicon Labs公司针对蓝牙应用的开发,经常用到的UART BootLoader或者也叫Gecko bootloader。但并不是默认加入到蓝牙工程中的,芯片上电以后应用代码是无法运行的。所以每一个蓝牙的工程都需要烧录一个Gecko bootloader。本文指导一步一步操作生成一份EFR32BG21系列芯片的bootloader工程代码。

设计经验    发布时间 : 2020-02-03

Silicon Labs EFR32BG21 蓝牙SoC RCP模式测试-扫描设备

本文介绍测试EFR32BG21 蓝牙RCP模式工作在主模式,用于扫描蓝牙从设备,建立蓝牙连接和收发数据。首先需要准备一台电脑并且已经安装好了linux系统。也可以是windows系统下安装的linux虚拟机。并且已经安装好了蓝牙BlueZ协议栈。

设计经验    发布时间 : 2024-03-01

【经验】如何使用树莓派开发 ZigBee 网关?

在 Zigbee 系统中,网关是一个非常重要的设备,为了能容纳更大的网络及更复杂的应用逻辑,一个强大的主机是不可或缺的,树莓派就是这样一个强大的开发平台,非常适合用来构建 host application,这个文章将描述如何设置树莓派来开发 Silicon Lbas EmberZNet ZigBee Gateway。

设计经验    发布时间 : 2018-10-12

开发环境(软件/固件)  -  SILICON LABS  - Rev 1.0  - 2024-APR-25 PDF 英文 下载

【经验】如何在Gateway Soc (internal flash)中实现 Ota Server?

EFR32MG多协议SoC芯片是Silicon Labs专门针对 IOT 推出的ZigBee方案,高达19.5dbm的发射功率,-102.7dbm的接收灵敏度,在业界内拥有最佳的RF射频性能,具有最全的Zigbee网络协议,被广泛应用在智能家居,工业控制等行业。本文介绍在开发 Zigbee Gateway 时如何在Gateway Soc (internal flash)中实现 Ota Server

设计经验    发布时间 : 2019-01-03

应用笔记或设计指南  -  SILICON LABS  - Rev. 0.2  - 2024/7/17 PDF 英文 下载 查看更多版本

【经验】EFR32BG21蓝牙绑定的操作流程

我们在使用EFR32BG21做产品时,有时会遇到需要配对、绑定的一些操作,做这些操作时要调用哪些API函数去实现呢?本文就用Silicon Labs的两块蓝牙SOC EFR32BG21的开发板测试一下这个功能。

设计经验    发布时间 : 2021-12-29

【经验】蓝牙MESH网关程序中的Vendor Model的OpCode的设置

在使用FR32BG21开发蓝牙MESH网关的程序时,我们有时需要使用Vendor Model功能,这时我们需要定义OpCode,在程序中我们可以查到默认定义了两个Opcode:0X00,0X01,这个定义与SIG标准有些冲突,这是什么原因?我们要如何定义OpCode?

设计经验    发布时间 : 2022-03-26

产品勘误说明  -  SILICON LABS  - Rev. 1.0  - May, 2024 PDF 英文 下载 查看更多版本

Silicon Labs EFR32BG21 蓝牙SoC RCP模式测试-广播设备

本文介绍测试EFR32BG21 蓝牙RCP模式工作在从模式,BG21 RCP会发出蓝牙广播,被手机的蓝牙扫描,连接。首先需要准备一台电脑并且已经安装好了linux系统。也可以是windows系统下安装的linux虚拟机。并且已经安装好了蓝牙BlueZ协议栈。

设计经验    发布时间 : 2024-02-29

Dusun IoT’s DSGW-210-HA Home Assistant IoT Gateway Operating System Upgrade to Debian 12

Dusun IoT’s DSGW-210 Home Assistant Zigbee Z-Wave Gateway now fully supports the Debian 12 operating system, enhances developer’s Linux IoT experience with fixed bugs and feature improvements, providing a robust IoT gateway platform and a smoother operation to leverage the capabilities that Home Assistant brings to your service.

产品    发布时间 : 2023-12-12

探索蓝牙新安全功能,基于证书的身份验证和配对 (CBAP)

“基于证书的身份验证和配对(CBAP)”有助于简化低功耗蓝牙(Bluetooth LE)设备的身份验证和配对过程。芯科科技是低功耗蓝牙解决方案的行业领导者,可以帮助您实施基于证书的身份验证和配对,以确保设备具有最高安全性,而无需任何用户交互。目前,Secure Vault-High 和 Secure Vault-Mid 设备上支持基于证书的身份验证和配对。

设计经验    发布时间 : 2024-07-10

用户指南  -  DUSUN  - Rev 1.1  - 2022-04-05 PDF 英文 下载

用户指南  -  DUSUN  - Rev 1.1  - 2023-07-10 PDF 英文 下载

EFR32BG21 BLE Wireless SoC Family Data Sheet

型号- EFR32BG21B010F1024IM32-B,EFR32BG21B020F1024IM32-D,EFR32BG21A020F768IM32-B,EFR32BG21A020F768IM32-D,EFR32BG21B010F512IM32-B,EFR32BG21A010F512IM32-B,EFR32BG21B020F768IM32-D,EFR32BG21B010F512IM32-D,EFR32BG21B020F768IM32-B,EFR32BG21A010F512IM32-D,EFR32BG21B020F512IM32-D,EFR32BG21B020F512IM32-B,EFR32BG21A020F1024IM32-B,EFR32BG21A020F512IM32-B,EFR32BG21,EFR32BG21A010F1024IM32-D,EFR32BG21A020F512IM32-D,EFR32BG21A010F1024IM32-B,EFR32BG21A020F1024IM32-D,EFR32BG21A010F768IM32-D,EFR32BG21B010F768IM32-B,EFR32BG21A010F768IM32-B,EFR32BG21B010F768IM32-D,EFR32BG21B020F1024IM32-B,EFR32BG21B010F1024IM32-D

数据手册  -  SILICON LABS  - Rev. 1.2  - May, 2024 PDF 英文 下载

展开更多

电子商城

查看更多

只看有货

品牌:SILICON LABS

品类:Wireless Gecko SoC

价格:¥15.1445

现货: 16,249

品牌:SILICON LABS

品类:开发工具

价格:

现货: 0

品牌:SILICON LABS

品类:Demo Board

价格:

现货: 0

品牌:SILICON LABS

品类:开发工具

价格:¥151.7235

现货: 0

品牌:SILICON LABS

品类:8位MCU

价格:¥26.2935

现货: 0

品牌:利成

品类:IoT GateWay 网关

价格:¥300.0000

现货: 100

品牌:MELEXIS

品类:LIN-to-LIN Gateway/LIN RGB Controller

价格:¥26.1114

现货: 62

品牌:WAGO

品类:WLAN以太网网关

价格:¥7,104.8185

现货: 6

品牌:MELEXIS

品类:Evaluation PCB

价格:¥1,306.5060

现货: 1

品牌:WAGO

品类:CAN网关

价格:¥4,661.3065

现货: 0

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

现货市场

查看更多

品牌:MICREL

品类:集成电路

价格:¥29.2296

现货:28

品牌:MICREL

品类:集成电路

价格:¥236.4773

现货:11

品牌:SILICON LABS

品类:Switch Hall Effect Magnetic Position Sensor

价格:¥2.2924

现货:150,000

品牌:SILICON LABS

品类:Light Sensor

价格:¥20.3400

现货:28,003

品牌:SILICON LABS

品类:Position Sensor

价格:¥3.0897

现货:12,568

品牌:SILICON LABS

品类:8位MCU

价格:¥4.9000

现货:12,000

品牌:SILICON LABS

品类:Mixed-Signal MCU

价格:¥10.1700

现货:10,000

品牌:SILICON LABS

品类:Gecko MCU

价格:¥15.6000

现货:5,353

品牌:SILICON LABS

品类:8 BIT MCU

价格:¥3.7900

现货:3,451

品牌:SILICON LABS

品类:Wireless SoC

价格:¥15.1400

现货:1,455

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

品牌:

品类:

价格:

现货:

服务

查看更多

IoT射频性能测试

支持 3Hz ~ 26.5GHz射频信号中心频率测试;9kHz ~ 3GHz频率范围内Wi-SUN、lora、zigbee、ble和Sub-G 灵敏度测量与测试,天线阻抗测量与匹配电路调试服务。支持到场/视频直播测试,资深专家全程指导。

实验室地址: 深圳/苏州 提交需求>

SMT贴片加工

可贴PCB板厚范围:0.6~2.0mm,也支持生产软硬接合板,拼板长宽:50*50mm~550*500mm,PCBA快速贴片支持01005CHIP元件。

最小起订量: 1片 提交需求>

世强和原厂的技术专家将在一个工作日内解答,帮助您快速完成研发及采购。
我要提问

954668/400-830-1766(工作日 9:00-18:00)

service@sekorm.com

研发客服
商务客服
服务热线

联系我们

954668/400-830-1766(工作日 9:00-18:00)

service@sekorm.com

投诉与建议

E-mail:claim@sekorm.com

商务合作

E-mail:contact@sekorm.com

收藏
收藏当前页面