delphi 蓝牙 TBluetoothLE
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的更多相关文章
- TBluetoothLE
delphi 蓝牙技术 D:\Users\Public\Documents\Embarcadero\Studio\17.0\Samples\Object Pascal\Multi-Device Sam ...
- Delphi IOS 蓝牙锁屏后台运行
Delphi IOS 后台运行 同样的程序,编译成android,锁屏后继续运行正常,蓝牙通讯正常,但在IOS下锁屏后程序的蓝牙就中断通讯了? IOS的机制就是这样,锁屏就关闭了. 音乐播放器是怎么做 ...
- Android实例-Delphi开发蓝牙官方实例解析(XE10+小米2+小米5)
相关资料:1.http://blog.csdn.net/laorenshen/article/details/411498032.http://www.cnblogs.com/findumars/p/ ...
- Delphi XE7的蓝牙 Bluetooth
Delphi XE7已经内建了蓝牙功能,提供了System.Bluetooth.pas单元 顾名思义,System表示XE7的蓝牙功能可以在Windows,Android,IOS系统内使用 Syste ...
- delphi xe5 android 控制蓝牙
本文部分内容摘自: http://www.pclviewer.com/android/用以下代码中的接口实现控制蓝牙的开.关及详细信息 unit Androidapi.JNI.BluetoothAda ...
- delphi xe10 蓝牙
//蓝牙 System.Bluetooth //单元中主要包含以下几个类 TBluetoothManager.TBluetoothDeviceList.TBluetoothAdapter.TBluet ...
- Delphi XE5 android 蓝牙通讯传输
不多讲,直接上代码了. 代码来自网络 http://files.cnblogs.com/nywh2008/Bluetooth_LEDs_android.rar
- delphi 演示数据路径
链接里默认的--------------------------- Error --------------------------- I/O error for file "C:\Prog ...
- Delphi 和 C++Builder 2014年及以后技术路线图
RAD Studio, Delphi 和 C++Builder 2014年及以后技术路线图 By: Embarcadero News 内容源自Embarcadero新闻组,本人水平有限,欢迎各位高人修 ...
随机推荐
- PostgreSQL的日志文件介绍
PostgreSQL的日志文件 pg_log:数据库活动日志(也就是数据库的操作日志): pg_xlog:事务日志: pg_clog:事务状态日志(pg_clog是pg_xlog的辅助日志). 现在主 ...
- Windows10安装Linux子系统
在win10上面可以直接在powershell里面安装Linux,具体步骤如下: 首先我们要打开Windows功能 在这里把勾打上 然后打开设置>>更新和安全>>针对开发人员, ...
- 原生js模态框实现
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...
- HTML代码中的空格和空行
HTML 代码中的所有连续的空格或空行(换行)都会被显示为一个空格. 例子1:(文本内容中的连续空格) 代码 <p>这段文本中,输入连续的空格 大概输入了十个.</p> 显示效 ...
- /var/adm/wtmp文件太大该怎么办?
/var/admin/wtmp文件记录所有用户的登陆信息,随着时间会增长到很大,/var/adm/wtmp文件太大该怎么办呢?先来看看/var/adm/wtmp文件的属性:testterm1:/#ls ...
- C#多线程操作
static void Main(string[] args) { Thread thread = Thread.CurrentThread; thread.Name = "Main Thr ...
- redis有序集合的使用
Redis 有序集合(sorted set) Redis 有序集合和集合一样也是string类型元素的集合,且不允许重复的成员. 不同的是每个元素都会关联一个double类型的分数.redis正是通过 ...
- myeclipse2014中如何安装freeMarker插件(支持ftl语法高亮)
MyEcplise2014安装Freemarker插件(支持.ftl文件) 1.下载插件:http://sourceforge.net/projects/freemarker-ide/?source= ...
- AMD 规范使用总结
转自:http://www.jianshu.com/p/9b44a1fa8a96 AMD模式 define和require这两个定义模块.调用模块的方法,合称为AMD模式.它的模块定义的方法非常清晰, ...
- 排列(加了点小set就过了,哈哈哈)
Ray又对数字的列产生了兴趣: 现有四张卡片,用这四张卡片能排列出很多不同的4位数,要求按从小到大的顺序输出这些4位数. 输入描述: 1 2 3 4 1 1 2 3 0 1 2 3 0 0 0 0输出 ...