HOMEABOUT USPRODUCT INFORMATION A PRACTICAL GUIDE TO CUSTOM ESP32 DIGITAL WALKIE-T...

A Practical Guide to Custom ESP32 Digital Walkie-Talkies (Part 3): Deconstructing the Serial Control Protocol

11

Sep . 2025

By sdga:

The key to effective communication with the module is to correctly implement its serial control protocol. This protocol uses a binary frame format, and all parameter configuration and status queries are accomplished by sending and receiving specific data frames.

Frame Structure Analysis

Serial Protocol Frame Structure

Serial Protocol Frame Structure Example

Each data frame follows a fixed structure, consisting of a header, command, data, and tail, among other parts.

Table 3: Serial Protocol Frame Structure

Offset (Bytes)

Field

Length (Bytes)

Description

0

Head

1

Frame header, fixed at 0x68.

1

CMD

1

Command word, defines the function of the frame, such as setting frequency, sending SMS, etc.

2

R/W

1

Read/Write flag. 0x00=Read, 0x01=Write, 0x02=Module-initiated report.

3

S/R

1

Set/Response flag. When sent by the host, it is a set request; when replied by the module, it is a response status.

4-5

CKSUM

2

16-bit checksum. Covers all bytes from CMD to the end of DATA.

6-7

LEN

2

Data length of the DATA field (in bytes).

8...

DATA

n (determined by LEN)

Data payload. The specific content is defined by the CMD.

8+n

TAIL

1

Frame tail, fixed at 0x10.

Checksum Calculation Method

According to the protocol document, the checksum is calculated as follows: each pair of bytes in the data to be checked is formed into a 16-bit number and then added sequentially. If the data frame has an odd length, 0x00 is appended to the last byte. The carry-over part (exceeding 16 bits) from the accumulation process is added back to the lower 16 bits of the result until the sum is less than or equal to 0xFFFF. Finally, the resulting 16-bit number is XORed with 0xFFFF to get the final checksum.

The reference C code provided in the protocol document is as follows:

uint16_t PcCheckSum(uint8_t *buf, int16_t len) {
    uint32_t sum = 0;
    while (len > 1) {
        sum += 0xFFFF & ((*buf << 8) | *(buf + 1));
        buf += 2;
        len -= 2;
    }
    if (len) {
        sum += (0xFF & *buf) << 8;
    }
    while (sum >> 16) {
        sum = (sum & 0xFFFF) + (sum >> 16);
    }
    return ((uint16_t)sum ^ 0xFFFF);
}


Checksum Calculation Flow Example

A noteworthy engineering detail is that the protocol document mentions that if the user does not want to calculate the checksum, the CKSUM field can be sent as 0x0000, and the module will ignore the checksum process. This can be very useful during the initial debugging phase, but for the sake of communication reliability, the correct checksum should be implemented and used in the final product.

Complete Command Set Reference

The following table categorizes and organizes all the commands supported by the module, providing a more structured reference than the original documentation.

Table 4: DMR858M Command Code (CMD) Complete Reference

CMD (Hex)

Function Description

R/W Support

Scope

Persistent

Notes

Configuration Commands (Saved on Power-off)






0x01

Change Channel

Write

Current

Yes

Switch to the specified channel.

0x02

Set Receive Volume

Write

All

Yes

Set the audio output volume level.

0x0B

Set Microphone Gain

Write

All

Yes

Adjust microphone sensitivity.

0x0C

Set Power Save Mode

Write

All

Yes

Enable or disable low-power mode.

0x0D

Set TX/RX Frequency

Read/Write

Current

Yes

Set the receive and transmit frequencies for the current channel.

0x12

Set Squelch (SQ) Level

Read/Write

Current

Yes

Set the squelch threshold for analog mode.

0x13

Set CTCSS/CDCSS Mode

Read/Write

Current

Yes

Set the sub-audio mode (e.g., receive only, transmit only, both).

0x14

Set CTCSS/CDCSS Value

Read/Write

Current

Yes

Set the specific sub-audio code.

0x17

Set High/Low Power

Read/Write

Current

Yes

Switch the transmit power for the current channel.

Operational Commands (Effective Immediately)






0x03

Scan

Write

Current

No

Start or stop channel scanning.

0x06

Initiate Call

Write

Current

No

Initiate a group or private call.

0x07

Send SMS

Write

Current

No

Send a DMR text message.

0x09

Emergency Alarm

Write

Current

No

Trigger the emergency alarm function.

0x15

Monitor Switch

Write

Current

No

Force open the squelch to monitor channel activity.

Status Query Commands






0x04

Check TX/RX Status

Read

Current

No

Query if the module is in receive, transmit, or idle state.

0x05

Read Signal Strength

Read

Current

No

Get the RSSI value of the current received signal.

0x24

Read ID

Read

All

No

Read the module's DMR ID.

0x25

Read Firmware Version

Read

All

No

Read the module's firmware version number.

0x28

Check Encryption Status

Read

Current

No

Query if encryption is enabled on the current channel.



A Practical Guide to Custom ESP32 Digital Walkie-Talkies Series


Part 1: In-depth Analysis of the DMR858M Module

Part 2: Hardware Integration and Reference Design

Part 3: Deconstructing the Serial Control Protocol

Part 4: Firmware Development and Driver Design

Part 5: Exploring Advanced Features and Conclusion


Contact Us

 +86-755-23080616

 sales@nicerf.com

Website: https://www.nicerf.com/

Address: 309-315, 3/F, Bldg A, Hongdu business building, Zone 43, Baoan Dist, Shenzhen, China

Contact us
Privacy Policy

Privacy Policy

· Privacy Policy

There is currently no content available


           

Email:sales@nicerf.com

Tel:+86-755-23080616

Address:309-315, 3/F, Bldg A, Hongdu business building, Zone 43, Baoan Dist, Shenzhen, China


×