Bluetooth Communication Protocol for Coating Thickness Gauges

Recently involved with the automotive industry coating thickness gauge hardware via Bluetooth communication, involving the transmission of data and parsing of relevant data, the protocol is organized.

I. Hardware parameters
The instrument is connected with cell phone or computer through Bluetooth, and the Bluetooth communication adopts Bluetooth transmitting module.

II. 16-bit CRC calibration

unsigned int  Crc16Code(unsigned char  *pInFrame, unsigned int  dwInLen)
{
    unsigned int  code = 0xFFFF;
    unsigned int  Poly = 0xA001;
    int flag = 0;
    int i,j;
    for( j=0; j < dwInLen; j++)
    {
			code ^= (unsigned int ) (*pInFrame);
			for(i=0; i<8;i++)
			{
				if ( code & 0x0001 ) flag = 1;
				code = code>>1;
				if ( flag )
				{
					code ^= Poly;
					flag = 0;
				}
			}
			pInFrame ++;
    	}
    return code;
}

III. The host computer query thickness gauge information
The upper computer sends:

1 2 3 4~M M+1 M+2
Number of bytes 0xBF Detailed Function Code Range of query CRC low byte CRC high byte
  • 1st byte: Total number of bytes from 3 to M (including 3 and M)
  • 2nd byte 0xBF: Query information function code (fixed at 0xBF)
  • Byte 3: Detailed function code, see detailed instruction
  • Byte 4 to M: Range of query information (this byte is not required if the range is not specified)
  • Byte M+1, M+2: CRC16 checksum from byte 1 to M.

lower Reply:

1 2 3 4~M M+1 M+2
Number of bytes 0xBD Detailed Function Code Returned data CRC low byte CRC high byte
  • 1st byte 0x01: Total number of bytes from 3 to M (including 3 and M)
  • 2nd byte 0xBD: Return information function code (fixed at 0xBD)
  • Byte 3: Detailed function code, see detailed instruction
  • Byte 4 to M: Returned data
  • Byte M+1, M+2: CRC16 checksum from byte 1 to M

3.1 Upper computer query thickness gauge upper and lower limit alarm switch status command:

1 2 3 4 5
0x01 0xBF 0x41 CRC Low Byte CRC High Byte

The lower computer replies:

1 2 3 4 5 6
0x02 0xBD 0x41 0: Switch is not turned on 1: switch is on (uint8_t) CRC low byte CRC high byte

3.2 Upper computer query over the upper limit alarm value instruction:

1 2 3 4 5
0x01 0xBF 0x5E CRC low byte CRC high byte

The lower computer replies:

1 2 3 4~5 6 7
0x03 0xBD 0x5E Alarm Value (int16_t) CRC Low Byte CRC High Byte

3.3 Upper computer query over the lower limit alarm value instruction:

1 2 3 4 5
0x01 0xBF 0x56 CRC low byte CRC high byte

The lower computer replies:

1 2 3 4~5 6 7
0x03 0xBD 0x56 Alarm Value (int16_t) CRC Low Byte CRC High Byte

3.4 Upper computer query serious over the upper limit alarm value instruction:

1 2 3 4 5
0x01 0xBF 0x68 CRC low byte CRC high byte

The lower computer replies:

1 2 3 4~5 6 7
0x03 0xBD 0x68 Alarm Value (int16_t) CRC Low Byte CRC High Byte

3.5 Upper computer query severe over lower limit alarm value instruction:

1 2 3 4 5
0x01 0xBF 0x6C CRC low byte CRC high byte

The lower computer replies:

1 2 3 4~5 6 7
0x03 0xBD 0x6C Alarm Value (int16_t) CRC Low Byte CRC High Byte

3.6 Upper computer query the number of data in the data group of the thickness gauge instruction:

1 2 3 4 5
0x01 0xBF 0x43 CRC Low Byte CRC High Byte

The lower computer replies:

1 2 3 4 5 6
0x02 0xBD 0x43 Quantity of data (uint8_t) CRC Low Byte CRC High Byte

3.7 Upper computer to obtain the thickness gauge specified range of data instruction:

1 2 3 4 5 6 7
0x03 0xBF 0x40 Number of the first data requested by the upper computer (uint8_t) Number of data requested by the upper computer (uint8_t) CRC low byte CRC high byte

The lower computer replies:

