简体   繁体   English

蓝牙 LE 通过应用程序在 Android 设备之间发送字符串数据

[英]Bluetooth LE send string data between Android devices via application

I'm completely clueless on how to use BLE.我对如何使用BLE完全一无所知。 I need to create an application for Android devices that sends a small string from one Android device to the other.我需要为 Android 设备创建一个应用程序,该应用程序将一个小字符串从一个 Android 设备发送到另一个设备。 I am NOT using any sensor type devices.我没有使用任何传感器类型的设备。 I only need to send a string from one phone to another phone using a BLE connection.我只需要使用 BLE 连接将字符串从一部手机发送到另一部手机。 From what I understand, I need to create a custom service and implement a GATT server on a central device and have a peripheral device access it as a client but I'm not even sure if that's what I need for my situation.据我了解,我需要创建一个自定义服务并在中央设备上实现一个 GATT 服务器,并让外围设备作为客户端访问它,但我什至不确定这是否是我所需要的。 I have scoured the internet and nothing I have found deals with this topic specifically.我已经在互联网上搜索过,但没有找到专门针对这个主题的交易。 I have no idea how to create a GATT server for this purpose and what I need to include in order to create a service.我不知道如何为此目的创建 GATT 服务器,以及创建服务需要包含什么。 Can someone please explain to me what I need to do or point me towards some resources that are useful for A COMPLETE NOVICE?有人可以向我解释我需要做什么或向我指出一些对完全新手有用的资源吗? Thanks.谢谢。

You are right so far.到目前为止你是对的。 You need to create two applications on two different Android devices as follows:-您需要在两个不同的 Android 设备上创建两个应用程序,如下所示:-

  • Android App A on Device #1: An app to act as a GATT Server to host your data that you want to send. Android 设备 #1 上的应用程序 A:充当GATT 服务器的应用程序,用于托管您要发送的数据。 For that, you will need GATT Server API .为此,您将需要GATT 服务器 API
  • Android App B on Device #2: An app to act as a GATT Client to connect to Device #1 and read the string data from the GATT Server using GATT Client API . Android 设备 #2 上的应用 B:作为GATT 客户端连接到设备 #1 并使用GATT 客户端 API从 GATT 服务器读取字符串数据的应用。

BLE is a relatively complex technology but luckily there are so many resources to help you get started. BLE 是一项相对复杂的技术,但幸运的是,有很多资源可以帮助您入门。 I recommend that you first understand how BLE technology works and for that I the following links are useful:-我建议您首先了解 BLE 技术的工作原理,为此,以下链接很有用:-

Once you have a better understanding of the protocol, the following links are useful for understanding Android BLE development (in addition to the video posted in the comment):-一旦您对协议有了更好的了解,以下链接有助于了解 Android BLE 开发(除了评论中发布的视频):-

However, before going through any of these, it's always a good idea to get a feel and practical understanding of how the technology works.但是,在进行任何这些操作之前,最好先感受一下并实际了解该技术的工作原理。 For that I recommend using the nRF Connect Android app to connect and read data off devices.为此,我建议使用nRF Connect Android应用程序连接和读取设备数据。 This way, you'll be able to relate to the new information and hopefully understand the new concepts easier.这样,您将能够与新信息相关联,并希望更容易理解新概念。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM