01Introduction:
The DSPS (Dialog Serial Port Service) protocol stack is based on the BLE GATT protocol to implement serial data transmission. The core process is divided into four stages: initialization, connection management, data transmission, and low power control.
Initialization → Broadcasting/Scanning → Establishing Connection → Data Transmission → Sleep/Wake → Disconnect → Loop
02Detailed Flowchart Analysis
1. Initialization Stage
Hardware Initialization
Configure peripherals (GPIO, UART, SPI, etc.)
Initialize the BLE protocol stack and kernel (Riviera Waves RTOS)
Register DSPS Service
Register TX/RX Characteristics and Flow Control features in GATT.
Low Power Configuration
Enable extended sleep mode (CFG_EXT_SLEEP) and set default connection parameters (connection interval, slave latency).
2. Broadcasting and Connection Establishment
Peripheral Side
Start directed advertising (3 seconds cycle), enter extended sleep immediately after broadcasting.
The advertising data includes device name and UUID.
Central Side
Periodic scanning (e.g., 3 seconds cycle), parse advertising packets and filter target devices.
Call gapc_conn_param_update to initiate connection request.
3. Data Transmission Stage
Data Sending (TX)
The host sends data to the peripheral.
The peripheral actively pushes data through the Notify characteristic (RX).
Flow Control Mechanism
When the receive buffer is full, send pause/resume signals through the Flow Control Characteristic.
Error Handling
Check the checksum of the data, if an error occurs, trigger retransmission (ATT Error Response).
4. Low Power Management
Extended Sleep Mode
Call app_easy_sleep() to enter sleep when idle, wake up on BLE events or GPIO interrupts.
During connection, extend sleep time by adjusting Slave Latency.
Dynamic Power Optimization
Turn off unused peripherals (e.g., ADC, SPI) to reduce GPIO pull-up/pull-down power consumption.
5. Connection Disconnection and Recovery
Active Disconnection
After data transmission is complete, call gapc_disconnect to terminate the connection.
Timeout Handling
If no device is scanned or communication times out within 20 seconds, trigger scan_timeout_cb callback and enter low power mode.
03Code Examples for Key Nodes in Flowchart
1. Initialize DSPS Service
void user_app_init(void) {
// Enable extended sleep
arch_set_sleep_mode(ARCH_EXT_SLEEP_ON);
// Register DSPS service
sps_server_init();
sps_client_init();
// Configure advertising parameters
app_easy_gap_advertise_start();
}
2. Data Sending Function
void send_data(uint8_t *data, uint16_t len) {
// Send data via TX Characteristic
sps_send_data(data, len);
// Trigger sleep (if idle)
app_easy_sleep();
}
3. Low Power Connection Parameter Configuration
static struct gapc_conn_param conn_params = {
.intv_min = 160, // 200ms (160 * 1.25ms)
.intv_max = 160,
.latency = 4, // Actual wake interval = 200ms * 5 = 1 second
.timeout = 600 // 6 seconds timeout
};
04Flowchart05References
SDK Documentation:
DSPS_Protocol_Stack.pdf
Example Projects:
ble_app_throughput, ble_app_profile
Low Power Design Guide:
UM-B-119_DA14531_SW_Platform_Reference