Making Custom Formats

“Custom Format” is a configuration factor, which is separated from Profile Configuration, to retrieve a numerical value from SPP’s byte streams or from byte strings of GATT characteristic values. If you set the custom format wrong, you cannot get a correct graph.

The custom format can be applied to both binary data and text data. Text data is assumed to be UTF-8 encoding. ASCII code is part of the UTF-8.

Extraction of numerical data is performed in the following four steps.

  • Cut out a data unit(hereinafter, referred as “packet”) from the whole data
  • (Optional) Apply a regular expression to the packet in order to extract a portion of data to be decoded as a numerical value for visualizing
  • Decode the extracted portion of data as a numerical value according to a specified (primitive) data type
  • (Optional) Apply a transformation formula to the decoded value

Settings for each step are described in following sections.

1 Cutting Out Packet

v09-packet_termination-medium.png
Setting a termination method of the packet

You can choose one of the packet termination methods below.

  • fixed length(in bytes)
  • utf-8 regular expression delimiter
  • binary regular expression delimiter

Fixed Length

Specified length bytes from the beginning of data are processed as a packet. You have to specify the length bytes.

UTF-8 Regular Expression Delimiter

Separate at a position where it matches the UTF-8 regular expression. Whole data to be sliced are regarded as a UTF-8 string.

See “Regular expression syntax” section in “Pattern Class” (Android official webpage) for the syntax of the UTF-8 regular expression.

Binary Regular Expression Delimiter

Separate at a position where it matches the binary regular expression.

Binary regular expression is a simplified regular expression for using with binary.

If you use the UTF-8 regular expression, data are regarded as being encoded with UTF-8. In this case, when the MSB bit of a byte is 1, it is recognized as a multibyte character. However, if you use the binary regular expression, data can be matched to a plain binary by using a hexadecimal representation of a byte atom.

2 Applying Regular Expression to Packet(optional)

Specifying Packet Format
v09-set_regular_expression1-small.png
Specifying a format of the whole packet.
v09-set_regular_expression2-small.png
Specifying a regular expression applyed to the whole packet.

After separating the packet, you need to specify a format of it. When you don’t use a regular expression, select a format of the whole packet from the dropdown menu (in the next Step 2). When you use a regular expression, a numeric portion in the packet is specified. The position of the numeric portion is specified by a grouping operator(Parentheses). Only the first grouping operator is used.

The regular expression type is either UTF-8 or binary. You don’t have to select the same type as that of the packet delimiter used in Step 1.

The matched delimiter in Step 1 is a part of the packet to which the regular expression is applied in Step 2.
This is because the delimiter itself may be necessary to be matched as a numerical value.

The UTF-8 regular expression is a part of the Java API.
Please refer “Regular expression syntax” section in “Pattern Class (Android official webpage)” for syntax details.

For detailed information of the binary regular expression, see “Making Binary Regular Expression

3 Decoding Packet (or Portion of Packet)

Dropdown Menu of Primitive Format
v09-set_regular_expression2-medium.png

In Step 3, the packet or the portion of the packet is decoded to a real number.

Encoding of the packet or the portion of the packet can be made in various ways, for example, an 8-bit integer, a 16-bit integer, an IEEE754 floating point number, etc.

The packet or the portion of the packet can be a UTF-8 string even if you use a binary regular expression. For example, the string “3.5” (0x30,0x2e,0x35 in binary) can be recognized as a decimal real number, and “32f” (0x33,0x32,0x66 in binary) can be recognized as a hexadecimal integer.

4 Transformation Formula(optional)

Determining Transformation Formulta
v09-transformation_formula_option-medium.png

Optionally, you can apply a transformation formula. Using the transformation formula, for example, you can calculate a temperature in the app side, by converting an A/D-converted integer value supplied by a sensor device.

In the transformation formula, you can use addition, subtraction, multiplication, division and parentheses.

You can edit the transformation formula with dedicated user interfaces. See “Making Transformation Formula” for more information about the editing UI.

Managing Custom Formats

When you came to this screen from Profile Configuration editor, you cannot edit configurations other than configuration you selected.

Managing Single Setting
v09-data_pattern_management-single-medium.png

When you select the “Manage Custom Formats” in the Menu of the main screen, you can edit multiple configurations. You can switch the editing configuration to another configuration with the drop down list at the top of the screen.

Managing Multiple Settings
v09-data_pattern_management-list-medium.png

If there is no saved custom format, “*Scratch*” is selected.

To create a new Custom Format, select “Add New…” from the drop down list. Before you edit a new configuration, you need to give a unique name.

There are special Custom Formats named “Preset Custom Format”. They are fixed setting which are prepared by VisualLogger in advance. You cannot edit them, but you can see the setting of them by selecting from the drop down list.