标签: characteristics

如何在Android中为BLE写出连续快速稳定的特性?

我在Android中开发BLE,我可以扫描,连接和写入BLE设备的特性.

我调用下面的函数传递BluetoothGatt,并characteristicAsyncTask当点击Button.

write_btn.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {
        new WriteCharacteristic(mBluetoothGatt , HueCharacteristic).execute();
     }
});
Run Code Online (Sandbox Code Playgroud)

写特性的代码如下:

private class WriteCharacteristic extends AsyncTask<String, Void, String> {

        public BluetoothGatt mGatt;
        public BluetoothGattCharacteristic mCharacteristic;

        public WriteCharacteristic(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic){
            mGatt = gatt;
            mCharacteristic = characteristic;
        }

        @Override
        protected String doInBackground(String... urls) {
            mGatt.writeCharacteristic(mCharacteristic);
            return null;
        }
    }
Run Code Online (Sandbox Code Playgroud)

但我尝试点击该按钮连续,看来Android的没有每次写入characteristicBLE装置.

如果我连续点击按钮5次,则会丢失1~3次.它只能写characteristicBLE装置两次.

题:

Is there any better …

android characteristics bluetooth-lowenergy

13
推荐指数
1
解决办法
4815
查看次数

Android如何阅读BLE属性可读写可通报的GATT特性

如何阅读BluetoothGattCharacteristic属性,如特征Readable,WritableNotifiable.

android characteristics bluetooth-lowenergy gatt

11
推荐指数
1
解决办法
6353
查看次数

如何在Xamarin/Android上启用多个BLE特征通知?

我正在尝试使用Xamarin/Android启用多个BLE特性的通知,但似乎无法这样做.如果我尝试一次启用多个BLE事件,该应用程序似乎停止接收任何BLE事件.

任何人都可以使用Tamarin/Android确认这是否可行.我们有一个原生的iOS应用程序,可以正常启用多个通知.我们使用的基本步骤如下:

  1. 扫描设备
  2. 连接到设备
  3. 发现服务
  4. 对于每个发现的服务,迭代特征并启用所需的服务
  5. 处理BLE回调中的每个异步回调事件

每当我们尝试在多个特征上启用通知时,我们就不再接收任何事件.

我也无法找到任何启​​用多个特性的示例.

我希望我在这里错过了使用Xamarin/Android API的基本信息.