1 2 3 4 5~(4+3*M) 3*M+5 3*M+6
3*Replied Data Volume+2 0xBD 0x40 Number of Valid Data Data Array(uint24_t) CRC low byte CRC high byte
  • Number of valid data: the total number of valid data from the beginning to the last valid data in the instrument array
  • Data array: three bytes to store a data, this instruction single time to get a maximum of 10 data. If the number of valid data is less than the number of requested data, only valid data will be uploaded.

3.8 Upper computer query the current measurement mode of the thickness gauge instruction:

1 2 3 4 5
0x01 0xBF 0x6D CRC low byte CRC high byte

The lower computer replies:

1 2 3 4 5 6
0x02 0xBD 0x6D Measurement Mode (uint8_t); Simple Mode: 0x01; Professional mode: 0x02 CRC low byte CRC high byte

3.9 Upper computer obtains vehicle component data instruction:

1 2 3 4 5 6
0x03 0xBF 0x67 Part Number (uint16_t) CRC Low Byte CRC High Byte

Lower byte reply:

1 2 3 4 5~(4+3*M) 3*M+5 3*M+6
Data set*3+3 0xBD 0x67 Part number (uint16_t) Measurement value (max. 6) (uint24_t) CRC low byte CRC high byte

Get the data of the whole vehicle, the upper computer needs to send the command to get the data of each part one by one to get the data of all the parts

3.10 The host computer queries the current part number instruction:

1 2 3 4 5
0x01 0xBF 0x70 CRC low byte CRC high byte

The lower computer replies:

1 2 3 4~5 6 7
0x03 0xBD 0x70 Part Number (uint16_t) CRC Low Byte CRC High Byte

IV. The upper computer sets the thickness gauge to turn state, or the thickness gauge sets the state and then actively uploads the state to the upper computer.

The upper computer sends:

1 2 3 4~M M+1 M+2
Number of bytes 0xBD Detailed Function Code Set Status CRC Low Byte CRC High Byte
  • Byte 1: Total number of bytes from 3 to M (including 3 and M)
  • 2nd byte 0xBD: Set status function code (fixed to 0xBD)
  • Byte 3: Detailed function code, see detailed instruction
  • Byte 4 to M: Setting status
  • Byte M+1, M+2: CRC16 checksum from byte 1 to M

Thickness gauge reply instruction is the same as sending instruction, after the thickness gauge sets the state, it will also send this instruction to the upper computer once, the upper computer should follow to set the state and keep synchronization.

4.1 Upper host computer set the upper and lower limit alarm switch state instruction:

1 2 3 4 5 6
0x02 0xBD 0x41 1=On, 0=Off (uint8_t) CRC Low Byte CRC High Byte

Thickness gauge reply or active upload command is the same.

4.2 Upper computer setup over upper limit alarm value instruction:

1 2 3 4~5 6 7
0x03 0xBD 0x5E Upper and Lower Limit Values (Int16_t) CRC Low Byte CRC High Byte

It needs to be set with the upper and lower limit alarms turned on, otherwise the instrument will reply 00 98 00 1a

4.3 Command for upper computer to set the alarm value of over and under limit:

1 2 3 4~5 6 7
0x03 0xBD 0x56 Lower Limit Value (Int16_t) CRC Low Byte CRC High Byte

It needs to be set with the upper and lower limit alarms turned on, otherwise the instrument will reply 00 98 00 1a

4.4 Upper computer set serious over upper limit alarm value instruction:

1 2 3 4~5 6 7
0x03 0xBD 0x68 Upper and Lower Limit Values (Int16_t) CRC Low Byte CRC High Byte

It needs to be set with the upper and lower limit alarms turned on, otherwise the instrument will reply 00 98 00 1a

4.5 Upper computer set severe over-lower limit alarm value instruction:

1 2 3 4~5 6 7
0x03 0xBD 0x6C Lower Limit Value (Int16_t) CRC Low Byte CRC High Byte

It needs to be set with the upper and lower limit alarms turned on, otherwise the instrument will reply 00 98 00 1a

4.6 The upper computer deletes the specified number of data in the data group instruction:

1 2 3 4 5 6
0x02 0xBD 0x2D Number of data to be deleted (uint8_t) CRC low byte CRC high byte

4.8 Upper computer set thickness gauge measurement mode command:

1 2 3 4 5 6
0x02 0xBD 0x6D Measurement Mode (uint8_t); Simple Mode: 0x01; Professional mode: 0x02 CRC low byte CRC high byte

4.9 The upper computer clears the data instruction of the vehicle component:

1 2 3 4~5 6 7
0x03 0xBD 0x64 Vehicle Parts (Uint16_t) CRC Low Byte CRC High Byte

