【发布时间】:2020-05-31 03:31:55
【问题描述】:
我正在使用 ArduinoBLE 库来创建服务和特性:
BLEService angleService("1826");
BLEFloatCharacteristic pitchBLE("2A57", BLERead | BLENotify);
我添加服务和特性并宣传我的设备:
BLE.setLocalName("acsAssist");
BLE.setAdvertisedService(angleService);
angleService.addCharacteristic(pitchBLE);
BLE.addService(angleService);
pitchBLE.writeValue(0);
BLE.advertise();
我执行了一些计算,然后将我的计算值写入服务:
pitchBLE.writeValue(posiPitch);
posiPitch 是一个浮点值,例如 1.96。它可以从 -90.00 到 90.00
我尝试从我的 Android 应用中读取此值:
(characteristic.getFloatValue(BluetoothGattCharacteristic.FORMAT_SFLOAT,0))
我得到了疯狂的数字,例如-1.10300006E9。
如何读取我的浮点值,以便我的 android 应用程序值与 arduino 值匹配?
【问题讨论】:
标签: android arduino bluetooth-lowenergy gatt bluetooth-gatt