格式字段决定特征值中包含的单个值的格式化方式。

本页所载信息参考了以下内容 Bluetooth核心规范第3卷,G部分,第3.3.3.5.2节。

如果一个格式不是整整的八位字节数,那么数据应包含在该值的最不重要的位内,其他所有位在传输时应置零,接收时忽略。如果特征值小于一个八位字节,则占据整个八位字节。定义了以下格式值。

Format Short Name Description Exponent Value
0x00 rfu Reserved for future use No
0x01 boolean unsigned 1-bit; 0=false, 1=true No
0x02 2bit unsigned 2-bit integer No
0x03 nibble unsigned 4-bit integer No
0x04 uint8 unsigned 8-bit integer Yes
​0x05 uint12 unsigned 12-bit integer Yes
​0x06 uint16 unsigned 16-bit integer Yes
0x07 uint24 unsigned 24-bit integer Yes
​0x08 uint32 unsigned 32-bit integer Yes
​0x09 uint48 unsigned 48-bit integer Yes
​0x0A uint64 unsigned 64-bit integer Yes
​0x0B uint128 unsigned 128-bit integer Yes
​0x0C sint8 signed 8-bit integer Yes
​0x0D sint12 signed 12-bit integer Yes
​0x0E sint16 signed 16-bit integer Yes
​0x0F sint24 signed 24-bit integer Yes
​0x10 sint32 signed 32-bit integer Yes
​0x11 sint48 signed 48-bit integer Yes
​0x12 sint64 signed 64-bit integer Yes
​0x13 sint128 signed 128-bit integer Yes
​0x14 float32 IEEE-754 32-bit floating point No
​0x15 float64 IEEE-754 64-bit floating point No
​0x16 SFLOAT IEEE-11073 16-bit SFLOAT No
​​0x17 FLOAT IEEE-11073 32-bit FLOAT No
​​0x18 duint16 IEEE-20601 format No
​​0x19 utf8s UTF-8 string No
​0x1A utf16s UTF-16 string No
​​0x1B struct Opaque structure No
​​0x1C-0xFF rfu Reserved for Future Use No

补充格式说明

  • 当对IPv4地址进行编码时,应使用uint32格式类型。
  • 当对IPv6地址进行编码时,应使用uint128格式类型。
  • 当对BDBluetooth _ADDR进行编码时,应使用uint48格式类型。
  • 一个duint16是两个uint16值连在一起。