4.10 The upper computer switches the current part command:

1 2 3 4~5 6 7
0x03 0xBD 0x70 Vehicle Parts (Uint16_t) CRC Low Byte CRC High Byte

4.11 The upper computer switches the vehicle data group command:

1 2 3 4~5 6 7 8
0x04 0xBD 0x63 Measurement data group number (Uint16_t) 0xAA indicates that the data group is cleared after switching to a new data group; the other data indicates that the data group is not cleared after switching to a new data group (uint8_t) CRC Low Byte CRC High Byte

Note: This command is only available in Vehicle Pro mode.

4.12 The upper computer deletes all the data of vehicle parts instruction:

1 2 3 4~5 6 7
0x03 0xBD 0x73 Vehicle number to be deleted (1~999) (Uint16_t) CRC low byte CRC high byte

V. Thickness gauge real-time measurement data uploading

1 2 3 4~5 6 7 8~10 6 7
0x08 0xBD 0x52 Vehicle Concise Mode: no practical meaning; Vehicle Specialized Mode: indicates the part number (uint16_t)_t) Vehicle Concise Mode: indicates the storage position of the oldest data in the group. Vehicle professional mode: always 0.(uint8_t) Vehicle concise mode: indicates the number of data in the group, range 0~60. vehicle professional mode: range 0~6 Indicates the current measurement data(uint24_t) CRC Low Byte CRC High Byte

Reserved digits: Absolute value of measured value <99.95μm, 1 decimal digit is reserved;

Measured value absolute value >=99.95μm, [retain integer].

Measured values are converted using rounding.

Below is an example of how the measured values should be converted.

Positive number example:

08 bd 52 7e 16 00 23 a9 64 00 75 ca

A9 64 00 is the current measurement data, data collation: the data set A9 64 00 is stored in small end mode, to perform calculations it should be converted to the correct reading order: 0x0064A9.

Convert this data to a binary number: 0000 0000 0110 0100 1010 1001.

The lower 2 bits indicate the substrate: 01 for iron base, 10 for aluminum base, and 11 for metal putty.

Thickness value calculation: the current value of the highest bit is 0, in 0000 0000 0110 0100 1010 1001 before adding 0x00 for 0000 0000 0000 0000 0110 0100 1010 1001, that would be equivalent to not adding, and then the binary value is converted to a decimal value, to get 25769, 25769 / 256.0 (floating-point type). Get 100.66015625, which is the thickness value, after which it is rounded according to the processing of the instrument to get 101μm.

Negative number example:

08 bd 52 81 27 00 05 19 d3 ff 43 fb

19 D3 FF is the current measurement data, data collation: 19 D3 FF This data is stored in small-end mode, and to perform calculations it should be converted to the correct reading order: 0xFFD319.

Convert this data to a binary number: 1111 1111 1101 0011 0001 1001.

The lower 2 bits indicate the substrate: 01 for iron base, 10 for aluminum base and 11 for metal putty.

Thickness value calculation: the highest bit of the current value is 1, add 0xFF before 1111 1111 1111 1101 0011 0001 1001 for 1111 1111 1111 1111 1101 0011 0001 1001, and then this data is processed into a decimal value of the type int32_t to get -11495, -11495/256.0 (floating-point type) to get -44.90234375, which is the thickness value, after which it is rounded according to the instrument’s processing to get -44.9μm.

VI. Error data recovery

Thickness gauge reply:

1 2 3 4
Byte count 0x98 CRC low byte CRC high byte
  • 1st byte 0x00: Total number of bytes
  • Byte 2 0x98: invalid instruction
  • Byte 3 and 4: CRC16 checksum from byte 1 to 2

VII. Correspondence table of vehicle components

  • Front hatch: 0x8010
  • Left front wing panel: 0x0010
  • Left A-pillar: 0x0031
  • Left Front Door: 0x0020
  • Left B-pillar: 0x0832
  • Left Rear Door: 0x0F20
  • Left C-pillar: 0x0F33
  • Left Rear Fender: 0x0F10
  • Left D-pillar: 0x0F34
  • Trunk lid: 0x8F10
  • Right D-pillar: 0xFF34
  • Right rear fender: 0xFF10
  • Right C-pillar: 0xFF33
  • Right rear door: 0xFF20
  • Right B-pillar: 0xF832
  • Right Front Door: 0xF020
  • Right A-pillar: 0xF031
  • Right front wing: 0xF010
  • Roof: 0x8810

Looks fancy! Do you have a question?

1 Like