简体   繁体   English

如何将自己的服务添加到BLE应用程序?

[英]How do I add my own service to a BLE application?

I am currently working on an Android BLE app with which I want to connect to a Nucleo IDB05A1. 我目前正在开发一个Android BLE应用程序,我想连接到Nucleo IDB05A1。 I looked into the examples given for both sides, meaning the Bluetooth Le Gatt example app and some example code for the Nucleo. 我查看了双方给出的示例,这意味着蓝牙Le Gatt示例应用程序和Nucleo的一些示例代码。 Discovering and connecting to the device works fine, I played a little bit with the code and can read as well as write the given characteristics on the Nucleo. 发现并连接到设备工作正常,我玩了一些代码,可以读取以及在Nucleo上写出给定的特征。

My problem now is that I want to add a custom service to (for example) write text on my phone, write it to a custom characteristic of this service so that I can put it on UART with the Nucleo board. 我现在的问题是,我想添加一个自定义服务(例如)在手机上写文本,将其写入此服务的自定义特征,以便我可以将其放在带有Nucleo板的UART上。 Unfortunately, I could not find a proper explanation on how to develop an own BLE service. 不幸的是,我找不到关于如何开发自己的BLE服务的正确解释。

I would really appreciate some help on both the Android code and the code for my uC (Nucleo F401RE with Nucleo IDB05A1 BLE module). 我非常感谢Android代码和我的uC代码(Nucleo F401RE与Nucleo IDB05A1 BLE模块)的一些帮助。

Best approach for that should be to determine what exact BLE stack is used for Nucleo (I don't know details for ST since I've been working mostly with TI or Nordic). 最好的办法应该是确定Nucleo使用了哪些精确的BLE堆栈(我不知道ST的详细信息,因为我主要使用TI或Nordic)。 After that, you should try to find documentation for exact BLE stack and start to analyse your working example. 之后,您应该尝试查找精确BLE堆栈的文档并开始分析您的工作示例。

Point that you have to check are: 你要检查的要点是:

  • Stack initialization 堆栈初始化
  • Stack callbacks 堆栈回调
  • Advertisement data 广告数据
  • Services declaration (usually a structure that describes service) 服务声明(通常是描述服务的结构)
  • Characteristics declaration (usually set of properties that have to be set in order to define custom service) 特征声明(通常为了定义自定义服务而必须设置的属性集)

After you understand mentioned above, I would suggest you to start from Advertisement data changing and go further into development of custom service. 在您了解上述内容后,我建议您从广告数据更改开始,进一步开发自定义服务。

Hope it helps... 希望能帮助到你...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ANDROID STUDIO BLE:如何将 LeDeviceListAdapter 类添加到我的 BLE 项目中? - ANDROID STUDIO BLE: How do I add the LeDeviceListAdapter class to my BLE project? 如何添加安装我自己的LocationProvider? - How do I add install my own LocationProvider? 仅当我的应用程序处于活动状态且在后台运行且未被破坏时,如何在后台运行 BLE 扫描? - How do I run a BLE scan in the background only if my application is alive and in the background as well and not destroyed? 我的BLE GATT服务应用程序不断崩溃 - My BLE GATT service application keep crashing 如何增加BLE应用程序的吞吐量? - How can I increase the throughput of my BLE application? 如何启用通知并能够读取我的 BLE 代码? - How do I enable notifications and to be able read in my BLE code? 如何获得视频录制应用程序的服务计时器? - How do i get service timer for my video recording application? 有没有一种方法可以向正在测试的应用程序添加权限? (我自己的应用) - Is there a way to add a permission to an application I'm testing? (my own app) 我可以在自己的Android应用程序中添加自己的广告吗? 这不是违反使用条款吗? - Can I add my own adverts in my own Android application? Isn't that against the terms of use? 我的Android应用程序中是否需要服务? - Do I need a Service in my android application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM