delphi 蓝牙 TBluetoothLE、TBluetoothLEManager BLE

http://docwiki.embarcadero.com/RADStudio/Seattle/en/Using_Bluetooth_Low_Energy

指定UUID

HRSERVICE: TBluetoothUUID = '{0000180D-0000-1000-8000-00805F9B34FB}';
HRMEASUREMENT_CHARACTERISTIC: TBluetoothUUID = '{00002A37-0000-1000-8000-00805F9B34FB}';
BODY_SENSOR_LOCATION_CHARACTERISTIC: TBluetoothUUID = '{00002A38-0000-1000-8000-00805F9B34FB}';

1、搜索设备

方法一、

BluetoothLE1.DiscoverDevices(4000);

方法二、

HRSERVICE: TBluetoothUUID = '{0000180D-0000-1000-8000-00805F9B34FB}';

BluetoothLE1.DiscoverDevices(2500, [HRSERVICE]);

触发事件

BluetoothLE1EndDiscoverDevices

BluetoothLE1DiscoverLEDevice

2、搜索服务

BluetoothLE1.DiscoverServices(FCurrentDevice)//搜索所有服务

BluetoothLE1.DiscoveredDevices[ListBox1.ItemIndex].DiscoverServices

FGattService:=BluetoothLE1.GetService(FBLEDevice, HRSERVICE);//搜索指定UUID服务,同于第一步的UUID

3、查询特征

BluetoothLE1.GetCharacteristics(FWeightGattService);//特征列表

BluetoothLE1.GetCharacteristic(FWeightGattService, UUIDchar);//UUID指定的某个特征

FWeightMeasurementGattCharacteristic := BluetoothLE1.GetCharacteristic(FGattService,Weight_CHARACTERISTIC);

触发事件

BluetoothLE1EndDiscoverServices

搜索Characteristics

for C := 0 to AServiceList[I].Characteristics.Count - 1 do
ListBox2.Items.Add(' - ' + AServiceList[I].Characteristics[C].UUIDName + ' - ' + AServiceList[I].Characteristics[C].UUID.ToString);

4、订阅

BluetoothLE1.SubscribeToCharacteristic(FBLEDevice, FHRMeasurementGattCharact);

BluetoothLE1.SubscribeToCharacteristic(FBLEDevice, FWeightMeasurementGattCharacteristic);

ADevice.SetCharacteristicNotification(ACharacteristic, True)

 5、发送数据

BluetoothLE1.WriteCharacteristic(TBluetoothLEDevice ADevice,TBluetoothGattCharacteristic ACharacteristic);

ADevice.WriteCharacteristic(AChar);

FGattChar.SetValue(sbytes);
bflag := FCurrentDevice.WriteCharacteristic(FGattChar)

6、接收数据

procedure BluetoothLE1CharacteristicRead(const Sender: TObject; const ACharacteristic: TBluetoothGattCharacteristic;
AGattStatus: TBluetoothGattStatus);

7、断开

BluetoothLE1.UnSubscribeToCharacteristic(FBLEDevice, FWeightMeasurementGattCharacteristic);

BluetoothLE1.UnSubscribeToCharacteristic(FBLEDevice, FHRMeasurementGattCharact);

ADevice.SetCharacteristicNotification(ACharacteristic, False)

http://blogs.embarcadero.com/sarinadupont/2014/10/20/creating-a-bluetooth-le-cloud-enabled-luggage-scale-application/

