【问题标题】:Bluetooth Floating Point representation蓝牙浮点表示
【发布时间】:2019-12-31 12:06:01
【问题描述】:

我正在尝试实现这个蓝牙网状网络特性:

<!--
  Copyright 2017 Bluetooth SIG, Inc. All rights reserved.
-->
<Characteristic xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schemas.bluetooth.org/Documents/characteristic.xsd" name="Illuminance" type="org.bluetooth.characteristic.illuminance" uuid="2AFB" last-modified="2017-07-11" approved="Yes">
  <InformativeText>
    <Abstract>
    The Illuminance characteristic is used to represent a measure of illuminance in units of lux.
    </Abstract>
  </InformativeText>
  <Value>
    <Field name="Illuminance">
      <InformativeText>Unit is lux with a resolution of 0.01.</InformativeText>
      <Format>uint24</Format>
      <Unit>org.bluetooth.unit.lux</Unit>
      <Minimum>0</Minimum>
      <Maximum>167772.14</Maximum>
      <DecimalExponent>-2</DecimalExponent>
      <BinaryExponent>0</BinaryExponent>
      <Multipler>1</Multipler>
      <Description>
        A value of 0xFFFFFF represents 'value is not known'. All other values are Prohibited.
      </Description>
    </Field>
  </Value>
</Characteristic>

https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Specifications/Mesh/Xml/Characteristics/org.bluetooth.characteristic.illuminance.xml。该特性以 3 个字节表示勒克斯值。

但我不知道如何将像 0x123456 这样的值转换为真正的浮点数。似乎没有使用标准的 IEEE 754 标准。我也不知道DecimalExponentBinaryExponent 是什么意思。

谁能帮帮我? 亲切的问候,大安

【问题讨论】:

  • 您链接到的页面的文本很短,应该包含在您的问题中。外部链接更改或消失,然后导致 Stack Overflow 问题变得错误或无用。始终在问题本身中包含与您的问题相关的所有信息。

标签: floating-point bluetooth-mesh


【解决方案1】:

您链接到的页面中没有浮点数。它使用 -2DecimalExponent 仅指定一个 24 位整数值,在普通二进制中将是从 0 到 16,777,214 的某个数字 x(其中 16,777,215 保留用于“未知”)表示x•10-2 lux 的值,范围从 0.00 lux 到 167,772.14 lux。这是定点,不是浮点;该点固定在纯二进制整数表示形式左侧两位数的位置。

【讨论】:

  • 非常感谢,现在已经很清楚了。我还编辑了开头的帖子。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-14
相关资源
最近更新 更多