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. 比较好的sql写法

    DECLARE @beginTime VARCHAR(20)= '2017-11-13 00:00:00';DECLARE @endTime VARCHAR(20)= '2017-11-13 23:0 ...

  2. 总结django知识点

    一.视图函数:     请求对象-----------request:           1.HttpRequest.body:         请求原数据           2.HttpRequ ...

  3. review34

    Thread类与线程的创建 让线程启动时使用我们自己创建run()的两种方式:一种是继承Thread类,实现其中的run()方法,然后用继承的类用无参构造方法创建对象就可以了.第二种是实现Runnab ...

  4. Memcache面试题

    * memcached是怎么工作的? * memcached最大的优势是什么? * memcached和MySQL的query cache相比,有什么优缺点? * memcached和服务器的loca ...

  5. mac实用脚本

    安全清倒废纸篓(AppleScript) on run {input, parameters} set title to "安全清倒废纸篓" set trashIsEmptyMes ...

  6. python MySQLdb连接mysql失败(转载)

    最近了解了一下django,数据库选用了mysql, 在连接数据库的过程中,遇到一点小问题,在这里记录一下,希望能够对遇到同样的问题的朋友有所帮助,少走一些弯路.关于django,想在这里也额外说一句 ...

  7. [1]移动端页面调试之“weinre大法”

    前言 这个也是从早读课转载的.如有侵权请联系我马上下架. 正文从这开始-- 移动端页面调试一般分两步.第一步我们需要把本地(pc端)写的页面效果展现在移动端,一个很方便的办法是用 fiddler 作为 ...

  8. 第二次ScrumMeeting

    每个人的工作(有Issue的内容和链接):昨天已完成的工作,今天计划完成的工作:工作中遇到的困难. 团队成员 昨日完成任务 明日要完成的任务 易子沐 前端框架学习 issue16 搭建主页框架 iss ...

  9. 常用服务搭建(nfs/ftp/samba)

    一. NFS1. NFS简介NFS全称是network file systemNFS允许一个系统在网络上与他人共享目录和文件.通过使用NFS,用户和程序可以像访问本地文件一样访问远端系统上的文件. 假 ...

  10. 使用BackgroundWorker组件

    BackgroundWorker 组件用来执行诸如数据库事务.文件下载等耗时的异步操作. 开始 在应用程序中添加一个BackgroundWorker实例,如果用的是VS,可以从工具上直接拖到应用程序: ...