delphi 蓝牙 TBluetoothLE的更多相关文章

  1. TBluetoothLE

    delphi 蓝牙技术 D:\Users\Public\Documents\Embarcadero\Studio\17.0\Samples\Object Pascal\Multi-Device Sam ...

  2. Delphi IOS 蓝牙锁屏后台运行

    Delphi IOS 后台运行 同样的程序,编译成android,锁屏后继续运行正常,蓝牙通讯正常,但在IOS下锁屏后程序的蓝牙就中断通讯了? IOS的机制就是这样,锁屏就关闭了. 音乐播放器是怎么做 ...

  3. Android实例-Delphi开发蓝牙官方实例解析(XE10+小米2+小米5)

    相关资料:1.http://blog.csdn.net/laorenshen/article/details/411498032.http://www.cnblogs.com/findumars/p/ ...

  4. Delphi XE7的蓝牙 Bluetooth

    Delphi XE7已经内建了蓝牙功能,提供了System.Bluetooth.pas单元 顾名思义,System表示XE7的蓝牙功能可以在Windows,Android,IOS系统内使用 Syste ...

  5. delphi xe5 android 控制蓝牙

    本文部分内容摘自: http://www.pclviewer.com/android/用以下代码中的接口实现控制蓝牙的开.关及详细信息 unit Androidapi.JNI.BluetoothAda ...

  6. delphi xe10 蓝牙

    //蓝牙 System.Bluetooth //单元中主要包含以下几个类 TBluetoothManager.TBluetoothDeviceList.TBluetoothAdapter.TBluet ...

  7. Delphi XE5 android 蓝牙通讯传输

    不多讲,直接上代码了. 代码来自网络 http://files.cnblogs.com/nywh2008/Bluetooth_LEDs_android.rar

  8. delphi 演示数据路径

    链接里默认的--------------------------- Error --------------------------- I/O error for file "C:\Prog ...

  9. Delphi 和 C++Builder 2014年及以后技术路线图

    RAD Studio, Delphi 和 C++Builder 2014年及以后技术路线图 By: Embarcadero News 内容源自Embarcadero新闻组,本人水平有限,欢迎各位高人修 ...

随机推荐

  1. javascript的宿主环境

    关于javascript语言,最有意思的是它必须要在一个宿主环境中运行,其中受欢迎的宿主环境当然就是浏览器了,但这并不是我们唯一的选择, javascript完全可以运行在服务器端,桌面以及富媒体环境 ...

  2. Spring Boot入门——JPA

    JPA最大的特点就是可以根据@Entity自动创建你数据库表,用户只需要声明持久层的接口,不需要实现该接口 1.JPA概念 JPA全称Java Persistence API,JPA通过JDK5.0注 ...

  3. PHP使用header+Location实现网站301重定向

    对于我们SEO人员来说,有的时候需要对网站进行重定向.一般来说,对网站重定向的http返回状态码是301和302两种.下面兰州SEO就通过实例来为你介绍一下怎样通过PHP使用header+Locati ...

  4. liunx常用命令-----查找命令

    locate 根据文件名查找文件 根据数据库记录搜索,当天创建的搜不到 whereis which  搜索命令的命令   如 whereis ls find   /root   -name       ...

  5. PyCharm 的初始设置2 - 打开、新建项目

    03. 新建/打开一个 Python 项目 3.1 项目简介 开发 项目 就是开发一个 专门解决一个复杂业务功能的软件 通常每 一个项目 就具有一个 独立专属的目录,用于保存 所有和项目相关的文件 – ...

  6. 条款47:请使用traits class表示类型信息

    在stl的算法中,我们的希望往往是根据不同的迭代器类型进行不同的更有效率的操作: template<typename IterT, typename DistT> void advance ...

  7. MyISAM引擎的特点及优化方法

    1.什么是MyISAM引擎?MyISAM引擎是MySQL关系数据库管理系统的默认存储引擎(MySQL5.5.5以前),这种MySQL的表存储结构从旧的ISAM代码扩展出许多有用的功能.在存储的时候,每 ...

  8. vs2012 sln和.vcxproj有什么区别

    sln是解决方案的配置,主要是管理这个方案里的多个vcxprojvcxproj是工程的配置文件,管理工程中细节比如包含的文件,引用库等一般没有sln,也可以直接打开vcxproj,也可以重新生成sln ...

  9. C中的时间函数的用法

    C中的时间函数的用法    这个类展示了C语言中的时间函数的常用的用法. 源代码: #include <ctime>#include <iostream> using name ...

  10. CodeForces - 682E: Alyona and Triangles(旋转卡壳求最大三角形)

    You are given n points with integer coordinates on the plane. Points are given in a way such that th ...