feat(gml670-v2): 添加 BLE NUS 传输层
BLE 广播/连接管理、NUS 上下行通信、下行参数解析 (Resistance/Spotter/Heartbeat),3 次重试发送机制。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief 初始化 BLE 协议栈、NUS 服务和内部状态。
|
||||
* @return 0 成功,负 errno 失败。
|
||||
*/
|
||||
int ble_transport_init(void);
|
||||
|
||||
/**
|
||||
* @brief 启动 BLE 广播。
|
||||
*/
|
||||
void ble_transport_adv_start(void);
|
||||
|
||||
/**
|
||||
* @brief 通过 NUS 发送二进制帧,自动重试最多 3 次。未连接或通知未开启时静默丢弃。
|
||||
* @param data 待发送字节缓冲区。
|
||||
* @param len 字节数。
|
||||
*/
|
||||
void ble_transport_send(const uint8_t *data, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief 检查是否已连接且通知已使能。
|
||||
*/
|
||||
bool ble_transport_is_ready(void);
|
||||
|
||||
/* --- 下行参数 getter --- */
|
||||
float ble_transport_get_resistance_K(void);
|
||||
float ble_transport_get_resistance_B(void);
|
||||
float ble_transport_get_resistance_Tau(void);
|
||||
float ble_transport_get_spotter_threshold(void);
|
||||
bool ble_transport_get_spotter_enabled(void);
|
||||
int64_t ble_transport_get_last_heartbeat_ms(void);
|
||||
Reference in New Issue
Block a user