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


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.
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
- |
- +1 赞 0
- 收藏
- 评论 0
本文由PlusLee转载自Dusun Blogs,原文标题为:How to Develop an Application connected with BLE 5 Devices on Dusun’s Gateways,本站所有转载文章系出于传递更多信息之目的,且明确注明来源,不希望被转载的媒体或个人可与我们联系,我们将立即进行删除处理。
相关推荐
【经验】EFR32BG21系列蓝牙BootLoader生成与烧录的操作流程和注意细节
Silicon Labs公司针对蓝牙应用的开发,经常用到的UART BootLoader或者也叫Gecko bootloader。但并不是默认加入到蓝牙工程中的,芯片上电以后应用代码是无法运行的。所以每一个蓝牙的工程都需要烧录一个Gecko bootloader。本文指导一步一步操作生成一份EFR32BG21系列芯片的bootloader工程代码。
Silicon Labs EFR32BG21 蓝牙SoC RCP模式测试-扫描设备
本文介绍测试EFR32BG21 蓝牙RCP模式工作在主模式,用于扫描蓝牙从设备,建立蓝牙连接和收发数据。首先需要准备一台电脑并且已经安装好了linux系统。也可以是windows系统下安装的linux虚拟机。并且已经安装好了蓝牙BlueZ协议栈。
How to Reduce Gateway Energy Consumption in the Smart Home with Low-Power Mesh Technology
This blog describes Silicon Labs’ new patent-pending Low-power Mesh Technology, which can significantly reduce energy consumption on any manufacturer’s CPE while improving the smart home user experience.
【经验】如何使用树莓派开发 ZigBee 网关?
在 Zigbee 系统中,网关是一个非常重要的设备,为了能容纳更大的网络及更复杂的应用逻辑,一个强大的主机是不可或缺的,树莓派就是这样一个强大的开发平台,非常适合用来构建 host application,这个文章将描述如何设置树莓派来开发 Silicon Lbas EmberZNet ZigBee Gateway。
【经验】EFR32BG21蓝牙绑定的操作流程
我们在使用EFR32BG21做产品时,有时会遇到需要配对、绑定的一些操作,做这些操作时要调用哪些API函数去实现呢?本文就用Silicon Labs的两块蓝牙SOC EFR32BG21的开发板测试一下这个功能。
Z/IP网关拒绝服务漏洞安全公告
本安全通告针对Silicon Labs的Z/IP网关产品存在的高危拒绝服务漏洞。该漏洞可能导致设备服务暂时中断和网络连接问题。具体包括CVE-2024-3051和CVE-2024-3052两个编号的安全漏洞,分别对应不同的攻击方式。目前,已发布补丁版本以缓解这些问题,用户应升级至相应版本以修复漏洞。同时,建议咨询Z-Wave联盟确认重新认证的要求。
SILICON LABS - CVE-2024-3051,CVE-2024-3052
【经验】蓝牙MESH网关程序中的Vendor Model的OpCode的设置
在使用FR32BG21开发蓝牙MESH网关的程序时,我们有时需要使用Vendor Model功能,这时我们需要定义OpCode,在程序中我们可以查到默认定义了两个Opcode:0X00,0X01,这个定义与SIG标准有些冲突,这是什么原因?我们要如何定义OpCode?
【经验】EFR32BG21蓝牙SOC在作为NCP模式时数据的校验处理
Silicon Labs推出的EFR32BG21蓝牙SOC在蓝牙网关的应用中多数是以协处理器(NCP)模式工作的。在这种模式下EFR32BG21是通过UART接口与主机通信,通信时使用BGAPI的命令格式收发命令/事件的数据。
东胜无线4G IoT Gateway如何连接到AT&T LTE-M网络?
AT&T在美国完成对其4G LTE蜂窝站点的升级后,正式启用了其CatM1和窄带物联网(NB-IoT)网络。东胜物联公司开发了一款4G LTE物联网网关,支持AT&T LTE-M移动网络连接云。本文将讨论什么是LTE-M / NB-IoT以及如何在东胜物联网网关上使用AT&T LTE-M服务。
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.
zigbee sdk_6.7.3, Z3GatewayHost控制zigbee子设备的时候Z3GatewayHost日志报错: ERROR: tx 66, Profile: HA (0x0104), Cluster: 0x0006, 3 bytes, ZCL Cluster Cmd ID: 1 D59F failed with code 66 ROUTE REPAIR SERVICE RETURN RESULT: status=4 有时候会报: ROUTE REPAIR SERVICE RETURN RESULT: status=0 请问这个问题怎么解决?
使用SiliconLabs的Zigbee 方案EFR32MG21A020F768IM32做Zigbee应用,tx66表示发送数据不成功,子设备(我想一定是休眠子设备)没有及时唤醒去Poll其父设备,导致发送失败。会返回该错误。route repair表示该设备已经丢失,网关无法找到该设备,需要子设备主动发送数据过来才会修复。
AN1387:备份和恢复Z3绿色电源组合网关
本文档详细介绍了如何在Z3 Gateway GP Combo场景应用中使用备份和恢复功能。主要内容包括备份和恢复的基本工作原理、涉及的组件、Token文件格式、EUI64 Token的保存和恢复、示例构建、功能测试以及局限性。文档涵盖了从NCP到Host的Token备份和恢复过程,以及如何使用Simplicity Studio构建示例应用进行测试。同时,也指出了该功能的一些限制,如仅适用于NVM3堆栈Token组、备份过程可能受到网络活动影响等。
SILICON LABS
【经验】Zigbee host与Gateway无法连接问题如何解决?
在笔者的Zigbee智能模块项目中,需要在SimplicityStudio V5软件中调试Zigbee连接host与gateway。实际调试过程中没有成功提示ERROR: ezspForceReset 0x21,本文就此分析问题原因并解决。
Custom Smart Home Hub with DSGW-210 IoT Gateway,a Backup Solution of Raspberry Pi 3
DSGW-210 (Dusun Pi 3+) is an IoT edge-computing gateway that supports multiple operating systems and wireless protocols for flexible selection, which is a backup solution of Raspberry Pi 3 to help customer develop their own IoT devices in a cost-effective way.
无线Gecko Bluetooth®低能耗SoC EFR32BG21勘误表
本资料详细介绍了EFR32BG21无线Gecko蓝牙低功耗SoC的已知错误(Errata)。资料中列出了所有已知的错误和未解决的错误,并提供了每个错误的描述、影响、解决方案和可能的解决方法。资料还包含了已解决错误的描述,以及如何识别芯片版本的信息。
SILICON LABS - SOC,EFR32BG21
电子商城
品牌:SILICON LABS
品类:Wireless Gecko SoC
价格:¥24.8076
现货: 11,239
品牌:MELEXIS
品类:LIN-to-LIN Gateway/LIN RGB Controller
价格:¥26.1114
现货: 42
品牌:MELEXIS
品类:LIN-to-LIN Gateway/LIN RGB Controller
价格:¥16.0552
现货: 0
现货市场
品牌:SILICON LABS
品类:Switch Hall Effect Magnetic Position Sensor
价格:¥2.2924
现货:126,000
服务

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

可定制LAMP LED、 CHIP LED、 PLCC LED、 汽车用车规级LED、COB LED的尺寸/电压/电流等参数,电压1.5-37V,电流5-150mA,波长470-940nm。
最小起订量: 30000 提交需求>
登录 | 立即注册
提交评论