public override void OnServicesDiscovered (BluetoothGatt gatt, GattStatus status)
{
    base.OnServicesDiscovered (gatt, status);
    foreach (BluetoothGattService service in gatt.Services) {
        string uuid = service.Uuid.ToString ().ToUpper();
        if (uuid.Equals (BLEServices.HRService.ToUpper())) {
            _Adap.LogMessage ("HRService discovered");
            foreach(BluetoothGattCharacteristic characteristic in service.Characteristics) {
                string c_uuid = characteristic.Uuid.ToString ().ToUpper ();
                _Adap.LogMessage (" HRCharacteristic: " + c_uuid);

                if (c_uuid.Equals(_Adap.useCharacteristic.ToUpper())) {
                    _Adap.LogMessage ("  enabling HRCharacteristic");
                    gatt.SetCharacteristicNotification(characteristic, true);
                    BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor (Java.Util.UUID.FromString (BLEServices.CLIENT_CHARACTERISTIC_CONFIG), GattDescriptorPermission.Write | GattDescriptorPermission.Read);
                    characteristic.AddDescriptor (descriptor);
                    descriptor.SetValue …
Run Code Online (Sandbox Code Playgroud)

notifications xamarin.android characteristics bluetooth-lowenergy xamarin

10
推荐指数
1
解决办法
1620
查看次数

静态数组的定义

我一直在寻找一个不错的静态数组定义.我尝试过使用msdn和c#来源,但似乎无法找到定义.它举例说明,但没有定义......

有谁知道静态数组的任何链接或定义和特征吗?

c# arrays static definition characteristics

7
推荐指数
2
解决办法
3万
查看次数

如何从Swift的蓝牙特性中获取数据

我现在周围有一个Polar h7设备(它是BTLE)而且我已经完成了所有工作,但我很困惑如何获得BPM我们characteristic.value现在正在更新.我必须将一些字节转换为bpm ...

我的外设正在更新:

func peripheral(peripheral: CBPeripheral!, didUpdateValueForCharacteristic characteristic: CBCharacteristic!, error: NSError!) {
    if characteristic.UUID == CBUUID.UUIDWithString(heartRateChar) {
        getInfoAboutHeartRate(characteristic)
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到有关心率的信息:

func getInfoAboutHeartRate(characteristic:CBCharacteristic) {
    println(characteristic.value)
    var bytes = characteristic.value.bytes
}
Run Code Online (Sandbox Code Playgroud)

我知道我需要将这些字节转换为BPM.
根据规格(这是我困惑的地方)在bluetooth.org,字节0要么是a 1还是0..如果是0心率值是a uint8,如果它是a 1那么它是a uint16和我可以从中获得BPM.
如何确定byte 0是a 1还是a 0?如何把它变成一个uint8uint16.如果我这样做,我会直接获得BPM,还是必须为此做其他事情?现在,BPM回归到了<16447d03>有意义的东西.

bluetooth characteristics ios btle swift

7
推荐指数
1
解决办法
8308
查看次数

HM10 ble改变特征值AT命令Arduino

任何人都可以帮助我使用AT命令写入特征值,或者如何使用Hm10模块将数据从arduino发送到另一个ble设备.

HM10发送AT + START后,确实发布了数据包,并且可以检测服务和特性,但是特征值是默认值0x00,我该如何改变呢?

已多次检查数据表,但找不到能够执行相同操作的AT命令.

更新:在中央模式下设置HM10的类似问题:

中央模式设置!

1)AT + ROLE1 - 设置为中央模式

2)AT + IMME1 - 从RESET开始

3)AT + SHOW1 - 显示发现的设备

4)AT + DISC? - 发现设备获取设备MAC ID,

5)AT + CON [MAC ID]

结果:总是给OK + CONNA,10秒后OK + CONNF

我很困惑,在"AT + DISC"之前使用"AT + START"?导致AT + START不起作用,反之亦然.使用AT + START结果进入OK + CONN循环,然后连续OK + LOST,不再接受AT命令.我相信它确实会产生一个

你能按正确的顺序提出建议吗?

使用LightBlue iOS应用程序作为外围设备.我如何选择服务并订阅特征以从应用程序接收数据?

谢谢.

arduino at-command characteristics bluetooth-lowenergy hm-10

7
推荐指数
2
解决办法
2万
查看次数

看不懂特色.Android BLE

我想将我的远程BLE设备的特定数据的数据读取到我的Android平板电脑Nexus 7.

问题是,即使没有打电话,我也可以通过启用该特性的通知来接收数据readCharacteristic.但是,readCharacteristic如果不启用通知,我无法通过调用成功读取特征.

mBluetoothGatt.readCharacteristic(characteristic)返回false.因此,该功能onCharacteristicRead从未被触发过.我还检查了属性值BluetoothGattCharacteristic.PROPERTY_READ,它是30.

有没有人对这里发生的事情有所了解?我真的需要分别阅读这个特性.因为如果我只根据通知分析数据,我无法弄清楚数据的开始位置.这是因为我的设备每次都会发送12bytes.它会不断发送字节数组.但是,通知会一次一个字节地给我带来数据.所以我不知道哪个是字节数组的起始字节.

我正在使用Android提供的示例代码.

这是片段:

public void readCharacteristic(BluetoothGattCharacteristic characteristic) {
    if (mBluetoothAdapter == null || mBluetoothGatt == null) {
        Log.w(TAG, "BluetoothAdapter not initialized");
        return;
    }

    boolean status = mBluetoothGatt.readCharacteristic(characteristic);
    System.out.println("Initialize reading process status:" + status);

}



public void setCharacteristicNotification(BluetoothGattCharacteristic characteristic,
                                          boolean enabled) {
    if (mBluetoothAdapter == null || mBluetoothGatt == null) {
        Log.w(TAG, "BluetoothAdapter not initialized");
        return;
    }
    mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);

    // This is specific to Heart Rate Measurement.
    if …
Run Code Online (Sandbox Code Playgroud)

android characteristics bluetooth-lowenergy android-bluetooth android-4.3-jelly-bean

6
推荐指数
1
解决办法
1万
查看次数

BLE 特性的长度限制是多少?

我正在阅读蓝牙核心规范。v 4.2文档,但我找不到任何有关特征长度限制的信息。

  • BLE 服务特性的长度限制是多少?

characteristics bluetooth-lowenergy

6
推荐指数
1
解决办法
2万
查看次数

通过响应写入多个蓝牙低功耗特征值

蓝牙核心规范V4.0卷.3 G部分4.9.3规定,对于具有响应的特征值的写入,使用属性协议写请求过程.

蓝牙核心规范V4.0第3卷第F部分3.3.2描述了

一旦客户端向服务器发送请求,该客户端就不会向同一服务器发送其他请求,直到收到响应PDU为止.

我想在使用CoreBluetooth的iOS应用程序中使用响应编写多个值.我是否必须自己管理此规范?或者我可以简单地使用- writeValue:forCharacteristic:type一次写入所有值,并且iOS管理每个请求仅在前一个请求被处理后发送?

我猜不出iOS会管理它,因为根据蓝牙核心规范V4.0第3卷第F部分第3.4.5.2节,写响应不包含写入特征的链接.但是,该- peripheral:didWriteValueForCharacteristic:error方法建议iOS以某种方式跟踪响应链接的特征.

有人可以确认或否认吗?

characteristics ios core-bluetooth bluetooth-lowenergy

5
推荐指数
1
解决办法
3869
查看次数

如何在ios swift中为BLE设备写入characteristc值

我正在开发 iOS BLE 应用程序来为手机充电。我做了所有正确的事情来发现特征。首先扫描外围设备并连接到它。发现具有通知和无响应写入属性的服务(FFB0)和特征(FFB1,FFB2)。

\n\n

我找到了客户端特征配置描述符。我想向 PCB 发送命令以解锁充电 我想将值写入 FFB2 特性,但外设没有响应。这是我的代码。

\n\n

我已经搜索了与此相关的所有内容,但没有找到任何解决方案如果有人提供此问题的解决方案,这将对我有所帮助。

\n\n

这是客户提供的文件:

\n\n

每个PCB上都有一个BLE4.0蓝牙模块,每个蓝牙模块都有一个单独的12字节长度的地址码,PCB数据通道,Service UUID为OxFFBO,包括两个特征值,分别是OxFFBI和OxFFB2,通信长度数据为1--20字节。\nOxFFB1为APP数据下载通道。OxFBB2为蓝牙上传数据通道。

\n\n

开机进入空闲模式,空闲模式下两个灯会闪烁。它会发送一个ID码(一个字节)到手机,手机中的APP会获取该ID码(一个字节)。\nID码可以通过手机设置来设置。是指通过ID码发送相应的解锁指令。

\n\n

解锁指令为0x55,0xe1,(ID0+1),时间,解锁指令说明如下:

\n\n

ID0为ID码,“time”为用户解锁时间(5-120分钟),\n请注意是二进制到十六进制的转换,\ntime==05表示5分钟,\ntime==6表示6分钟,\n时间==A表示10分钟,以此类推。\n如果PCB的ID0为0xff,\n解锁PCB 60分钟为:0x55,0xe1,0x00,0x3c;\n如果PCB的ID0为0x05 ,\n解锁 PCB 10 分钟为:0x55、0xe1、0x06、0x0a

\n\n

当PCB上的MCU收到解锁指令时,将开始打开输出并计时。\n计时时间到后系统再次进入空闲模式。\n在空闲模式下,长按该键进入关机休眠时间模式。

\n\n

uart 波特率设置为 9600。\nAPP 向 MCU 发送的查询指令为 0x55 0x01\nMCU 回复 APP 的信息格式为:0x55,0x02,bat_level,xH,XL(xH XL 代表当前电池电压值,\nxH - 代表高8位,XL---代表低8位)

\n\n
import CoreBluetooth\n\nlet batteryServiceCBUUID = CBUUID(string: "FFB0")\nlet batteryServiceRequestCBUUID = CBUUID(string: "FFB1")\nlet batteryServiceRequestCBUUID2 = CBUUID(string: "FFB2")\n\n class ChargingViewController: UIViewController , CBPeripheralDelegate \n ,CBCentralManagerDelegate {    \n\n  override func viewDidLoad() {\n    super.viewDidLoad()\n centralManager = CBCentralManager(delegate: self, …
Run Code Online (Sandbox Code Playgroud)

characteristics ios core-bluetooth cbperipheral swift

5
推荐指数
1
解决办法
7294
查看次数