Android 从光传感器解读蓝牙GATT值

Android 从光传感器解读蓝牙GATT值,android,byte,bluetooth-lowenergy,sensors,gatt,Android,Byte,Bluetooth Lowenergy,Sensors,Gatt,我正在写一个应用程序,它从一个可编程设备的光传感器接收值。我试图确定我收到的是什么。我试图得到勒克斯值,这是由传感器提供的,但担心它需要转换。我不知道这个传感器的测量单位是什么。例如,Android手机的单位是SI Lux。应该很容易,但是对于这个传感器,规格没有说明 下面是给我输出的代码: case MSG_LIGHT: characteristic = (BluetoothGattCharacteristic) msg.obj; if (cha

我正在写一个应用程序,它从一个可编程设备的光传感器接收值。我试图确定我收到的是什么。我试图得到勒克斯值,这是由传感器提供的,但担心它需要转换。我不知道这个传感器的测量单位是什么。例如,Android手机的单位是SI Lux。应该很容易,但是对于这个传感器,规格没有说明

下面是给我输出的代码:

case MSG_LIGHT:
            characteristic = (BluetoothGattCharacteristic) msg.obj;
            if (characteristic.getValue() == null) {
                Log.w(TAG, "Error obtaining light value");
                return;
            }
            int formatlgt1 = -1;                
            formatlgt1 = BluetoothGattCharacteristic.FORMAT_SINT8;

            Log.i(LIGHT, "Light RawValue1 " + characteristic.getIntValue(formatlgt1, 0));
            Log.i(LIGHT, "Light RawValue2 " + characteristic.getIntValue(formatlgt1, 1));
            Log.w(LIGHT, "Light UUID " + characteristic.getUuid());
            Log.w(LIGHT, "Light Stored Value " + characteristic.getValue());
            Log.w(LIGHT, "Light Descriptors " + characteristic.getDescriptors());
            Log.d(LIGHT, "Light Characteristic " + characteristic);
            updateLightValues(characteristic);
            break;
很简单,只要读取传感器,并在读取时给我该传感器的各种输出。下面是输出:

Light RawValue1 4
Light RawValue2 9
Light UUID 0000aa91-0000-1000-8000-00805f9b34fb
Light Stored Value [B@431d30b0
Light Descriptors [android.bluetooth.BluetoothGattDescriptor@4300e508, android.bluetooth.BluetoothGattDescriptor@4300eaf8]
Light Characteristic android.bluetooth.BluetoothGattCharacteristic@43002b10
我的解释是,这一点的测量值是原始值1和2,但我记录了存储的帮助信息。问题是StoredValue是[B@431d30b0根据制造商的描述,第一个字节是地址00x03处的HILUX,第二个字节是地址00x04处的LOLUX,默认值为00:00

我在看什么?我错在哪里?我受伤的地方是我对阅读内容的理解。似乎无法获得一个好的搜索上下文来了解它


谢谢

好吧,假设前两个字节是16位的值,他们给出23362-这对于直接读取勒克斯来说似乎有点高-所以可能涉及一些缩放?233.62勒克斯?你是如何得到这个值的?根据规范,这个值可能非常接近。我将前两个字符的值作为ASCII 91和66。91 x 256+66=23362